Back to articles
KubernetesVideo companion22 Nov 2026

What really happens when you run kubectl apply

One command passes through six components — kubectl, the API server, etcd, controllers, the scheduler and the kubelet — and the same watch loops heal the cluster when a node dies at 3 a.m.

#kubernetes#devops#cloud-native#sre

Watch the video

More on the channel
Kubernetes Control Plane Explained Simply: API Server, etcd, Scheduler, Kubelet

You type one command: kubectl apply. A few seconds later, three pods are running on machines you never touched.

So who decided where they run? Who actually started them? And when one dies at three in the morning, who brings it back?

It isn't magic. It's a small team of components, each doing exactly one job. This article follows a single Deployment through all of them — the same journey as the video above, with the commands and details that don't fit on screen.

The cluster as a company

Think of a Kubernetes cluster as a company.

  • The control plane is head office. It makes every decision, but it never runs your app.
  • The worker nodes are the factory floor, where your containers actually run.

Head office has four key people, and every node has a supervisor:

Role in the companyComponentIts one job
Receptionkube-apiserverThe only way in. Checks every request and records it.
Records roometcdStores the cluster's entire state.
Assigns the workkube-schedulerPicks a node for every pod that has none.
Checks reality matches the plankube-controller-managerRuns the loops that close the gap between desired and actual state.
Floor supervisor (on every node)kubeletActually starts the containers and reports back.

Here is the whole journey at a glance. Keep it in mind; every section below zooms into one link.

  1. kubectlTurns your YAML into one HTTPS request
  2. API serverAuthentication → authorization (RBAC) → admission, then validates and saves
  3. etcdStores the Deployment — the cluster's single source of truth
  4. ControllersDeployment → ReplicaSet → three Pod objects (desired 3, actual 0)
  5. SchedulerFilters and scores nodes, then writes nodeName onto each pod
  6. KubeletAsks containerd to pull and start the container, then reports Running

1. kubectl starts nothing

It all starts with you. You write a Deployment — three replicas of an nginx container:

yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: web
spec:
  replicas: 3
  selector:
    matchLabels:
      app: web
  template:
    metadata:
      labels:
        app: web
    spec:
      containers:
        - name: nginx
          image: nginx:1.27

Here's the first surprise: kubectl doesn't start anything. It turns your YAML into an HTTPS request and sends it to exactly one place — the API server. You can watch it happen:

terminal
$ kubectl apply -f web.yaml -v=6
I1122 10:04:12 loader.go:395] Config loaded from file: /home/you/.kube/config
I1122 10:04:12 round_trippers.go:553] GET https://10.0.0.10:6443/apis/apps/v1/namespaces/default/deployments/web 404 Not Found in 9 milliseconds
I1122 10:04:12 round_trippers.go:553] POST https://10.0.0.10:6443/apis/apps/v1/namespaces/default/deployments 201 Created in 21 milliseconds
deployment.apps/web created

A GET to see whether the object exists, then a POST to create it. That's all kubectl ever does.

2. The API server: three checks, then save

The API server is the front door of the cluster, and it's the only component that talks to etcd directly. Every other component — the scheduler, the controllers, every kubelet — goes through it.

Every request passes three checks:

  1. Authentication — who are you?
  2. Authorization — are you allowed to do this? Usually decided by RBAC.
  3. Admission control — does the request follow the cluster's policies, and does it need defaults added?

Only after all three does the API server validate the object and save it.

[!NOTE] The precise order is authentication → authorization → mutating admission → schema validation → validating admission → write to etcd. Mutating webhooks can change your object (for example, inject a sidecar); validating webhooks can only accept or reject it.

You can ask the authorization layer the same question it asks itself:

terminal
$ kubectl auth can-i create deployments --namespace default
yes
$ kubectl auth can-i delete nodes --as system:serviceaccount:default:ci-bot
no

3. etcd: the cluster's memory

The API server saves your Deployment in etcd: a consistent, distributed key-value store and the cluster's single source of truth. Every Deployment, Pod, Secret and node status lives here.

etcd usually runs as three or five members and uses the Raft consensus protocol, so a majority must agree before anything is written — two of three, or three of five. That's why you never run an even number: four members tolerate one failure, exactly like three.

Lose etcd without a backup, and you've lost the cluster's memory. That's why snapshots matter:

terminal
$ ETCDCTL_API=3 etcdctl snapshot save /backup/etcd-$(date +%F).db --endpoints=https://127.0.0.1:2379 --cacert=/etc/kubernetes/pki/etcd/ca.crt --cert=/etc/kubernetes/pki/etcd/server.crt --key=/etc/kubernetes/pki/etcd/server.key
Snapshot saved at /backup/etcd-2026-11-22.db
$ etcdutl snapshot status /backup/etcd-2026-11-22.db --write-out=table
+----------+----------+------------+------------+
|   HASH   | REVISION | TOTAL KEYS | TOTAL SIZE |
+----------+----------+------------+------------+
| 3f1c9a2e |   184212 |       1407 |     6.1 MB |
+----------+----------+------------+------------+

[!TIP] A snapshot you have never restored is a hope, not a backup. Practise etcdutl snapshot restore on a throwaway cluster before you need it.

4. Controllers: desired state vs actual state

Notice something: so far, nothing is running. Your Deployment is just a record in etcd.

This is where controllers come in. The controller manager runs many small loops that watch the API server:

  • The Deployment controller sees your new Deployment and creates a ReplicaSet.
  • The ReplicaSet controller sees that it wants three pods, counts zero, and creates three Pod objects.

Desired state: three. Actual state: zero. Close the gap. Every controller in Kubernetes is a variation on that one sentence.

terminal
$ kubectl get deploy,rs,pods -l app=web
NAME                  READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/web   0/3     3            0           2s

NAME                             DESIRED   CURRENT   READY   AGE
replicaset.apps/web-7c9d8f6b4d   3         3         0       2s

NAME                       READY   STATUS    RESTARTS   AGE
pod/web-7c9d8f6b4d-2xkqp   0/1     Pending   0          2s
pod/web-7c9d8f6b4d-8hvnm   0/1     Pending   0          2s
pod/web-7c9d8f6b4d-tq4lz   0/1     Pending   0          2s

Three pods exist — and all three are Pending, because none of them has a node yet.

5. The scheduler: filter, score, bind

The scheduler watches for exactly that: pods without a node. For each one it runs two phases:

  1. Filter out nodes that can't run the pod: not enough CPU or memory, a taint the pod doesn't tolerate, or a node selector that doesn't match.
  2. Score the nodes that are left, and pick the best one.

And the scheduler doesn't start anything either. It simply writes the chosen node's name onto the pod — spec.nodeName — through the API server. That write is called a binding.

When a pod stays Pending, the scheduler tells you why in the pod's events:

terminal
$ kubectl describe pod web-7c9d8f6b4d-tq4lz | tail -4
Events:
  Type     Reason            Age   From               Message
  ----     ------            ----  ----               -------
  Warning  FailedScheduling  12s   default-scheduler  0/6 nodes are available: 3 Insufficient memory, 3 node(s) had untolerated taint {dedicated: gpu}.

6. The kubelet makes it real

On the chosen node, the kubelet is watching for pods assigned to it. It sees the new pod and asks the container runtime — usually containerd, through the CRI — to pull the image and start the container. It sets up networking and storage, starts the health probes, and reports back to the API server: Running.

Three pods, on three nodes, and you only typed one command:

terminal
$ kubectl get pods -l app=web -o wide
NAME                   READY   STATUS    RESTARTS   AGE   IP            NODE
web-7c9d8f6b4d-2xkqp   1/1     Running   0          41s   10.244.1.12   node-1
web-7c9d8f6b4d-8hvnm   1/1     Running   0          41s   10.244.2.9    node-2
web-7c9d8f6b4d-tq4lz   1/1     Running   0          41s   10.244.3.17   node-3

7. Self-healing at 3 a.m.

Now the best part. At three a.m., node-3 crashes and takes one of your pods with it.

  1. Heartbeats stopThe kubelet on node-3 stops reporting, so the node is marked NotReady
  2. Pods evictedAfter a timeout (300 seconds by default), its pods are evicted
  3. ReplicaSet recountsDesired 3, actual 2 — so it creates one new Pod object
  4. Scheduler places itFilters out node-3 and binds the pod to a healthy node
  5. Kubelet starts itThe new node's kubelet pulls the image and reports Running

Nobody woke up. That's the whole secret of Kubernetes: every component is a watch loop, comparing desired state with actual state.

The one question to ask when something breaks

Remember the chain: kubectl talks to the API server; the API server writes to etcd; controllers create the pods; the scheduler picks a node; the kubelet runs them. When something breaks, ask which link stopped:

SymptomThe link that stoppedFirst command
kubectl errors, Forbidden, timeoutsAPI server, authentication or RBACkubectl auth can-i …
Pod stuck PendingScheduler (resources, taints, selectors)kubectl describe pod <pod>
Pod stuck ContainerCreatingKubelet, runtime or image pullkubectl get events --sort-by=.lastTimestamp
Pods not recreated after a failureController managerkubectl get rs and the controller-manager logs

[!IMPORTANT] The names here — web, node-1 to node-6, the pod hashes and 10.244.3.17 — are illustrative. Your cluster's output will differ in detail, not in shape.

Which control plane component failed first in your cluster? Tell me in the comments on the video.