How Kubernetes works
You declare the desired state; the cluster relentlessly makes it real.
Kubernetes orchestrates containers across a cluster. The control plane — API server, etcd, scheduler and controller manager — accepts your desired state, stores it, places pods on nodes and continuously reconciles reality toward that state. Worker nodes run a kubelet, a container runtime and kube-proxy, hosting the pods that actually do the work.
Submit a manifest
You send a YAML manifest describing the desired state — say, a Deployment asking for 3 replicas of an app — to the API server with `kubectl apply`. You declare what you want to be true, not the steps to get there. The API server is the single front door: every human, controller, and node component talks to the cluster only through it.
Store in etcd
The API server authenticates and validates the request, then persists the desired state in etcd, a consistent key-value store that is the cluster's single source of truth. Nothing else writes to etcd directly; the API server guards it. Every other component watches this stored state and springs into action when it changes.
Schedule the pods
The scheduler watches for pods that have no node assigned, then picks a suitable worker for each by filtering on constraints (resource requests, node selectors, taints) and scoring the survivors. It doesn't start anything — it just records its choice by writing the node assignment back through the API server. Placement is a decision; execution happens elsewhere.
Reconcile
The controller manager runs a set of never-ending control loops that compare desired state against observed state and act to close the gap. If a Deployment wants 3 pods but only 2 exist, its controller creates a third; if a node dies, its pods are rescheduled. This reconciliation loop is the engine behind self-healing and scaling.
Running pods
On each chosen node, the kubelet sees the pods assigned to it and instructs the container runtime (containerd) to pull images and start the containers, then reports health back continuously. kube-proxy programs the node's networking so a stable Service IP load-balances across whichever pods are currently alive. The declared wish is now real, and the loops keep it that way.
Why orchestration exists at all
Containers solved packaging, but they created a new problem of scale. One container on one machine is easy. Now imagine hundreds of containers spread across dozens of servers: something has to decide which container runs on which machine, restart the ones that crash, replace the ones on a server that died, roll out a new version without downtime, scale up when traffic spikes, and give every container a stable way to find the others whose IP addresses keep changing.
Doing that by hand — SSH-ing into boxes, restarting processes, editing load-balancer configs — does not survive contact with production. It is error-prone, slow, and impossible at 3 a.m. when a node fails. This coordination job is called container orchestration, and Kubernetes is its de-facto standard.
The mental leap Kubernetes asks you to make is from imperative to declarative operations. You stop issuing commands like "start this container on that server." Instead you declare the desired end state — "I want 3 healthy replicas of version 2, reachable at this address" — and hand it to the cluster. The cluster's entire job is then to make reality match that declaration and to keep it matching, indefinitely, as machines and processes fail underneath it. You describe the destination; Kubernetes drives.
Declarative desired state and the reconciliation loop
The single idea that unlocks all of Kubernetes is the reconciliation loop. It is worth internalising because every controller in the system is a variation of it.
The loop runs forever and does three things: observe the current actual state, compare it to the declared desired state, and take action to reduce any difference. That's it. If you asked for 3 pods and 3 are running, it does nothing. If one crashes, the observed count drops to 2, the comparison finds a gap, and the loop creates a replacement. If you edit the manifest to ask for 5, the gap reappears and two more are created.
The perfect analogy is a thermostat. You set a target temperature (desired state). The thermostat continuously senses the room (actual state) and switches the heating on or off (action) to close the gap — not once, but forever. It handles disturbances (an open window, a cold night) automatically because it never stops looping.
This is why Kubernetes gives you self-healing for free. Nobody wrote special "restart on crash" logic; a crash simply becomes a gap the loop notices and closes. The same mechanism delivers scaling (change the desired replica count), rolling updates (change the desired image and let controllers converge gradually), and node-failure recovery (a dead node's pods become missing, so they get rescheduled elsewhere). One primitive, many powers.
The control plane: the brain of the cluster
The control plane is the set of components that make global decisions and hold the cluster's state. It usually runs on dedicated nodes and has four key parts:
- API server — the front door and the only component that talks to etcd. Every request, whether from
kubectl, a controller, or a kubelet, goes through it. It authenticates, authorises, validates, and then reads or writes state. Because everything funnels through one well-defined API, the system is uniform and extensible. - etcd — a consistent, distributed key-value store that is the single source of truth. Both your desired state and the last observed state live here. It uses the Raft consensus algorithm so the data stays correct even if some etcd members fail; lose etcd and you lose the cluster's memory, which is why it is backed up carefully.
- Scheduler — watches for pods with no assigned node and chooses one for each by filtering nodes against constraints (CPU/memory requests, taints, affinity) and scoring the rest. It only decides placement; it never starts containers.
- Controller manager — runs the reconciliation loops: the Deployment controller, ReplicaSet controller, node controller, and more. These are the loops that actually drive actual state toward desired state.
Notice the separation of concerns: the API server is the gatekeeper, etcd is the memory, the scheduler is the placer, and the controllers are the doers. Each is simple; the power is in their composition.
Worker nodes and the objects you actually deploy
The control plane decides; the worker nodes do the work. Each node runs three components:
- kubelet — the node's agent. It watches the API server for pods assigned to its node, tells the container runtime to run them, and reports their health back. It is the bridge between the control plane's intentions and real running containers.
- Container runtime — usually containerd. It pulls images and actually starts and stops containers, using the same Linux namespaces and cgroups that plain Docker uses.
- kube-proxy — programs the node's network rules so that a stable Service address load-balances across the live pods behind it.
On top of these run the objects you write manifests for:
- Pod — the smallest deployable unit: one or more tightly-coupled containers sharing a network namespace and storage. Pods are mortal and disposable; you rarely create them directly.
- Deployment — declares "keep N replicas of this pod template running" and manages rolling updates and rollbacks. This is what you usually apply.
- Service — a stable virtual IP and DNS name in front of a changing set of pods, solving the problem that pod IPs come and go. It is how pods find each other and how traffic enters reliably.
The layering is deliberate: Deployments manage ReplicaSets, ReplicaSets manage Pods, and Services provide a durable address over whichever pods currently exist.
Trade-offs, failure modes, and when it's worth it
Kubernetes is powerful, but power has a price, and being honest about it is part of using it well.
The dominant trade-off is complexity. Kubernetes has a steep learning curve, many moving parts, and a large operational surface — networking plugins, storage classes, RBAC, ingress controllers. Running a cluster yourself means operating etcd, upgrades, and certificates; most teams sensibly use a managed offering (EKS, GKE, AKS) to hand that off.
Common failure modes are worth recognising:
- etcd trouble. It is the memory of the cluster; if it is slow, unbacked-up, or loses quorum, the whole control plane suffers. Treat it as precious.
- Bad resource requests/limits. Set them too low and pods get OOM-killed or CPU-throttled; too high and the scheduler can't pack nodes and you waste money. Getting requests right is a real, ongoing tuning task.
- Missing health probes. Without liveness and readiness probes, Kubernetes can't tell a hung pod from a healthy one, so self-healing and safe rollouts silently degrade.
- Networking confusion. Service discovery, DNS, and ingress are where most beginner debugging time goes.
So when is it worth it? Kubernetes pays off when you run many services at real scale, need self-healing and zero-downtime deploys, and have the team to operate it. For a single small app, a simpler platform (a managed container service or a PaaS) is often the wiser choice — the orchestration overhead only earns its keep once you genuinely have a fleet to orchestrate. Used in the right place, though, it turns a pile of fragile servers into a system that heals and scales itself while you sleep.
The API server is the cluster's front door — every command and component goes through it.
etcd is the single source of truth, a consistent key-value store holding the cluster's desired and observed state.
The scheduler decides which node each new pod runs on, based on resources and constraints.
The controller manager runs reconciliation loops that compare desired vs actual and drive them together.
Each worker node runs a kubelet (starts pods), a container runtime (runs containers) and kube-proxy (networking).
Quick quiz
What is etcd's role in the control plane?
What does 'reconciliation' mean in Kubernetes?
How Docker works
Package an app and everything it needs into one portable, isolated unit.
CI/CD pipeline explained
Turn every commit into a tested, shippable, deployable artifact — automatically.
A crash course on scalability
How one box on a laptop becomes a system that serves millions.