The control plane

Intermediate · 9 min

The API server, etcd, the scheduler and the controller manager: what each one does, how they talk only through the API, and how they stay up.

Before thisWhat Kubernetes is and is not

Anton Putra · 13 min · from 3:20

The control plane

The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.

Taught by Anton PutraReport a problem with this video
Not started
Set this lesson's status

What you'll learn

  • The API server is the only component that talks to etcd. Every other part of the cluster, including the scheduler and controllers, is just an API client.
  • A write passes authentication, authorization, mutating admission, schema validation and validating admission before it is stored, so policy lives in one place.
  • etcd holds the whole cluster state as keys under /registry. Losing it means losing the cluster, so it runs as an odd-sized quorum and gets backed up.
  • The scheduler only chooses a node and records the choice. The controller manager runs about fifty independent reconcile loops in one process.
  • API servers scale out side by side. The scheduler and controller manager run several copies but only one leads at a time, decided by a Lease object.

One place where decisions are made

Picture a cluster without a centre. Each node runs its own copy of “keep three web servers going”, and each one notices a crash and starts a replacement. Two of them do it at once and you have four. A third node never heard about the change. Every distributed system that lets many actors write shared state has to answer the same questions: where is the truth kept, who may change it, and how do the others find out?

Kubernetes answers with the control plane: a small set of components that hold the cluster’s desired state and decide what should happen next. Nodes do the work. The control plane keeps the books.

The API server: the only door

kube-apiserver serves the Kubernetes API over HTTPS. You, kubectl, CI pipelines, the scheduler, every controller and every kubelet all talk to it. It is the only component that reads from and writes to etcd.

That single door is the design. Every write goes through the same pipeline, as the “Controlling access” docs lay out:

  1. Authentication works out who you are: a client certificate, a bearer token, OIDC.
  2. Authorization asks whether that identity may do this verb on this resource, usually through RBAC.
  3. Mutating admission can change the object, such as filling in a default ServiceAccount or injecting a sidecar.
  4. Schema validation rejects malformed objects.
  5. Validating admission can still refuse it, for example Pod Security or a ValidatingAdmissionPolicy.
  6. The object is written to etcd, and anyone watching that kind of object is told.

Because everything passes through here, the API server is also where auditing, rate limiting (API Priority and Fairness) and watch caching happen. It is stateless apart from caches, so you scale it by running more copies behind a load balancer.

The lab cluster makes the “everyone is a client” point concrete. After kubectl create deployment web --replicas=3, the API server’s audit log records who did what (one line per write, condensed with a short script):

17:46:28.088 lab-admin                                               create deployments  web
17:46:28.095 system:serviceaccount:kube-system:deployment-controller create replicasets web-689b9bdbdd
17:46:28.107 system:serviceaccount:kube-system:replicaset-controller create pods
17:46:28.111 system:serviceaccount:kube-system:replicaset-controller create pods
17:46:28.115 system:serviceaccount:kube-system:replicaset-controller create pods
17:46:28.123 system:serviceaccount:kube-system:replicaset-controller update replicasets/status

Two controllers, each with its own identity, made ordinary API calls within 30 milliseconds of the human’s request. Nothing happened behind the API’s back.

etcd: the state of the cluster

etcd is a consistent key-value store built on the Raft consensus algorithm. Kubernetes keeps every object under keys that start with /registry/. Querying the lab’s etcd directly, with the API server out of the picture:

/registry/deployments/default/web
/registry/replicasets/default/web-689b9bdbdd
/registry/pods/default/web-689b9bdbdd-mvwsr
/registry/pods/default/web-689b9bdbdd-vxgrd

The values are not YAML. They start with the bytes k8s\x00 and hold protobuf-encoded objects, which is one more reason only the API server should touch them.

Raft needs a majority to commit a write, so etcd runs as 3 or 5 members. Three survive one failure, five survive two, and an even count buys nothing. If quorum is lost, the API server can no longer change anything, but running containers keep running, because nodes do not need the control plane to keep doing what they were already told. etcd is the one component you must back up. Snapshots are covered in backup and disaster recovery.

The scheduler: one decision, recorded

kube-scheduler watches for Pods with no spec.nodeName. For each one it filters out nodes that cannot fit it (not enough CPU, wrong taints, failing affinity rules), scores the rest, and writes a binding that sets the node. That is all it does. It starts nothing; the kubelet on the chosen node sees a Pod assigned to it and takes over. How the scheduler places Pods covers the filter and score plugins.

The controller manager: many small loops

kube-controller-manager is one binary that runs many controllers. Logically each is separate, and they are compiled together for convenience. In v1.37.3, kube-controller-manager --help lists 49 of them, from deployment-controller and replicaset-controller to node-lifecycle-controller, namespace-controller, garbage-collector-controller and cronjob-controller. Each watches some kinds of objects and acts to close a gap. Controllers and the reconcile loop covers how one works.

On a cloud, a separate cloud-controller-manager runs the loops that need the provider’s API: creating load balancers for type: LoadBalancer Services, labelling nodes with their zone, and deleting Node objects when the VM is gone. Splitting it out lets cloud providers release on their own schedule.

Staying up

A production control plane runs on three or more machines. The pieces scale differently:

Component How it runs in HA
kube-apiserver All copies active behind a load balancer
etcd 3 or 5 members, Raft majority
kube-scheduler Several copies, one leader
kube-controller-manager Several copies, one leader

Two schedulers making different choices for the same Pod would be a mess, so the scheduler and controller manager use leader election. Each copy tries to hold a Lease object in kube-system (named kube-scheduler or kube-controller-manager). The holder renews it every few seconds. If it stops, the others wait out the lease duration, 15 seconds by default, and one takes over. On a managed service like EKS or GKE, all of this is run for you and you never see these machines, covered in managed Kubernetes.

About the video

The embed is the “Control Plane” chapter of Anton Putra’s “Kubernetes Architecture: Deep Dive - Part 2” (June 2024), from 3:20 to 16:04. Its sub-chapters, per the description, take etcd, kube-scheduler, the controller manager, the cloud controller manager and the API server in turn, which is the same set this lesson covers. It does not cover the admission pipeline in detail or HA leader election, which the lesson adds. The video’s Nodes chapter, right after this clip, is the subject of the next lesson. English was judged from the watch page’s “English (US) original” audio track. Daniel Smith’s 2019 KubeCon talk in deeper is the API machinery view of why the control plane is built from resources and controllers, and it has aged well.

What was run: the audit-log lines, the /registry/ keys (read through etcd’s HTTP gateway) and the controller count came from a local v1.37.3 control plane whose nodes run no containers, on 2026-11-28. That lab runs one copy of each component with leader election turned off, so the Lease behaviour and HA table are from the kube-scheduler flag defaults and the Kubernetes docs, checked the same day.

Where this fits

The other half of the cluster does the running: nodes, the kubelet and the container runtime.

Check yourself

  1. 01The scheduler process crashes for ten minutes. Which running workloads stop?

    None. Running Pods are untouched because the scheduler only assigns nodes to new Pods. During the outage, newly created Pods stay unscheduled with no node; once a scheduler is back, it assigns them.

  2. 02Why does no controller connect to etcd directly, even though that would save a hop?

    Going through the API server means every change is authenticated, authorized, admitted, validated and audited the same way, and it lets the API server serve watches from its cache. A controller writing to etcd would bypass all of that and couple itself to the storage format.

  3. 03You run three etcd members and lose two. What happens to the cluster?

    etcd loses quorum, needing two of three, so it stops accepting writes, and the API server cannot change state. Running Pods keep running on their nodes, but nothing new can be created, scheduled or updated until quorum is restored or etcd is recovered from backup.

  4. 04In a highly available control plane, what stops two controller managers from both creating replacement Pods?

    Leader election. Each copy tries to hold a Lease in kube-system; only the holder runs its controllers. The others wait and take over if the leader stops renewing the Lease, after 15 seconds by default.

Go deeper

Notes

Private to you

Esc
↑↓ navigate↵ open? shortcuts

Keyboard shortcuts

Press Esc to close

Anywhere

⌘K
Search and commands
/
Search
?
This sheet
Esc
Close

Reading a lesson

J
Next lesson
K
Previous lesson
B
Bookmark