Sub topic 11
Upgrading the control plane with kubeadm
This chapter assumes you know basic kubectl, understand the roles of control plane and worker nodes, and have read the chapters on version skew and etcd backups. The cluster is assumed to be built with kubeadm, with a stacked etcd (etcd running on the control plane nodes).
What the upgrade does
kubeadm upgrade apply upgrades the control plane components on one node: the API server, controller manager, scheduler, and local etcd. It also upgrades CoreDNS and kube-proxy. It does not upgrade the kubelet, kubectl, or your CNI plugin. You handle those separately.
The kubelet on a control plane node may be one minor version older than the API server, so a newly upgraded API server is allowed to run with an older kubelet for a while. You must never skip a minor version. Going from 1.29 to 1.31 means doing 1.29 to 1.30 first.
Step by step
First install the new kubeadm package on the first control plane node. The exact commands depend on your package manager and repository. Then run:
# On the first control plane node, after installing the new kubeadm package
sudo kubeadm upgrade plan
sudo kubeadm upgrade apply v1.<MINOR>.<PATCH>plan checks the current cluster and lists the versions you can reach. Read its output for warnings, such as component configs that need manual changes. apply then pulls images and replaces the static Pod manifests one at a time.
Now upgrade the kubelet on that node. Drain it, upgrade the kubelet and kubectl packages, restart the kubelet, and uncordon:
kubectl drain <node-name> --ignore-daemonsets --delete-emptydir-data
# Upgrade the kubelet and kubectl packages on the node, then:
sudo systemctl daemon-reload
sudo systemctl restart kubelet
kubectl uncordon <node-name>On every other control plane node, install the new packages and run the shorter command. Do these nodes one at a time:
sudo kubeadm upgrade nodeThen repeat the drain, kubelet upgrade, and uncordon steps for each of those nodes.
Common errors
- Version skew refusal.
planshows no target, orapplyrefuses, because you tried to skip a minor version. Upgrade through each minor release. - Package version mismatch. The
kubeadmbinary must match the target version. Check it withkubeadm versionbefore you runapply. - Held packages. If the package manager pins
kubeadm,kubelet, andkubectl, you must unhold them for the upgrade and hold them again afterward. - Stuck static Pods. If
applytimes out waiting for a component, checkcrictl psand the kubelet logs on that node. Do not rerun blindly. kubeadm keeps backups of the old manifests under/etc/kubernetes/tmp. - Add-ons break. The CNI plugin, ingress controller, and webhooks may not support the new version. Check them in your planning step before you start.
Exercise
You have three control plane nodes. You ran kubeadm upgrade apply on node 1 and upgraded its kubelet. Which kubeadm command do you run on nodes 2 and 3, and what does apply leave for you to do by hand on every node?
Show answer
Run sudo kubeadm upgrade node on nodes 2 and 3, one at a time. apply and upgrade node do not upgrade the kubelet or kubectl. On every node you must drain it, upgrade those packages, restart the kubelet, and uncordon it. The CNI plugin is also outside kubeadm's upgrade.