Learn Labs
Foundations

Architecture

The API server, etcd, scheduler, controllers, kubelet, and kube-proxy

A Kubernetes cluster is a database of desired state with a set of programs that each watch part of it and act. Everything goes through one front door, the API server.

kubectl get pods -n kube-system -o wide
NAME                                        STATUS    NODE
etcd-lab-control-plane                      Running   lab-control-plane
kube-apiserver-lab-control-plane            Running   lab-control-plane
kube-controller-manager-lab-control-plane   Running   lab-control-plane
kube-scheduler-lab-control-plane            Running   lab-control-plane
coredns-559f6c778d-7vjpk                    Running   lab-control-plane
kube-proxy-wcgbz                            Running   lab-worker2        # one per node
kindnet-wxdtl                               Running   lab-worker2        # one per node (the network plugin)
metrics-server-995d47bd7-ml8q7              Running   lab-worker3
kube-state-metrics-7cfd7f4c58-vpndr         Running   lab-worker3

The control plane

ComponentDoes
kube-apiserverThe only thing anyone talks to. Authenticates, authorizes, validates, runs admission (Pod Security, defaults), stores objects, and serves watches: streams of changes
etcdThe database. A Raft-replicated key-value store (one member here; three or five in production). Lose it without a backup and the cluster forgets everything
kube-schedulerWatches for pods with no node, picks one (resources, spread, affinity, taints, volume topology) and writes the choice back
kube-controller-managerDozens of controllers: Deployment, ReplicaSet, StatefulSet, node lifecycle, endpoints, garbage collection... each a reconciliation loop

On every node

ComponentDoes
kubeletWatches for pods bound to its node, starts their containers through the runtime (containerd), runs probes, reports status, kills containers over their memory limit (via the kernel)
kube-proxyPrograms the node's packet rules (iptables or nftables) so Service IPs reach pod IPs
CNI plugin (kindnet here)Gives each pod an IP and routes between nodes; enforces NetworkPolicies if it supports them

One Deployment, start to finish

youAPI server + etcdcontrollersschedulerkubeletapply: Deployment replicas=3watch: want 3, have 0create ReplicaSet, 3 Podsbind each Pod to a nodemy node has a new Pod: start itstatus: Running, Ready
  1. kubectl apply sends a Deployment to the API server, which stores it.
  2. The Deployment controller sees a Deployment with no ReplicaSet and creates one. The ReplicaSet controller sees 0 of 3 pods and creates 3 pod objects, with no node.
  3. The scheduler sees 3 unscheduled pods and binds each to a node.
  4. Each kubelet sees a pod bound to its node, pulls the image, starts the container, runs the probes, and reports status.
  5. The endpoints controller sees ready pods matching the Service's selector and adds them to its EndpointSlice. kube-proxy and the Gateway's NGINX see that and start sending traffic.

No component calls another. Each watches the API server for the objects it cares about and writes its results back. That's why the system heals itself: if a step fails, the gap is still visible, and the loop tries again.

Talking to the API

kubectl get deploy web -n shop -o yamlthe stored object: spec (desired) + status (observed)kubectl get --raw /apis/apps/v1/namespaces/shop/deployments/web | head -c 300kubectl get events -n shop --watchcontrollers narrating what they dokubectl api-resourcesevery object type this cluster knows

Every object has a spec (what you want) and a status (what the controllers last observed). Debugging Kubernetes is mostly comparing the two, and reading the events controllers emit when they can't close the gap.

Lab

  1. Run kubectl get events -n shop --watch in one terminal and kubectl -n shop scale deploy web --replicas=5 in another. Name the component behind each event.
  2. Stop the scheduler: docker exec lab-control-plane mv /etc/kubernetes/manifests/kube-scheduler.yaml /tmp/. Scale web to 6. What state are the new pods in? Move the file back.
  3. Read kubectl get lease -n kube-node-lease twice, ten seconds apart.

On this page