Skip to Content

Kubernetes Field Guide · Chapter 2 of 16

Inside a cluster: the path of a kubectl apply

A cluster is a handful of components that never call each other directly. They all watch one API server and react. Learn who does what, follow a kubectl apply end to end, and find every piece in your own cluster.

  • 30 min
  • Beginner
  • Hands-on
  • Free

By , founding engineer running Kubernetes in production. Updated .

kubectlcontrol planedecidesAPI serveretcd (the database)schedulercontrollersworker-1kubelet + kube-proxypodpodpodworker-2kubelet + kube-proxypodpodworker-3kubelet + kube-proxypodpodpod
The chapter in one pictureEverything goes through the API server. Nodes do the work; the control plane decides.

By the end you can

0 of 4

Two halves: the control plane decides, the nodes run

Every cluster has two parts. The control plane stores the desired state and decides what should run where. The worker nodes are the machines that actually run your containers.

One rule explains most of the design: components never call each other directly. Each one watches the API server for changes it cares about, does its job and writes the result back. That is how a scheduler, a dozen controllers and hundreds of kubelets stay in step without knowing about each other.

Interactive

Cluster map

You

Control plane

Worker node-1

web-7d4f

Worker node-2

web-k2x9web-p8wq

Click a component, or press play

Two halves: the control plane decides, the nodes run.

Everything goes through the API server. Components never call each other directly: they watch the API server and react.

The control plane

  • kube-apiserver is the front door. kubectl, controllers, the scheduler and every kubelet talk only to it. Each request is authenticated, checked against RBAC, passed through admission controllers and validated.
  • etcd is a consistent key-value store holding every object in the cluster. Only the API server talks to it. Back it up: without etcd there is no cluster.
  • kube-scheduler picks a node for each new pod. It filters out nodes that cannot run it (not enough CPU or memory, taints, affinity rules), scores the rest and records its choice.
  • kube-controller-manager runs the control loops from chapter 1: Deployments, ReplicaSets, Nodes, Jobs and more, each reconciling desired with actual state.

On a cloud provider there is often a fifth, the cloud-controller-manager, which creates load balancers and attaches disks through the provider's API.

Worker nodes

  • kubelet is the agent on every node. It watches for pods bound to its node, starts their containers, runs health checks and reports status.
  • Container runtime, usually containerd, pulls images and runs containers. The kubelet talks to it through the Container Runtime Interface (CRI).
  • kube-proxy programs network rules so traffic sent to a Service reaches a healthy pod. Some network plugins, such as Cilium, replace it.

A network plugin (CNI) gives every pod its own IP address and lets pods on different nodes reach each other. kind uses one called kindnet.

What happens on kubectl apply

Nothing in Kubernetes calls anything else directly. Every component watches the API server and reacts to changes. Step through one kubectl apply and watch the work pass from component to component:

Step through it

One kubectl apply, from your laptop to a running container

  1. kubectlyour laptop
  2. API servercontrol plane
  3. etcdcontrol plane
  4. Controllerscontroller manager
  5. Schedulercontrol plane
  6. Kubeleton the node
  7. containerdon the node

Step 0 of 9

Press Play, or step through with Next.

Knowing that path turns error messages into directions:

SymptomSuspect first
kubectl says connection refused or UnauthorizedAPI server address or credentials in your kubeconfig
Pod stuck in Pending, no nodeScheduler: resources, taints, affinity
Pod stuck in ContainerCreatingKubelet on that node: volumes, network plugin, image pull
ErrImagePull or ImagePullBackOffRuntime and registry: image name, tag, credentials
Pods run but the Service gets no trafficService selector and labels, then kube-proxy

When a component stops

Knowing who does what pays off when something breaks. Each component has one job, so each failure has its own signature: some take out kubectl, some only stop new pods, some you would not notice for minutes. Stop one at a time and read what still works.

Interactive

Stop a component. What still works?

Control plane

Nodes

Everything is running. Click a component to stop it.

  • Running apps keep serving traffic

  • kubectl get and apply work

  • New pods get placed on a node

  • Crashed or deleted pods are replaced

  • Apps find each other by name

The pattern worth remembering: running workloads are surprisingly hard to kill. Almost every control plane failure freezes the cluster in its current state rather than tearing it down. What stops is change: new pods, replacements, scaling, deploys.

Hands-on: find every component

Live lab · no install

Find every component

Look under the hood of a running kind cluster and trace who did what.

kind-learn
  1. Tasks0/6
  2. Find the control plane

    Tick "system" above the map to see these pods on the node.

    kubectl cluster-info
  3. List every cluster component

    The API server, etcd, scheduler and controller manager run as pods in kube-system.

    kubectl get pods -n kube-system

    Names ending in -learn-control-plane are static pods, started by the kubelet from files on the node.

  4. Check the kubelet, which is not a pod

    kind nodes are Docker containers, so you can look inside one.

    docker exec learn-control-plane systemctl is-active kubelet
  5. Ask the runtime what it is running

    crictl talks to containerd directly, the same way the kubelet does.

    docker exec learn-control-plane crictl ps --name nginx
  6. Scale web to 4 and see who did what

    Events record every component that touched the new pod.

    kubectl scale deployment web --replicas=4
    sleep 3
    kubectl get events --sort-by=.metadata.creationTimestamp | tail -n 6

    SuccessfulCreate: the ReplicaSet controller. Scheduled: the scheduler. Pulled and Started: the kubelet.

  7. Read the newest pod from top to bottom

    describe ends with the same story, for one pod.

    kubectl describe $(kubectl get pods -l app=web --sort-by=.metadata.creationTimestamp -o name | tail -n 1)
  8. Lab complete. Keep experimenting, or press Reset to start again.
↑↓ history · Tab complete · Ctrl+C stop
Cluster map live
  • ready
  • starting / not ready
  • failing
  • terminating
Prefer your own machine? The same steps on a local cluster

Use the learn cluster from chapter 1. In kind, one node runs both halves, so you can see everything at once.

Terminal
kubectl cluster-info
kubectl get pods -n kube-system
Kubernetes control plane is running at https://127.0.0.1:52813
CoreDNS is running at https://127.0.0.1:52813/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

NAME                                          READY   STATUS    RESTARTS   AGE
coredns-7c65d6cfc9-8xw2m                      1/1     Running   0          1h
coredns-7c65d6cfc9-tqv6n                      1/1     Running   0          1h
etcd-learn-control-plane                      1/1     Running   0          1h
kindnet-9k4lf                                 1/1     Running   0          1h
kube-apiserver-learn-control-plane            1/1     Running   0          1h
kube-controller-manager-learn-control-plane   1/1     Running   0          1h
kube-proxy-r2b7d                              1/1     Running   0          1h
kube-scheduler-learn-control-plane            1/1     Running   0          1h
-n kube-system
The namespace where cluster components live.
-learn-control-plane
Control plane components run as static pods, named after their node.
coredns
Cluster DNS, so pods can find Services by name (chapter 5).

The kubelet is missing from that list because it is not a pod. kind nodes are Docker containers, so you can look inside one:

Terminal
docker exec learn-control-plane systemctl is-active kubelet
docker exec learn-control-plane crictl ps --name nginx
active
CONTAINER       IMAGE          CREATED        STATE     NAME    ATTEMPT   POD ID          POD
3f1c2a9e8b7d4   a830707172e8   2 hours ago    Running   nginx   0         9e1d7c3b2a6f5   web-6c9b8d7f5d-9qmzt
...
systemctl is-active kubelet
The kubelet runs as a systemd service on the node.
crictl ps
Asks containerd directly, the same way the kubelet does.

Finally, see the components at work. Events record who did what:

Terminal
kubectl get events --sort-by=.metadata.creationTimestamp | tail -n 5
LAST SEEN   TYPE     REASON              OBJECT                     MESSAGE
5m          Normal   ScalingReplicaSet   deployment/web             Scaled up replica set web-6c9b8d7f5d from 2 to 3
5m          Normal   SuccessfulCreate    replicaset/web-6c9b8d7f5d  Created pod: web-6c9b8d7f5d-zc8hn
5m          Normal   Scheduled           pod/web-6c9b8d7f5d-zc8hn   Successfully assigned default/web-6c9b8d7f5d-zc8hn to learn-control-plane
5m          Normal   Pulled              pod/web-6c9b8d7f5d-zc8hn   Container image "nginx:1.27" already present on machine
5m          Normal   Started             pod/web-6c9b8d7f5d-zc8hn   Started container nginx
SuccessfulCreate
The ReplicaSet controller (controller manager).
Scheduled
The scheduler.
Pulled, Started
The kubelet and container runtime.

Add -v=6 to any kubectl command to see the HTTPS calls it makes to the API server. The log format varies between kubectl versions.

Mini mission

Name who did it

Scale web to four replicas. For the new pod, find which component created it, which one chose its node and which one started its container.

Reveal one safe solution
Terminal
kubectl scale deployment web --replicas=4
kubectl describe $(kubectl get pods -l app=web --sort-by=.metadata.creationTimestamp -o name | tail -n 1)

The Events at the bottom show default-scheduler for Scheduled and kubelet for Pulled, Created and Started. The pod's Controlled By line names its ReplicaSet, whose controller created it. Scale back with kubectl scale deployment web --replicas=3.

Check yourself

Quiz

0 of 4 answered

  1. 1. Which component is the only one that reads and writes etcd?
  2. 2. A pod stays Pending with no node assigned. Where do you look first?
  3. 3. How does the kubelet run on a node?
  4. 4. On a managed cluster such as EKS, AKS or GKE, who runs the control plane?

Further reading