Kubernetes foundations: the cluster and kubectl · 6 MIN READ
How a cluster works: control plane, nodes and reconciliation loops
Name the control-plane and node components, trace a kubectl apply from the API request to a running container, and inspect the nodes and system pods of a kind cluster.
Kubernetes is easy to treat as a black box until something does not start; then you need to know which component was supposed to act. A cluster is a store of desired state plus independent control loops that keep moving reality towards it. This lesson maps those parts, follows one Deployment from kubectl to running containers, and builds a local cluster with kind to look at them.
kubernetes · A MAP OF THE IDEA
- kubectl sends the object
- API server stores it in etcd
- Controllers create pods
- Scheduler binds to nodes
- Kubelet starts containers
Useful when
- Each component reconciles independently, so restarts and missed events heal themselves.
- One API makes every part of the system observable with kubectl.
Watch out
- etcd holds everything, so back it up and restrict access to it.
- Changes made by hand to running containers are undone by reconciliation.
Implementation & operation cost: A control plane to run or rent, and the habit of debugging through objects, status and events rather than hosts.
The control plane: one API, one store, many controllers
kube-apiserver is the front door and the only component that talks to etcd. kubectl, the controllers, the scheduler and every kubelet are clients of its REST API. Each request is authenticated, authorized (normally by RBAC), filled in with defaults, run through admission control, which can modify or reject it, validated, and then stored in etcd, a consistent key-value store that is the cluster's only source of truth: lose etcd without a backup and you lose the cluster. kube-scheduler watches for pods that have no node, filters out nodes that cannot run them (resources, taints, affinity), scores the rest and records its choice in the pod's spec.nodeName. kube-controller-manager runs dozens of controllers in one process, among them the Deployment, ReplicaSet, Job, node lifecycle, EndpointSlice, namespace and garbage-collector controllers. None of them start containers; they create, update and delete other objects.
Nodes: kubelet, container runtime and kube-proxy
Every node, the control-plane node included, runs a kubelet. It watches the API for pods bound to its node and asks the container runtime, containerd in kind and most clusters, through the Container Runtime Interface to pull images, create the pod sandbox and start containers. It then runs probes and writes container states back into pod status. kube-proxy watches Services and EndpointSlices and programs iptables or nftables rules so that a Service's virtual IP reaches pod IPs; some network plugins replace it entirely. The CNI plugin, kindnet in kind, gives each pod an IP from its node's pod range. The control-plane components are themselves static pods: the kubelet on the control-plane node starts them from manifest files in /etc/kubernetes/manifests, so they run before any scheduler exists, and read-only mirror pods represent them in kube-system.
Desired state, observed state and reconciliation
Objects carry a spec, the desired state you write, and a status, the observed state written by the component responsible for it. A controller is a loop: observe the current state through watches, compare it with the spec, act to narrow the gap, record what it saw in status, and repeat. Controllers are level-triggered: they react to how things are now, not to a log of past events, so a missed notification or a restarted controller is harmless, because the next pass sees the same gap and closes it. This is why deleting a pod that a ReplicaSet owns does not reduce the replica count, why pods from a dead node reappear on other nodes, and why the fix for drift is to change the spec rather than to poke at whatever is running.
From kubectl apply to a running container
Follow kubectl apply -f web.yaml for a Deployment with three replicas. kubectl sends the object to kube-apiserver, which authenticates you, checks RBAC, runs admission, validates the object and writes it to etcd; apply returns as soon as the object is stored, before anything runs. The Deployment controller notices a Deployment without a matching ReplicaSet and creates one. The ReplicaSet controller sees zero of three pods and creates three Pod objects that have no node yet. The scheduler binds each pod to a node. The kubelet on that node sees the new pod, has containerd pull the image and start the container, and reports the pod Running, then Ready once its probes pass. Every component acted on an object that the previous one wrote, and every step left an event you can read afterwards.
kind: a whole cluster in containers
kind (Kubernetes IN Docker) runs each node as a container on your machine, from the kindest/node image that contains the kubelet, containerd and kubeadm. kind create cluster boots the control plane with kubeadm, installs the kindnet CNI and a local-path StorageClass, adds a context named kind-NAME to ~/.kube/config and makes it current. The result is a conformant cluster, good for learning, CI and testing manifests, but not a production environment: all nodes share one kernel and disk, LoadBalancer Services need an extra component, and your laptop's memory is the limit. A small config file describes the node layout. With a single node, kind removes the control-plane taint so that ordinary pods can run there; with workers, the control-plane node keeps its NoSchedule taint and your pods land on the workers.
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
- role: workerThis is the whole file for a three-node cluster: one control-plane node and two workers, each a container on your machine. For the default cluster name kind they are called kind-control-plane, kind-worker and kind-worker2. Pass the file with kind create cluster --config kind.yaml; on your own machine, --name lets several clusters run side by side, each with its own kind-NAME context.
Try it in the lab terminal
Build a three-node cluster from a kind config file and look at what kind installed: the nodes, the system pods in kube-system and the details of the control-plane node. Then create a Deployment and read the events to watch the chain of components turn one command into running pods. Deleting all of its pods at the end shows reconciliation at work: nobody asks for new pods, but the ReplicaSet still wants three.
cat > kind.yaml <<'EOF'
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
- role: worker
EOF
kind create cluster --config kind.yaml
kubectl cluster-info
kubectl get nodes -o wide
kubectl get pods -n kube-system -o wide
kubectl describe node kind-control-plane
kubectl create deployment web --image=nginx:1.27 --replicas=3
kubectl get events --sort-by=.metadata.creationTimestamp
kubectl rollout status deploy/web
kubectl get pods -o wide
kubectl delete pod -l app=web
kubectl get podsget nodes lists kind-control-plane, kind-worker and kind-worker2, all Ready on v1.34.1 with containerd://2.1.1. In kube-system, etcd, kube-apiserver, kube-controller-manager and kube-scheduler are static pods named after their node, using its IP 172.18.0.2; kindnet and kube-proxy run once per node; the lab adds metrics-server, which plain kind does not install. describe node shows the taint node-role.kubernetes.io/control-plane:NoSchedule, so web lands on the workers. The events follow the chain: ScalingReplicaSet, three SuccessfulCreate, Scheduled to kind-worker or kind-worker2, Pulling, Pulled. After delete pod -l app=web, three new web-<hash>-<id> pods are already ContainerCreating.
TAKE THIS WITH YOU
A cluster is the API server and etcd holding desired state, plus controllers, the scheduler and kubelets that each reconcile one piece of it. When something does not happen, ask which component should have acted and read its events.
Check your understanding
You delete one of the three pods of a Deployment. Seconds later there are three pods again. Which component created the new Pod object?
Go to the source
Progress stays in this browser. No account needed.