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–
- Upgrade the primary master node.
- Upgrading additional master nodes.
- 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–
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
[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
- 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-
- Upgrade the kubeadm tool.
- Use kubeadm to upgrade the node — sudo kubeadm upgrade node
- Drain the node and cordon it to be marked as unscheduable.
- Upgrade kubelet and kubectl for the worker node
- Restart the kubelet software
- Uncordon the nodes and make it available for the pods.
- 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.
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!! 🙂