Unit 5 · Distributed & cloud · Lesson 9 of 14
Kubernetes and container orchestration
Step 1: Learn the ideas
- Containers versus VMs (recap)
- Control-plane and node components
- Declarative API objects: spec and status
- Controllers and reconciliation loops
- Pods, ReplicaSets and Deployments; rolling updates
- Services, endpoints and kube-proxy
- Scheduling: filtering, scoring, affinity, taints and tolerations
- Requests, limits and QoS classes
- CPU throttling and OOM kills
- Liveness, readiness and startup probes
- Horizontal Pod Autoscaler basics
- Eviction, priority and PodDisruptionBudgets
Why it matters
Many cloud services you will build or operate run on Kubernetes or something shaped like it. Command syntax matters far less than understanding the control loops underneath well enough to predict what happens when a probe is wrong, a limit is too tight or a node disappears. For cloud and SRE roles, this is where design meets operations.
Core ideas
Containers and VMs (recap). A container is a group of processes isolated by kernel namespaces and limited by cgroups, sharing the host kernel; a VM runs its own kernel on virtualized hardware, isolating more strongly at higher cost. Kubernetes schedules containers grouped into pods, which share a network identity and can share volumes.
Architecture. The API server is the only component that talks to etcd, the consistent store holding every object. The scheduler assigns pending pods to nodes. Controllers, mostly bundled in the controller manager, watch objects and act to close the gap between desired and observed state. On each node the kubelet starts containers through the container runtime and reports status, while kube-proxy (or a network plugin that replaces it) programs service routing.
Reconciliation. Each object has a spec (what you want) and a status (what exists). A controller repeatedly compares them and takes one step toward the spec. It is level-triggered: it reacts to the current state, not to the sequence of events, so a missed notification or a controller restart is harmless. Deployments create ReplicaSets, ReplicaSets create pods, and each layer is just another controller. Infrastructure as code rests on the same desired-state idea.
Scheduling uses requests, not usage. The scheduler filters nodes that can fit a pod's requests and satisfy its constraints (node selectors, affinity, taints and tolerations), then scores the remainder. A node can be full by requests while nearly idle by usage.
Limits are enforced differently per resource. A container that uses up its CPU limit is throttled: it is paused until the kernel's next CPU bandwidth period begins, which shows up as latency spikes rather than errors. A container that exceeds its memory limit is OOM-killed and restarted under its restart policy. QoS classes follow from requests and limits: Guaranteed (every container has equal CPU and memory requests and limits), Burstable (some requests or limits) and BestEffort (none). Under node memory pressure, BestEffort pods are evicted first, then Burstable pods using more than they requested.
Probes have distinct jobs.
- Liveness: restart the container when it is stuck. Check only the process itself; a liveness probe that calls a database restarts every replica when the database is slow, turning a dependency problem into a full outage.
- Readiness: remove the pod from Service endpoints while it cannot serve (warming up, overloaded, draining). No restart.
- Startup: hold off the other probes until a slow-starting container is up, instead of inflating liveness delays.
Services and rollouts. A Service selects pods by label and routes to the ready ones behind a stable virtual IP and DNS name. A rolling update adds new pods and removes old ones within surge and unavailability bounds, gated on readiness, so a readiness probe that passes too early ships a broken version straight to traffic.
Autoscaling. The HPA periodically sets desired replicas to the current count times the ratio of the observed metric to its target, ignores small deviations and smooths scale-down over a stabilization window. CPU utilization is measured relative to requests, so wrong requests produce wrong scaling. It reacts over tens of seconds to minutes and cannot add capacity faster than new pods start and become ready, so it does not replace headroom or load shedding.
Common misconceptions
- "Limits protect my latency." A tight CPU limit throttles the service even on an idle node. One widely used approach is to set CPU requests carefully and keep CPU limits generous or absent for latency-sensitive services, while keeping memory limits.
- "Liveness and readiness are interchangeable." A liveness failure restarts the container; a readiness failure only removes it from load balancing. Dependency checks belong, if anywhere, in readiness.
- "Kubernetes schedules by actual usage." It schedules by requests; usage matters for throttling, eviction and autoscaling.
- "The HPA handles traffic spikes." It reacts after the fact and is bounded by pod start time; plan headroom and admission control.
- "Controllers process events in order." They reconcile current state and must be idempotent; ordering and missed events must not matter.
How to approach it
Read the components overview and the controllers page, then the resource-management, QoS and probe pages, and the HPA algorithm section. Then do the kind exercise: deploy a toy service with a liveness probe that checks a dependency, a CPU limit far below need and a memory limit below its working set, and observe events, restarts, throttling and endpoint changes. If your cloud coursework used Kubernetes, connect what you saw there to these mechanisms. Graduates should explain pods, deployments, services and probes. Mid-level candidates should debug misconfigurations and explain requests, limits and QoS. Senior candidates should discuss controllers, multi-tenancy, disruption budgets, autoscaling dynamics and cluster upgrades.
Suggested order
- 1Read the Kubernetes components overview and the Controllers page; draw the path from applying a Deployment manifest to running containers.
- 2Read the Pods, Deployments and Service pages, focusing on rolling updates and how readiness gates traffic.
- 3Read "Resource Management for Pods and Containers", the Pod QoS classes page and the node-pressure eviction page.
- 4Read "Configure Liveness, Readiness and Startup Probes" and the Builders' Library article on health checks; write the probe set for a slow-starting service with a database dependency.
- 5Read the algorithm section of the HPA page and reproduce one scaling decision by hand.
- 6Do the kind break-and-fix exercise, then optionally the HPA walkthrough; finish with "Borg, Omega, and Kubernetes" for the design rationale.
Step 2: Check off what you can do
Tap each one you can genuinely do or explain. Each earns 10 XP.
Step 3: Go deeper
Kubernetes components (official documentation)Start here
Kubernetes projectSection: Components overview, then the Controllers, Pods, Deployments, Service, Resource Management and Probes pages
Official description of the components and of the objects, controllers, resource rules and probes this topic covers.
Open(opens in a new tab)Link responded, 5 Oct 2026Kubernetes components (official documentation)
Kubernetes projectSection: Pod Quality of Service Classes (with the node-pressure eviction page)
How requests and limits map to QoS classes and how those classes decide eviction order under node pressure.
Open(opens in a new tab)Link responded, 5 Oct 2026Kubernetes components (official documentation)
Kubernetes projectSection: Horizontal Pod Autoscaling (algorithm details)
The autoscaling formula, utilization relative to requests, tolerance and stabilization windows.
Open(opens in a new tab)Link responded, 5 Oct 2026Implementing health checks
Amazon Builders' LibraryWhy deep health checks can take down a fleet and how to design probes that fail safely.
Open(opens in a new tab)Link responded, 5 Oct 2026Borg, Omega, and Kubernetes
Google ResearchDesign rationale for pods, labels, the uniform API and reconciling controllers.
Open(opens in a new tab)Link responded, 5 Oct 2026
Step 4: Practice
Create a kind or minikube cluster and deploy a toy HTTP service three times, each with one fault: a liveness probe that depends on an unavailable backend, a CPU limit far below the service's need, and a memory limit below its working set. For each, predict the symptom first, then confirm it with kubectl describe, events, restart counts, endpoint lists and the container's CPU throttling metrics. Fix each and note the production signal that would reveal it. Then follow the HorizontalPodAutoscaler walkthrough in the Kubernetes documentation on the same cluster (it needs a metrics server) and relate each scaling step to the formula.
- Break and fix a toy service on a local kind cluster (probes, requests, limits)Open(opens in a new tab)Not attemptedkind (Kubernetes SIGs)
Record attempts on each problem’s page (+15 XP, +10 more when solved on your own).
Step 5: Test yourself
Answer each one out loud or on paper before you finish the lesson.
- Question 1Why should a liveness probe not check downstream dependencies?
- Question 2A pod is Running but receives no traffic. What do you check?
- Question 3How can a node be "full" while its CPUs are mostly idle?
- Question 4What happens to a Burstable pod using more memory than it requested when the node runs low?
- Question 5Why does the HPA depend on correct CPU requests?
- Question 6What makes a controller safe to restart at any moment?
You’re done when you can
- Explain the reconciliation pattern and trace a Deployment rollout through its controllers without notes.
- Predict the symptom of three probe or resource misconfigurations and confirm them on a local cluster.
- Explain CPU throttling versus OOM kills and how QoS classes affect eviction in under three minutes.
- Compute an HPA scaling decision by hand from current replicas, observed utilization and target.
Finish the lesson
Unlocks next: Platform engineering, infrastructure as code and safe migrations, Resource scheduling, fairness, interference and cold starts, Elasticity, autoscaling and serverless cold starts


