Sunday, November 29, 2026

What Happens Inside Kubernetes When You Run kubectl apply

Source: This post is an attributed summary of The DevOps Traveller's Instagram reel “How kubectl create works” (Nov 28, 2026). The summary below is written in my own words. The reel itself is embedded below — the animation is the original, hosted on Instagram, not a re-upload.

View this post on Instagram

The one command that hides ten steps

You type kubectl apply and two seconds later your app is running. Behind that one command, ten things happen across the control plane and the worker nodes. The reel walks through them with a sample AKS cluster (aks-myshop:443) and a user named Priya deploying my-app:v2. (The caption condenses the flow to six steps; the animation shows all ten.)

The ten steps

1. kubectl reads your kubeconfig. The ~/.kube/config file tells kubectl which cluster to talk to, as what user, and with which credentials.

2. kubectl calls the API server. Over HTTPS, it sends POST /apis/apps/v1/namespaces/default/deployments. The kube-apiserver is the only door into the cluster — every request goes through it.

3. Authentication — who are you? The API server verifies identity, here with a client certificate signed by the cluster CA (user: priya).

4. Authorization — are you allowed? RBAC checks whether priya, holding the developer Role, can CREATE deployments in the default namespace. If not, the request stops here with Forbidden.

5. Admission — is the request valid? Admission controllers validate the rules (the image comes from a registry, the namespace exists) and fill in defaults — in the example, CPU 100m and memory 128Mi.

6. etcd saves the Deployment. The desired state is persisted. Pods running: 0. Nothing runs yet — etcd holds the intent, not the workload.

7. Controllers react. The Deployment controller sees the new Deployment and creates a ReplicaSet; the ReplicaSet creates 3 Pods, all pending.

8. The scheduler places the Pods. It watches for unscheduled Pods, filters out nodes that don't fit — node-3 is full, so it's skipped — and binds the Pods to node-1 and node-2 based on free CPU and memory.

9. The kubelet starts the containers. The kubelet on each node asks containerd to pull the image (myshopcr/my-app:v2) and start the container, then reports the Pod as Running with its IP. This is the step where ImagePullBackOff and CrashLoopBackOff live.

10. kube-proxy and readiness open the traffic. kube-proxy writes the routing rules, and once the readiness probes pass, the Service my-app starts sending user traffic to the 3 Ready Pods. Final screen: “Your app is live — 3/3 Ready.”

Where your app gets stuck (and which step that is)

The reel ends by asking where your app got stuck last time. Each symptom points at a step:

  • Forbidden right after the command — step 4, RBAC.
  • Request rejected for a bad image or missing namespace — step 5, admission.
  • ImagePullBackOff — step 9, the image can't be pulled (wrong tag, private registry, bad credentials).
  • CrashLoopBackOff — step 9, the container starts and immediately crashes.
  • Pod Running but never Ready, and no traffic arrives — step 10, the readiness probe is failing, so the Service sends nothing.

That mapping is why this flow is an interview staple: it's also the debugging map you use on a real cluster.

Sources

No comments: