Control plane
Deploy an app
kubectl apply → Pod Running
What happens between typing kubectl apply and your app answering requests. Ten components touch one Deployment, and almost none of them talk to each other directly: every one of them reads and writes through the API server.
- Command
- kubectl apply -f web.yaml
- Objects
- Deployment, ReplicaSet, Pod, Binding, EndpointSlice
- Components
- kubectl, API server, etcd, controllers, scheduler, kubelet, containerd, CNI
- Time to ready
- ≈ 4.2 s, most of it pulling the image
Read the whole lesson as text
1. Send the manifest
kubectl reads web.yaml, turns it into JSON and asks the API server whether a Deployment called web already exists. The answer is 404, so it sends a create request. kubectl never talks to nodes or etcd; the API server is the only door.
- kubectl asks the API server whether a Deployment called web already exists. It doesn't.
- So kubectl sends the whole Deployment, as JSON, and asks the API server to create it.
2. Gatekeeping
Before anything is stored, the API server runs the request through a fixed pipeline. Authentication works out who you are, authorization (RBAC) decides whether you may create Deployments in this namespace, and admission plugins get a chance to change or reject the object. Missing fields get their defaults on the way.
- The API server checks who is asking: your client certificate says you.
- Then it checks you're allowed to create Deployments here. RBAC says yes.
- It fills in the fields you left out with defaults, and admission checks the object.
3. Saved to etcd
The API server writes the Deployment to etcd, the cluster's only database, and answers kubectl with 201 Created. That's where kubectl stops. Nothing is running yet: etcd now holds a description of what you want, and the rest of the cluster has to notice it.
- The API server saves the Deployment in etcd. Nothing is running yet.
- kubectl gets 201 Created and exits. The rest happens without it.
4. Controllers react
Controllers hold long-lived watches on the API server, so they hear about the new Deployment within milliseconds. The Deployment controller creates a ReplicaSet for this version of the Pod template. The ReplicaSet controller sees it wants 3 Pods, finds 0, and creates 3. None of them has a node yet.
- The Deployment controller is watching, so it hears about the new Deployment at once.
- It creates a ReplicaSet: the thing that keeps a set number of identical Pods.
- The ReplicaSet controller hears about the new ReplicaSet. It wants 3 Pods and has 0.
- So it creates 3 Pods. They exist only as records: no node, nothing running.
5. Scheduling
The Pod exists, but nothing runs it yet: its spec.nodeName is empty. The scheduler watches every Pod and queues the ones with no node. It drops nodes that can't fit the Pod's CPU and memory requests, scores the rest, and writes its pick back to the API server as a Binding. The other two Pods go through the same loop and land on node-1 and node-2.
- The scheduler is watching every Pod. This one has no node, so it joins the queue.
- It picks node-2 and records that choice as a Binding. It never contacts node-2 itself.
6. kubelet starts it
Zoom into node-2. Its kubelet only watches Pods assigned to this node, so it sees this one right away. It asks containerd for a sandbox: a tiny pause container that owns the Pod's network namespace. The CNI plugin plugs that namespace into the cni0 bridge and gives it an IP. Then the image is pulled and the app container starts inside the sandbox.
- node-2's kubelet only watches Pods assigned to node-2. Now one is.
- The kubelet asks containerd for a sandbox: an empty home for the Pod.
- containerd calls the network plugin, which plugs the Pod into the bridge and gives it an IP.
- The kubelet asks for the app's image. Downloading 48 MB is the slow part.
- containerd creates the app's container inside the sandbox.
- And starts it. The app is now running.
- The kubelet tells the API server: Running, with IP 10.244.2.17.
7. Ready for traffic
Running isn't the same as ready. The kubelet calls the app's readiness probe, and only when it answers with a success code (200–399) does the Pod become Ready. The EndpointSlice controller sees that and adds 10.244.2.17:8080 to the web Service's endpoints. From now on, traffic for the Service can land here.
- The kubelet calls the app's health check. It answers 200: ready.
- The kubelet reports the Pod as Ready.
- The Pod's IP is added to the Service's list of endpoints. Traffic can now reach it.
Summary
One command became 23 events across ten components in about 4.2 seconds. Notice what never happened: kubectl never talked to a node, the scheduler never started a container, and the kubelet never wrote to etcd. Each component watched the API server and did one job.
Next lesson: A request finds your Pod