4. Cluster upgrade

First, upgrade the control plane node.

Drain the control plane node.

kubectl drain <control plane node name> --ignore-daemonsets

Upgrade kubeadm.

sudo apt-get update && \
sudo apt-get install -y --allow-change-held-packages kubeadm=1.20.2-00

kubeadm version

Plan the upgrade.

sudo kubeadm upgrade plan v1.20.2

Upgrade the control plane components.

sudo kubeadm upgrade apply v1.20.2

Upgrade kubelet and kubectl on the control plane node.

sudo apt-get update && \
sudo apt-get install -y --allow-change-held-packages kubelet=1.20.2-00 kubectl=1.20.2-00

Restart kubelet.

sudo systemctl daemon-reload

sudo systemctl restart kubelet

Uncordon the control plane node.

Verify that the control plane is working.

Upgrade the worker nodes.

Note: In a real-world scenario, you should not perform upgrades on all worker nodes at the same time. Make sure enough nodes are available at any given time to provide uninterrupted service.

Run the following on the control plane node to drain worker node 1:

Log in to the first worker node, then Upgrade kubeadm.

Upgrade the kubelet configuration on the worker node.

Upgrade kubelet and kubectl on the worker node.

Restart kubelet.

From the control plane node, uncordon worker node 1.

Repeat the upgrade process for worker node 2.

From the control plane node, drain worker node 2.

On the second worker node, upgrade kubeadm.

Perform the upgrade on worker node 2.

From the control plane node, uncordon worker node 2.

Verify that the cluster is upgraded and working.

Last updated