Control plane
Upgrading the cluster
Control plane first, then each node
The cluster runs Kubernetes v1.36.6 and you move it to v1.37.2. An upgrade isn't one switch: every component is upgraded on its own, in an order the version skew policy allows. The control plane goes first, starting with the API server, and the kubelets follow, one node at a time, each one drained before its kubelet changes. The control plane runs as static Pods on one machine, cp-1, so for a short while there is no API at all, and the Pods keep serving anyway.
- From → to
- v1.36.6 → v1.37.2 · one minor version
- Tool
- kubeadm · static Pods on cp-1 (10.0.0.10)
- Order
- API server → controllers → kubelets
- Apps during it
- keep serving · moved off each node first
Read the whole lesson as text
1. The skew rules
Components of different versions run side by side during an upgrade, and the version skew policy says which mixes are supported. The API server is the newest component and goes first, one minor version at a time: 1.36 to 1.38 directly isn't supported. The controller manager and scheduler may be one minor older than the API server, never newer. Kubelets may be up to three minors older, never newer. kubectl may be one minor either side. So the control plane can reach 1.37 while every kubelet is still on 1.36.
- You check the versions: everything is on v1.36.6.
- The skew policy allows the control plane to be one minor ahead of every kubelet, so the upgrade can go in stages.
2. Plan
On cp-1, upgrade kubeadm itself first. Kubernetes packages come from pkgs.k8s.io, which has one repository per minor version, so you point apt at v1.37 before installing kubeadm 1.37.2. kubeadm upgrade plan then checks that the cluster is healthy, reads its configuration from the kubeadm-config ConfigMap and prints what it would change. It doesn't look for manifests that use APIs the new version has removed. That check is yours, and the API server keeps a metric for it.
- On cp-1, you switch the package repository to v1.37 and install the new kubeadm.
- kubeadm checks the cluster and prints what an upgrade to 1.37.2 would change.
- You ask the API server which deprecated APIs clients have been calling.
3. Apply
kubeadm upgrade apply v1.37.2 checks again, makes sure the new images can be pulled, and backs up the current static Pod manifests and etcd's data under /etc/kubernetes/tmp. It renews the control plane certificates by default. Then it rewrites the static Pod manifests in /etc/kubernetes/manifests, one component at a time. kubeadm never starts a container itself: the kubelet on cp-1 watches that directory and replaces each Pod when its file changes, and kubeadm waits for each one to come back healthy.
- kubeadm checks the cluster again and pulls the 1.37.2 images onto cp-1.
- kubeadm copies the current manifests and etcd's data directory aside, so a failed step can be rolled back.
- kubeadm renews the control plane certificates, which restarts their one-year clock.
- kubeadm writes the new kube-apiserver manifest. cp-1's kubelet sees the file change.
4. The API blinks
With a single control plane node, the cluster has no API while the new API server starts: kubectl, the controllers and every kubelet get connection refused. Nothing that's already running depends on the API, though. Pods keep serving, kube-proxy's iptables rules stay in the kernels, and a request to web is answered as usual. When the new API server is up, the kubelets reconnect their watches. kubeadm then replaces the controller manager and the scheduler, and each wins its leader Lease again before it does any work.
- cp-1's kubelet stops the old API server. Until the new one answers, every API call fails.
- In the middle of it, a request to web reaches a Pod on node-2 through the Service, and gets its answer.
- The new API server is Ready. The kubelets reconnect their watches.
- kubeadm swaps in the new controller manager. It takes its leader Lease before it starts any controller.
- Then the new scheduler, which also takes its Lease first.
- kubeadm uploads its new config, then upgrades CoreDNS and kube-proxy, and reports success.
5. The control plane node's kubelet
The control plane is on 1.37, but cp-1's kubelet, the program that runs those static Pods, is still 1.36. Upgrading a kubelet's minor version in place isn't supported, so you drain cp-1 first, which moves off the few ordinary Pods that run there, such as CoreDNS. Then install the new kubelet and kubectl packages, restart the kubelet, and uncordon. The static Pods don't go anywhere: they belong to this node's kubelet and start again with it.
- You drain cp-1: a cordon, then evictions, as in Draining a node.
- With the new packages installed, the kubelet restarts and reports its new version.
- You uncordon cp-1.
6. Each worker
Now the workers, one at a time so the others carry the load. On node-1: drain it, as in Draining a node, so its web Pod moves to node-2. Upgrade kubeadm and run kubeadm upgrade node, which on a worker fetches the 1.37 kubelet configuration from the cluster and writes it to disk. Upgrade the kubelet package, restart it, and the Node reports its new version. Uncordon. Then the same for node-2, whose Pods move to node-1.
- You drain node-1. Its web Pod is evicted and a replacement starts on node-2.
- On node-1, the new kubeadm fetches the 1.37 kubelet configuration and writes it to disk.
- With the kubelet package upgraded and restarted, node-1 reports v1.37.2.
- You uncordon node-1. Nothing moves back to it on its own.
- Now node-2. Its three web Pods are evicted, and the replacements land on node-1.
- kubeadm upgrade node, a new kubelet and a restart later, node-2 reports v1.37.2, and you uncordon it.
7. After
kubeadm only upgrades what it installed. Everything else in the cluster has its own version and its own support matrix: the CNI plugin, the ingress controller, the CSI drivers, operators. Check each against 1.37, ideally before you start. Managed services do the node part differently: they usually add new nodes with the new version and drain and delete the old ones, instead of upgrading kubelets in place. And with many clusters, upgrade a few first, watch them, then the rest.
- Every component reports 1.37.2. What kubeadm didn't install is still on whatever version it was.
Summary
An upgrade is many small replacements in an order the skew policy allows: kubeadm first, then the API server, the controllers and the add-ons, then each kubelet behind a drain. kubeadm does the control plane by rewriting static Pod manifests and letting cp-1's kubelet restart them. While the only API server restarts, the cluster can't change, but it keeps running. The things kubeadm didn't install are still yours to check.
Next lesson: Backing up and restoring etcd