How to Upgrade Kubeadm Cluster

kubeadm cluster upgrade

In this blog, I am going to demonstrate how we can upgrade the Kubeadm cluster from version 1.27 to 1.28.

Let’s see my current Kubeadm Cluster version.

kubectl get nodes
list nodes

Both Nodes in this cluster are running on the Kubeadm 1.27.1 version, so I am going to upgrade that to version 1.28.0.

Upgrade Controlplane

First, I am going to upgrade the Master Node.

Step 1: Drain Master Node

kubectl drain master-node --ignore-daemonsets
drain nodes
kubectl get nodes
list nodes

I am already in the Master Node, If you are using kubeconfig to connect the Nodes then first you need to enter into the Master Node.

ssh master-node

sudo permission necessary to upgrade the Kubeadm

sudo -i 

Step 2: Upgrade the Kubeadm

Upgrade the Master Node Kubeadm version from v1.27 to v1.28

apt-mark unhold kubeadm && \
apt-get update && apt-get install -y kubeadm='1.28.0-00' && \
apt-mark hold kubeadm

Once the degradation is completed, we need to ensure the Kubeadm version.

kubeadm version
kubeadm upgrade success

You can ensure how this upgrade performs before degradation by using the following command.

kubeadm upgrade plan
kubeadm upgrade plan

Now, I am going to apply this update.

kubeadm upgrade apply v1.28.0
kubeadm upgrade success

Step 3: Upgrade Kubelet and Kubectl

After seeing the upgrade’s successful output, I am upgrading the Kubelet and the Kubectl

apt-mark unhold kubelet kubectl && \
apt-get update && apt-get install -y kubelet='1.28.0-00*' kubectl='1.28.0-00' && \
apt-mark hold kubelet kubectl

Once the upgrade is completed, we have to reload the services.

systemctl daemon-reload
systemctl restart kubelet

If you want to confirm the kubelet service is running without any issues, you can use the following command.

systemctl status kubelet

Then you need to exit two times from the terminal to reach the initial position.

exit
exit

Finally, we need to uncordon the Master Node to schedule Pods.

kubectl uncordon master-node

Step 4: Check the Kubeadm Version

If we check the Nodes, we can see that the Master Node version has been changed.

kubectl get nodes
kubeadm version

Upgrade Worker Nodes

In Worker nodes also we do the same steps to upgrade the Kubeadm version.

Step 1: Drain Worker Node

First, need to drain the Worker Node

kubectl drain worker-node01 --ignore-daemonsets
kubeadm version

Enter into the Secure Shell of the Worker Node

ssh worker-node01

Sudo permission is required to upgrade Kubeadm

sudo -i

Step 2: Upgrade the Kubeadm

Upgrade the Kubeadm.

apt-mark unhold kubeadm && \
apt-get update && apt-get install -y kubeadm='1.28.0-00' && \
apt-mark hold kubeadm

Now, let’s upgrade the Node.

kubeadm upgrade node

Step 3: Upgrade Kubelet and Kubectl

After successfully upgrading the Node, we have to upgrade the Kubelet and Kubeclt.

apt-mark unhold kubelet kubectl && \
apt-get update && apt-get install -y kubelet='1.28.0-00' kubectl='1.28.0-00' && \
apt-mark hold kubelet kubectl

Once the upgrade process is completed, the services should be reloaded.

systemctl daemon-reload
systemctl restart kubelet

Now, we have to exit from the sudo shell as well as from the SSH

exit

Uncordon the Worker Node to accept scheduling Pods.

kubectl uncordon worker-node01

Step 4: Check the Node Version

List the Nodes and ensure the version of the Nodes.

kubectl get nodes
list nodes

Conclusion

This document explains how we can upgrade our Kubeadm cluster from version 1.27 to 1.28, and always ensure the steps are properly followed on the upgrade, also don’t forget to confirm the version at the end of the upgrade.

Also, cluster upgrade is an important task in CKA certification. If you are preparin for the certification, make use of the CKA coupon from the Linux Foundation coupon page.

0 Shares:
Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like