What it is
Kubernetes is an open-source system that runs containers across a cluster of machines. You describe what should run (a container image, how many copies, how to reach them, what resources they need) as objects stored through an API, and Kubernetes keeps the cluster matching that description: it places containers on machines, restarts them when they crash, replaces them when machines fail and routes traffic to the healthy ones.
Why it exists
With more than a handful of hosts and services, placing containers by hand, restarting them, rolling out new versions and keeping load balancers up to date becomes error-prone toil. Kubernetes turns those jobs into control loops that run continuously, and gives every team the same API for deploying, scaling and exposing services, whichever cloud or data centre the cluster runs in.
How it works
Control plane. The API server is the only entry point: it authenticates, authorises and validates every request and stores objects in etcd, a consistent key-value store that uses the Raft consensus protocol. The scheduler watches for pods without a node and binds each to a node that has enough requested CPU and memory, respects constraints (affinity, taints, topology spread) and scores best. The controller manager runs controllers: the Deployment controller manages ReplicaSets, the ReplicaSet controller keeps N pods, the node lifecycle controller watches node heartbeats, and so on. All of them watch and update objects through the API server; none talks to etcd directly.
Nodes. Each worker node runs the kubelet, which watches for pods bound to its node, asks the container runtime (containerd, CRI-O) to start them, runs their probes and reports status. A network proxy (kube-proxy with iptables, IPVS or nftables rules, or an eBPF data plane such as Cilium) implements Services on every node.
Objects.
- A Pod is one or more containers that share a network namespace and volumes, scheduled together on one node. Pods are disposable; each new one gets a new IP.
- A Deployment declares a pod template and a replica count; it manages ReplicaSets and performs rolling updates between them.
- A Service gives a set of pods (selected by labels) a stable DNS name and virtual IP. Its EndpointSlices list only pods whose Ready condition is true.
Probes. A readiness probe decides whether a pod receives traffic: while it fails, the pod is removed from endpoints, nothing else happens. A liveness probe decides whether a container is stuck: when it fails, the kubelet restarts the container. A startup probe holds off the other two while a slow app starts.
Healing. If a container exits, the kubelet restarts it in the same pod, with exponential back-off for repeated crashes (CrashLoopBackOff). If a node stops sending heartbeats, the node lifecycle controller marks it NotReady after a grace period (tens of seconds by default), its pods are marked not ready and removed from endpoints, and after a toleration period (five minutes by default) they are evicted; the owning ReplicaSet then creates replacements, which the scheduler places on other nodes.
When to use it
- Many services, teams or environments that benefit from one deployment and operations model.
- Workloads that scale horizontally and must survive machine failures without manual work.
- Platforms where you want declarative, reviewable infrastructure (GitOps) and a large ecosystem of tooling.
When not to
- A few services that a managed container platform, a PaaS or serverless functions run with far less to operate.
- Teams without the capacity to run (or pay for) a cluster and learn its failure modes.
- Latency-critical or specialised workloads that need tight control over hardware, unless you invest in tuning.
Trade-offs
| Choice | You gain | You pay |
|---|---|---|
| Kubernetes instead of VMs and scripts | Automated placement, healing, rollouts, one API | Operational complexity, many moving parts to learn |
| Managed control plane (EKS, GKE, AKS) | No etcd or API servers to run | Cost, provider-specific add-ons and upgrade cadence |
| Readiness probes | No traffic to pods that cannot serve | A badly designed probe can remove every pod at once |
| Liveness probes | Recover from deadlocks automatically | Restart loops if the probe is too strict or too slow |
| Many small pods | Fine-grained scaling, small blast radius | More scheduling, networking and per-pod overhead |
Alternatives
- Managed container services (Cloud Run, ECS/Fargate, Azure Container Apps): run containers without managing a cluster.
- Serverless functions: event-driven code without containers or nodes to size.
- Nomad or plain VMs with autoscaling groups: simpler schedulers or no scheduler at all.
- PaaS (Heroku-style platforms): push code, the platform builds and runs it.
Failure modes
- No readiness probe: pods join the Service while still starting and fail requests on every rollout and scale-out.
- Liveness probe on a dependency: a database blip makes every pod's liveness fail and the kubelet restarts all of them.
- Slow node failure detection: traffic keeps reaching dead pods until the node is marked NotReady.
- No spare capacity: replacement pods stay Pending because no node has room for their requests.
- All replicas on one node or zone: one failure takes the whole service down; use topology spread or anti-affinity.
- Control plane outage: running pods keep running, but nothing can be scheduled, scaled or healed until it is back.
In production
Use a managed control plane or run several API servers with a three- or five-member etcd. Spread replicas across nodes and zones, set resource requests from measurements, and keep enough headroom to absorb a node loss. Add readiness probes that check what the pod itself needs, liveness probes only for real deadlocks, and PodDisruptionBudgets so maintenance does not drain too many pods at once. Watch pending pods, restart counts, node conditions and Service endpoint counts.
Common misconceptions
- "
kubectl applydeploys my app." It stores desired state; the rollout happens afterwards and can fail. - "A crashed pod moves to another node." Its containers are restarted in place; only node loss or eviction leads to new pods elsewhere.
- "Readiness failures restart my container." Readiness only removes the pod from endpoints; liveness restarts.
- "Kubernetes makes my service highly available." Only if there are enough replicas, spread over failure domains, with capacity to spare.
Interview angle
Draw the control loop: API server and etcd hold desired state, controllers and the scheduler converge, kubelets act on nodes. Explain how a Service finds pods (labels, endpoints, Ready condition) and the difference between readiness and liveness. Walk through a node failure: detection, eviction, rescheduling and what users see meanwhile, then size the cluster for N+1 nodes. Mentioning that only the API server talks to etcd, and that apply is asynchronous, shows real understanding.
Model assumptions
This lesson uses a simplified model, not a benchmark. Pods are simulated servers with 4 workers and a 50 ms mean service time (lognormal, cv 0.35), about 80 req/s each; traffic is Poisson. The Service picks a ready pod at random. Its health check stands for readiness probes plus the endpoint update: every 250 ms, 2 failures remove a pod, 2 successes add it. The control plane (API server, etcd, scheduler, controllers, kubelets) is a scripted illustration: its messages are scripted packets, not simulated watches. A pod appears in the scene when its Pod object is created and stays offline until its container starts; evicted pods disappear. Pod starts, crashes, restarts, node loss and eviction are timed actions on a compressed timeline; real detection and eviction take tens of seconds to minutes. Utilisation is the fraction of busy workers.