Infrastructure
Containerization and Orchestration
Containers package applications with their dependencies for consistent deployment. Orchestration platforms like Kubernetes automate scaling, healing, and rolling updates across clusters.
- Containers â Lightweight, isolated application packaging
- Kubernetes â Declarative orchestration at scale
- Auto-Scaling â Dynamic resource adjustment based on load
Containers solved "it works on my machine"; orchestration solved "how do I run 1000 of them."
Containers
A container packages an application with its dependencies into a standardized unit.
Containers vs Virtual Machines
| Aspect | Container | Virtual Machine |
|---|---|---|
| Isolation | Process-level (shared kernel) | Hardware-level (dedicated kernel) |
| Startup | Milliseconds | Minutes |
| Size | Megabytes | Gigabytes |
| Density | 100s per host | 10s per host |
| Overhead | Minimal | Hypervisor overhead |
| Security | Weaker (shared kernel) | Stronger (full isolation) |
Docker
The de facto standard for building and running containers.
Dockerfile example:
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
EXPOSE 3000
HEALTHCHECK CMD curl -f http://localhost:3000/health
CMD ["node", "server.js"]
Image Layers
Kubernetes
The industry-standard container orchestration platform.
Key Kubernetes Concepts
| Concept | Description |
|---|---|
| Pod | Smallest deployable unit; one or more containers |
| Deployment | Manages replica sets and rolling updates |
| Service | Stable network endpoint for a set of pods |
| Ingress | HTTP routing to services |
| ConfigMap | Non-secret configuration data |
| Secret | Sensitive data (passwords, keys) |
| Namespace | Virtual cluster isolation |
Pod Scheduling
Scheduling Constraints
| Constraint | Description |
|---|---|
| Resource requests | Minimum CPU/memory required |
| Node affinity | Prefer/require specific node labels |
| Pod affinity | Co-locate pods on same node |
| Pod anti-affinity | Spread pods across nodes/zones |
| Taints/Tolerations | Reserve nodes for specific workloads |
Auto-Scaling
Practice Exercises
-
Design: Design a Dockerfile for a Node.js application that builds in under 30 seconds and produces an image under 100MB. Explain each optimization.
-
Kubernetes: Write a Deployment manifest for a web app with 3 replicas, resource limits, rolling updates, and a health check endpoint.
-
Scaling: Your service receives 10,000 QPS. Each pod handles 1,000 QPS with 500m CPU. Design the HPA and Cluster Autoscaler configuration.
-
Comparison: Compare Kubernetes, Docker Swarm, and Amazon ECS for a small team running 10 microservices. When would you choose each?
What to Learn Next
-> Service Mesh Envoy, Istio, and sidecar proxy patterns.
-> CI/CD Pipelines Continuous integration and deployment strategies.
-> Observability Logging, metrics, tracing, and monitoring.
-> Cost Optimization Cloud cost management and right-sizing.
-> Scalability Fundamentals Vertical vs horizontal scaling and capacity planning.
-> Load Balancing Distribution algorithms and L4 vs L7 load balancing.