Upgrade a cluster with kubeadm
Author: Fabrice JAMMES (LinkedIn).
Objective
- Upgrade a kubeadm cluster from Kubernetes 1.36 to 1.37: the control plane first, then the worker
- Empty a node with
kubectl drainbefore upgrading its kubelet - Understand the version skew policy, which imposes this order
The CKS curriculum lists “Upgrade Kubernetes to avoid vulnerabilities” in the Cluster Hardening domain: a security patch reaches a cluster only through an upgrade. The CKA curriculum lists the same task.
Official documentation, available in the exam:
Setup
The two-node cluster in Kubernetes 1.36 of the kubeadm lab: built by yourself, or already installed by the trainer.
On the training server, name your two nodes:
Then open one terminal on each node, with ssh $MASTER and ssh $WORKER. On the master, check the version of the nodes:
Deploy an application, to watch what happens to it during the upgrade:
Exercise 1: the target version
Which versions of kubeadm 1.37 can you install on the master?
Tip
The apt repository of the Kubernetes packages serves one minor version only: look at /etc/apt/sources.list.d/kubernetes.list.
Exercise 2: upgrade the control plane
On the master: upgrade kubeadm, check the upgrade plan, apply it, then upgrade the kubelet and kubectl of the master. Empty the master with kubectl drain before restarting its kubelet.
Warning
Run the upgrade of each node in tmux: if the ssh connection drops during kubeadm upgrade apply, kubeadm stops halfway. Reattach with tmux attach.
Exercise 3: upgrade the worker
Empty the worker from the master, upgrade it, then put it back in service. Where are the pods of the hello application during the upgrade?
Questions
- Why the control plane first, then the workers? Can you upgrade from 1.36 to 1.38 at once?
- Why
apt-mark holdonkubeadm,kubeletandkubectl? - A CVE is fixed in Kubernetes 1.36.5. Which upgrade do you plan?