Kubernetes architecture, one component at a time
Kubernetes is one API, a database behind it, and loops that watch it. What the API server, etcd, the scheduler, the controller manager, the kubelet and kube-proxy each do, what breaks when each one stops, and how to find the loop that is behind.
ON THIS PAGE
Kubernetes is one API with a database behind it, and a handful of loops that watch it. The API server is the only component that touches etcd; the scheduler, the controllers and every kubelet read what they care about from the API server and write their results back to it, and none of them talks to another directly. Learn it that way and the useful question during an outage stops being "what is broken?" and becomes "which loop has stopped answering?", which the cluster's own objects will tell you.
Based on the article from Gazeek, our sister site for hands-on CKA and CKAD labs: Draw a Kubernetes architecture diagram in minutes, with archhy. It walks through drawing the cluster from archhy's Kubernetes sample and adding the path a request takes through an Ingress and a Service.
One API, many loops#
Every component except etcd is a client. Each one opens a watch on the objects it is responsible for, compares what it sees with what should be true, does something about the difference, and records the outcome as an update through the API. That is a control loop, and it is the whole design. There is no message from the scheduler to the kubelet, and no call from a Deployment to a node. There are only objects changing, and other loops noticing.
That is why the cluster survives so much partial failure. A loop that stops leaves its objects where they were; it does not take the others with it.
Who writes what#
- kube-apiserver serves the HTTP API, checks who you are and what you may do, validates the object and stores it.
- etcd is the key-value store holding all of that state. Lose it without a backup and the cluster forgets everything it was asked to run.
- kube-scheduler looks for Pods with no node, picks one, and writes the choice into the Pod. It never starts anything.
- kube-controller-manager runs the built-in controllers. The ReplicaSet controller creates Pods when there are too few; the node controller notices nodes that stop reporting.
- cloud-controller-manager, when there is one, turns objects into cloud resources: a load balancer for a Service of type LoadBalancer, addresses for nodes.
- kubelet, on every node, watches for Pods assigned to its node, asks the container runtime to run them over the CRI, and reports their status back.
- kube-proxy watches Services and their endpoints and programs each node's packet rules. Some network plugins do this job themselves, and then the cluster runs without it.
What breaks when each one stops#
Each loop owns one kind of change, so each failure has its own signature:
- The API server stops:
kubectlcannot connect and nothing new can happen. Running Pods carry on serving traffic; the kubelets keep the containers they already know about. - The scheduler stops: new Pods stay Pending with no node, forever. Everything already placed is fine.
- The controller manager stops: you can create a Deployment and nothing happens. A crashed node's Pods are never replaced, and a rollout never progresses.
- A kubelet stops: after a grace period the node controller marks the node's Ready condition Unknown, which
kubectlshows as NotReady. By default its Pods are evicted five minutes later, and controllers recreate them elsewhere. - kube-proxy stops: the rules it already wrote stay in the kernel, so traffic still flows, but Service changes no longer reach that node. It shows up later, as a node that sends traffic to Pods that have gone.
The pattern to keep: a broken control plane freezes change, not traffic. Good for availability, bad for diagnosis: a cluster can look healthy for hours after a loop has died.
Debugging by asking which loop is behind#
Read a stuck object as a request nobody has answered yet, and find the field that should have changed. No nodeName on a Pending Pod points at the scheduler or at what it is waiting for. A node name but no running container points at that node's kubelet or runtime. A Deployment whose ReplicaSet never appears points at the controller manager.
kubectl get pod web-1 -o jsonpath='{.spec.nodeName}'
kubectl get events --field-selector involvedObject.name=web-1
sudo ls /etc/kubernetes/manifests
sudo crictl ps --name kube-apiserverThe last two matter when kubectl itself is down. On a kubeadm cluster the control plane runs as static Pods: the kubelet starts them from files in that folder, without the API server. A typo in one of those manifests is a classic exam fault, and the way in is crictl and the kubelet's logs on the control plane node. Gazeek's cluster troubleshooting module breaks real clusters in exactly these ways. Backing up the one component that holds state is its own subject: see etcd backup and restore.
The same reading works for your own apps. In WordPress on Kubernetes, a claim stuck in Pending is a storage loop with nothing to answer it; in blue/green with a Service selector, the endpoints follow the label you change, because a controller is watching it.
The diagram#
The picture shows a control plane and two compute (worker) nodes, with the scheduler, controller manager and kubelets watching the API server, and notes on what breaks when each part stops. Open it in archhy and make a copy to draw your own cluster.
Go deeper#
Gazeek's full article starts from archhy's Kubernetes sample, reads the control plane and the nodes, and adds an Ingress and a Service with the official icons.
