Upgrading a Kubernetes Cluster using kubeadm tool

Filed Under: Random
Upgrading A Kubernetes Cluster Using Kubeadm Tool

Hello, readers! This article talks about Upgrading a Kubernetes Cluster using the kubeadm tool with a detailed explanation.

So, let us begin!! 馃檪


Upgradation of a Kubernetes Cluster

Once we have the cluster setup and running, it is always essential that we upgrade the Kubernetes version from time to time to have the newly introduced features as a part of our cluster.

The kubeadm tool can be helpful to upgrade the cluster easily with some minimal steps. For the same, we need to be sure that the Kubernetes cluster that we plan to upgrade is up from the kubeadm tool itself.

The entire upgrade plan of the cluster has three steps–

  1. Upgrade the primary master node.
  2. Upgrading additional master nodes.
  3. Upgrade the worker nodes.

Let us have a look at the entire upgrade plan in a step-by-step manner.


1. Upgrading master nodes

At first, the major task is to find the latest patch that we can upgrade to using the below command-

apt update
apt-cache madison kubeadm

Once the version to upgrade to is finalized, the next step is to upgrade kubeadm on the node. Yes, the upgrade should happen on one node at a time.

Upgrading the kubeadm tool —

In this example, we are upgrading kubeadm to version 1.22.x-00 effectively.

apt update && \
apt install -y --allow-change-held-packages kubeadm=1.22.x-00

Let us now check if the kubeadm tool has picked up the right version–

kubeadm version

Now, with the below command, we can check the versions to which the cluster can be upgraded to –

kubeadm upgrade plan

This gives us a table defining the versions available. Choose the suitable version and apply the below command to begin the upgrade on the master node-

sudo kubeadm upgrade apply v1.22.x

Output–

[upgrade/successful] SUCCESS! Your cluster was upgraded to "v1.22.x". Enjoy!

[upgrade/kubelet] Now that your control plane is upgraded, please proceed with upgrading your kubelets if you haven't already done so.

Upgrading other master nodes

Once we are done with the primary master node, we need to apply the below rules to upgrade other master nodes-

sudo kubeadm upgrade apply
  1. Drain the node, so that all the pods scheduled on it are evicted and it is marked as unschedulable.
kubectl drain <node-to-drain> --ignore-daemonsets

2. Upgradation of kubectl and kubelet

apt update && \
    apt install -y --allow-change-held-packages kubelet=1.22.x-00 kubectl=1.22.x-00

3. Post the upgrade, we need to restart the kubelet to pick up the latest configuration-

sudo systemctl daemon-reload
sudo systemctl restart kubelet

4. Once the process of upgrade gets completed, it is time to uncordon the node to mark it as scheduled for the pods.

kubectl uncordon <node-to-drain>

2. Upgrading worker nodes

The upgrade of worker nodes can happen one at a time or a few at a time. But, we need to be sure that the minimum number of nodes to run the workloads is up and running.

Rest the process of upgrade is the same following the below steps-

  1. Upgrade the kubeadm tool.
  2. Use kubeadm to upgrade the node — sudo kubeadm upgrade node
  3. Drain the node and cordon it to be marked as unscheduable.
  4. Upgrade kubelet and kubectl for the worker node
  5. Restart the kubelet software
  6. Uncordon the nodes and make it available for the pods.
  7. Finally, verify the status of the node using kubectl get nodes command.

The above steps can be repeated for all the worker nodes one by one for the upgrade.


Conclusion

By this, we have approached the end of this topic. Feel free to comment below, in case you come across any questions.

For more such posts related to Docker and Kubernetes, Stay tuned with us.

Till then, Happy Learning!! 馃檪

Leave a Reply

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

close
Generic selectors
Exact matches only
Search in title
Search in content