⚙️DevOps
Core skills · Lesson 5/8

Kubernetes — Orchestrating Containers

30 min 1 exercise 1 quiz

What you'll learn

  • The problem Kubernetes solves
  • Pods, nodes, and the desired-state idea
  • Self-healing and auto-scaling
  • Why "K8s" is a career-defining skill

The conductor of the container orchestra 🎼

One container is easy to run. But real systems have hundreds — a web service needs 20 copies, the API needs 50, and they're spread across dozens of servers. Managing that by hand is impossible: what starts them? what restarts a crashed one at 3 a.m.? what adds copies when traffic spikes? The answer is Kubernetes (K8s) — the industry-standard container orchestrator, the conductor that keeps the whole orchestra playing.

The vocabulary:

  • Pod — the smallest unit; usually one running container (plus its close helpers).
  • Node — a worker machine (server) that runs pods.
  • Cluster — all your nodes together, managed as one.

The big idea: desired state. This is what makes Kubernetes special. You don't give it step-by-step commands. Instead you declare the state you want — "I always want 5 copies of my web app running" — and Kubernetes continuously works to make reality match. This is the declarative idea from Infrastructure as Code, applied to running containers.

From that one idea, superpowers emerge automatically:

  • Self-healing — a container crashes? Kubernetes notices reality (4 running) doesn't match desired (5) and instantly starts a replacement. No human paged at night.
  • Auto-scaling — traffic spikes? It launches more pods; traffic drops? It removes them. You declare the rules; it enforces them.
  • Rolling updates — deploy a new version gradually, pod by pod, with zero downtime; roll back instantly if something's wrong.
  • Load balancing — spread requests across all healthy pods.

The trade-off (honesty): Kubernetes is powerful but genuinely complex — it has a steep learning curve and is overkill for small projects (a simple app is fine with plain containers or serverless). But for large-scale systems, K8s is the standard, and skilled Kubernetes engineers are among the best-paid in DevOps. It's worth learning once you're comfortable with Docker.

Rolling updates and health checks 🩺

Pods are constantly created and destroyed — during scaling, self-healing, and especially deployments. So how does Kubernetes deploy a new version of your app without downtime?

Rolling updates replace pods gradually, never all at once:

Desired: 4 pods running v2 (currently: 4 running v1)

Step 1: start 1 pod on v2  → [v1 v1 v1 v1 v2]      (5 running briefly)
Step 2: kill 1 pod on v1   → [v1 v1 v1 v2]
Step 3: start 1 pod on v2  → [v1 v1 v1 v2 v2]
... repeat until all 4 are v2, one small batch at a time

At every moment, there are always enough healthy pods serving traffic — users never see a gap. If a health check on the new version fails partway through, Kubernetes automatically halts the rollout before it replaces every pod, limiting the blast radius of a bad release.

Health checks (probes) are how Kubernetes knows a pod is actually working, not just "running":

  • Liveness probe — "is this pod still alive?" If it fails repeatedly, Kubernetes kills and restarts the pod (self-healing in action).
  • Readiness probe — "is this pod ready to receive traffic yet?" A pod can be alive but still warming up (loading data, connecting to a database) — Kubernetes won't send it traffic until readiness passes.

Without probes, Kubernetes would treat a frozen, unresponsive pod as perfectly healthy just because the process hasn't crashed — probes are what make self-healing and rolling updates actually safe in practice.

Exercise 1

Simulate a rolling update step-count. Write rolloutSteps(totalPods) that returns the number of individual "start new, kill old" steps needed to fully replace totalPods pods one at a time (a simple one-by-one rolling strategy).

Example: rolloutSteps(4) → 4 (each of the 4 pods gets replaced individually)

Real-world case study: Pokémon GO's launch-day crush 🔍

When Pokémon GO launched in 2016, demand exploded far beyond anyone's forecasts — reportedly 50x the traffic the team had planned for, arriving within days. The game's backend ran on Google's cloud infrastructure with container orchestration handling the workload, and the team has since spoken publicly about how that architecture was the only reason the service survived launch week at all: instead of provisioning fixed servers sized for an estimate, the orchestration layer could keep adding capacity as real traffic demanded it.

A launch of that scale on traditional, manually-provisioned servers would have meant an outright outage lasting days while engineers scrambled to rack up more hardware. This is the exact promise of Kubernetes-style orchestration you learned in this lesson: you declare "keep enough healthy pods running to serve demand," and the system keeps making that true — even when demand is 50 times higher than anyone predicted.

Quick quiz

Question 1 of 5

What does Kubernetes do?

Question 2 of 5

What is Kubernetes' 'desired state' model?

Question 3 of 5

A pod crashes at night. What does K8s do?

Question 4 of 5

What is the purpose of a rolling update?

Question 5 of 5

What's the difference between a liveness probe and a readiness probe?

Summary

  • Kubernetes orchestrates hundreds of containers across a cluster
  • Pods run on nodes; you declare desired state and K8s enforces it
  • Self-healing, auto-scaling, rolling updates, load balancing come for free
  • Rolling updates deploy new versions gradually with zero downtime; liveness/readiness probes are what make self-healing and rollouts actually safe
  • Powerful but complex — worth it at scale, overkill for small apps
  • Pokémon GO's 2016 launch (50x expected traffic) shows why declarative, self-scaling orchestration matters at real-world scale

Next: Infrastructure as Code — declaring not just containers but entire environments.

Practice

Reading is not learning until you run something. Pick one.

Open an example in Code Lab