Upgrade the Kubernets Kubeadm CLuster

How to Upgrade the Kubernetes Kubeadm Cluster

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

Upgrade Master Node

Switch to the root user and run the commands in the below steps to upgrade the master node.

Step 1: Download the Package and key for the package

To install a new version you have to download the package for the version. Use the below command to add the package

echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.29/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list

Now, run the below command to download the key for the package

curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.29/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg

Use the command below to update and list available kubeadm version

apt update
apt-cache madison kubeadm

Step 2: Install the new version

Run the below command to install the new version of kubeadm

apt-mark unhold kubeadm && \
apt-get update && apt-get install -y kubeadm='1.29.1-*' && \
apt-mark hold kubeadm

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

kubeadm version

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

Upgrade the Kubernetes Kubeadm Cluster: kubeadm version details

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.29.1

Step 4: Upgrade Kubelet and Kubeclt

Now, all the components for the control node are upgraded to the new version, drain the master node using the command given below to

kubectl drain master-node --ignore-daemonsets

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

apt-mark unhold kubelet kubectl && \
apt-get update && apt-get install -y kubelet='1.29.1-*' kubectl='1.29.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 master-node

To verify the node use the command

kubectl get nodes

You can see the master node is upgraded to version 1.29.1.

Upgrade the Kubernetes Kubeadm Cluster: master node is upgraded to version 1.29.1

Upgrade Worker Node

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

Step 1: Download the Package and key for the package

To install a new version you have to download the package for the version. Use the below command to add the package

echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.29/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list

Now, run the below command to download the key for the package

curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.29/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg

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-mark unhold kubeadm && \
apt-get update && apt-get install -y kubeadm='1.29.1-*' && \
apt-mark hold kubeadm

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

kubeadm upgrade node

Step 3: Upgrade Kubelet and Kubeclt

Use the below command to upgrade kubelet and kubeclt to the new version

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

Restart the service to make the changes

systemctl daemon-reload
systemctl restart kubelet

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
master node is upgraded to version 1.29.1: both nodes are upgraded to the new version

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

Conclusion

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

I hope every step is easy to understand.

Upgrade the Kubernets Kubeadm CLuster

Other Interesting Blogs

Leave a Comment

Share via
Copy link
Powered by Social Snap