In this blog, we are going to see how to upgrade the Kubernetes Kubeadm Cluster to version 1.33.1.

The first control plane is upgraded to kubeadm and its control plane components (kubelet, kubectl). Then worker nodes are upgraded to kubeadm and kubelet.

Upgrade Control Plane

Switch to the root user and run the commands in the below steps to upgrade the control plane.

Step 1: Check the Kubeadm new version

To check a new version, you need to verify the package for the version. Use the command below to package.

apt-get update -y 

apt-mark unhold kubeadm

apt-cache madison kubeadm | tac

You can view the new kubeadm version.

Step 2: Install the new version

Run the below command to install the new version of kubeadm

sudo apt-get install -y kubeadm=1.33.5-1.1

Verify if the new version of Kubeadm is installed using the command

kubeadm version -o json

You will get the kubeadm version details in the following output and you can see that version 1.33.5 has been installed.

Step 3: Upgrade Components of Control-Plane

Once the new version of kubeadm is installed, run the below command to view the control-plane component upgrade plan

kubeadm upgrade plan

It will show the current version of the components and the version it going to upgrade, to upgrade the components of the control node to the new version

kubeadm upgrade apply v1.33.5

Now we will hold the kubeadm package to prevent upgrades.

apt-mark hold kubeadm

Step 4: Upgrade Kubelet and Kubeclt

Now, all the components of the control plane have been upgraded to the new version. Drain the control plane using the command provided below to

kubectl drain controlplane --ignore-daemonsets

Then, use the below command to upgrade kubelet and kubeclt to the new version

apt-mark unhold kubelet kubectl 

apt-get update -y

apt-get install kubelet=1.33.5-1.1 kubectl=1.33.5-1.1

apt-mark hold kubelet kubectl

Restart the service to make the changes

systemctl daemon-reload
systemctl restart kubelet

Now, everything has been upgraded, uncordon the master node and check the nodes

kubectl uncordon controlplane

To verify the node use the command

kubectl get nodes

You can see the controlplane is upgraded to version 1.33.5.

Upgrade Worker Node

Upgrading the worker node is similar to upgrading the controlplane, switch to the root user and run the commands in the below steps to upgrade the controlplane.

Step 1:Check the Kubeadm new version

To check the new version, you need to verify the package's version. Use the command below to package. same as controlplane

apt-get update -y 

apt-mark unhold kubeadm

apt-cache madison kubeadm | tac

Use the command below to update the apt

apt update

Step 2: Install the new version

Run the below command to install the new version of kubeadm

apt-get install -y kubeadm=1.33.5-1.1

apt-mark hold kubeadm

Now, run the below command to upgrade the kubelet configurations of the worker node

kubeadm upgrade node

Step 3:  Drain the worker

Drain the worker plane node using the node name and make it unschedulable.

This command is used on the control plane:

 kubectl drain node01 --ignore-daemonsets 

Step 4: Upgrade Kubelet

Use the below command to upgrade kubelet to the new version

apt-mark unhold kubelet

apt-get install kubelet=1.33.5-1.1

apt-mark hold kubelet

Restart the service to make the changes

systemctl daemon-reload
systemctl restart kubelet

Uncordon the node so that node01 can be scheduled.

kubectl uncordon node01

After upgrading the worker node run the following command from the master node to verify if the nodes are upgraded to the new version

kubectl get nodes

You can see in the above image that the control-plane and worker have been upgraded to the new version 1.33.5

Conclusion

In this blog, we learned about upgrading the Kubernetes cluster.

I hope every step is easy to understand.