Intermediate → Advanced30 min read· Topic 9.1

Containers and orchestration

Docker, Kubernetes architecture, scheduling, networking, Helm, service mesh

🐳Key Takeaways

  • 1
    Containers package code + dependencies into a portable unit — same behavior everywhere
  • 2
    Docker builds images; Kubernetes orchestrates containers at scale (scheduling, scaling, networking, healing)
  • 3
    K8s core: Pods (smallest unit), Deployments (desired state), Services (stable networking), Ingress (external access)
  • 4
    Helm charts template K8s manifests; GitOps (ArgoCD) syncs cluster state from Git

From Docker to Kubernetes

Containers solved 'works on my machine' by packaging applications with all dependencies. Docker made containers developer-friendly. Kubernetes made running containers at scale manageable — handling scheduling, networking, scaling, and self-healing across clusters of machines.

Kubernetes Architecture

API Server: REST API — all K8s communication goes through here.

etcd: Distributed key-value store holding all cluster state (Raft consensus).

Scheduler: Assigns pods to nodes based on resource requirements and constraints.

Controller Manager: Runs control loops that watch cluster state and make changes (e.g., if desired replicas = 3 but only 2 are running, start another).

kubelet: Agent on each node that ensures containers are running as specified.

kube-proxy: Handles networking rules — routes traffic to correct pods.

Container Runtime: Actually runs containers (containerd, CRI-O).

Pod: Smallest deployable unit (1+ containers). Ephemeral — can be deleted/recreated anytime.

Deployment: Declarative desired state (image, replicas). Controller ensures reality matches desired state.

Service: Stable IP + DNS name for a set of pods. Types: ClusterIP (internal), NodePort, LoadBalancer.

Ingress: HTTP routing rules for external traffic (host/path-based routing, SSL termination).

Deployment Strategies

StrategyHow It WorksDowntimeRollback
Rolling UpdateReplace pods one at a timeZeroAutomatic (K8s default)
Blue/GreenRun new version alongside old, switch trafficZeroInstant (switch back)
CanaryRoute 1-5% traffic to new version, gradually increaseZeroPull canary
RecreateKill all old pods, start new onesYesRedeploy old version

Advantages

  • Kubernetes automates deployment, scaling, and healing
  • Declarative desired-state model prevents drift
  • Massive ecosystem (Helm, Istio, ArgoCD, etc.)

Disadvantages

  • K8s has a steep learning curve
  • Operational overhead for small teams
  • Debugging network issues in K8s is notoriously hard

🧪 Test Your Understanding

Knowledge Check1/1

What does the Kubernetes scheduler do?