Skip to content

Part 4 · Orchestration with Kubernetes

In Part 3 we learned that a container is just a process with a private view of the system. Running one is easy: docker run myapp and you’re done. The trouble starts when you have many. A real service is dozens of containers, spread across many machines, that must survive crashes, survive whole-machine failures, scale up under load, scale down to save money, get new versions without downtime, and find each other on the network as their addresses churn. Do that by hand and you are writing a pile of fragile, error-prone shell scripts — the exact toil this book exists to remove.

Orchestration is the layer that automates all of it. Kubernetes (often “K8s”) is the orchestrator that won. This Part builds it up from first principles, and the recurring thread runs right through the heart of it: what manual, error-prone step does Kubernetes remove — and how does it make production safer? The answer, page after page, is the same shape: you stop telling a machine what to do step by step, and start telling the cluster what you want to be true. A program then works tirelessly to make reality match that wish — and to keep it matching, forever.

Kubernetes has a reputation for being overwhelming. It is — if you learn it as a bag of kubectl commands to memorize. It is not, once you grasp the single idea underneath: the reconciliation loop. Almost everything in Kubernetes is a controller watching desired state, comparing it to actual state, and nudging actual toward desired. Learn that one pattern and the rest of the system stops being a list of features and becomes obvious variations on a theme.

So we go why before how. We will not paste a manifest until you understand the problem it solves.

WITHOUT orchestration WITH Kubernetes
┌────────────────────┐ ┌────────────────────────────┐
│ you, at 3am: │ │ you declare desired state: │
│ • ssh to box │ │ "I want 4 healthy replicas"│
│ • restart crashed │ ──► │ a controller, 24/7: │
│ container │ │ • notices a crash │
│ • move it off a │ │ • reschedules the pod │
│ dead node │ │ • keeps the count at 4 │
│ • update LB by hand │ │ • updates routing for you │
└────────────────────┘ └────────────────────────────┘
manual, ad-hoc declared, self-healing

This Part is ten pages. Read them in order — each builds on the last.

  1. Why Orchestration — the problems at scale (scheduling, healing, scaling, rollouts, networking) you’d otherwise script by hand, and what Kubernetes automates instead.
  2. Kubernetes Architecture — the control plane (API server, etcd, scheduler, controller-manager) and the worker nodes (kubelet, kube-proxy, runtime). The declarative API and desired state stored in etcd.
  3. Pods & Workloads — why a Pod, not a container, is the unit; ReplicaSets, Deployments (rollouts and rollbacks), DaemonSets, Jobs and CronJobs.
  4. The Reconciliation Loop — the single most important idea in Kubernetes, and why once you see it you see it everywhere.
  5. Services & Networking — the pod-IP churn problem, Service types (ClusterIP, NodePort, LoadBalancer), kube-proxy, cluster DNS, and a word on CNI.
  6. Ingress & Controllers — getting HTTP traffic from the outside world to the right Service, host/path routing, and TLS termination.
  7. Config & Secrets — separating configuration from images with ConfigMaps and Secrets, so one image runs unchanged across every environment.
  8. Storage & Stateful Workloads — PersistentVolumes, claims, StorageClasses, and StatefulSets for databases and anything that remembers.
  9. Scaling & Scheduling — requests and limits, the scheduler’s decisions, the Horizontal Pod Autoscaler, taints, tolerations, and affinity.
  10. Helm & Packaging — templating and versioning whole applications so a release is one reviewable, repeatable command.

Resist the urge to memorize commands. For every page, answer the recurring question in your own words: what would I be doing by hand if Kubernetes weren’t here? If you can answer that, you understand the feature — the YAML is just how you ask for it. Then do the Check your understanding questions before moving on. Depth over speed; this is the part of the book worth slowing down for.

  1. Running one container is easy. Name three things that get hard once you have many containers across many machines.
  2. What is the one core idea that, once understood, makes the rest of Kubernetes feel like variations on a theme?
  3. In one sentence, restate the shift orchestration asks of you: from telling a machine what to do to telling the cluster what?
  4. Using the book’s recurring thread, give one concrete “3am manual step” that a Kubernetes controller removes — and say how that makes production safer.
  5. Why does this Part insist on why before how? What goes wrong if you learn Kubernetes purely as a list of kubectl commands?
Show answers
  1. Any three of: scheduling (which machine has room?), healing (restart crashed containers and reschedule off dead nodes), scaling up under load and down to save money, rollouts of new versions without downtime, and networking/service discovery as ephemeral containers’ IPs churn.
  2. The reconciliation loop — controllers continuously watching desired state, comparing it to actual state, and nudging actual toward desired. Once you see it, every other feature is just another controller.
  3. From telling a machine what to do step by step, to telling the cluster what you want to be true — and letting a controller keep reality matching that wish forever.
  4. For example: a controller notices a crashed Pod (or a whole dead node) and reschedules it to keep the replica count at 4, without anyone SSHing in at 3am. It’s safer because the routine recovery happens the same correct way every time, by software that doesn’t get tired, distracted, or skip a step under pressure.
  5. Because Kubernetes is overwhelming as a bag of commands to memorize but obvious once you grasp the single idea underneath. Learn it as commands and the system stays a list of disconnected features; learn the reconciliation loop first and the rest collapses into variations on one theme.