Use context: kubectl config use-context k8s-c3-CCC
Your coworker said node cluster3-node2
is running an older Kubernetes version and is not even part of the cluster. Update Kubernetes on that node to the exact version that’s running on cluster3-controlplane1
. Then add this node to the cluster. Use kubeadm for this.
Upgrading Kubernetes and Adding a Node to Your Cluster
Upgrading your Kubernetes cluster and adding new nodes are essential tasks for maintaining a healthy and scalable environment. In this guide, we’ll walk through upgrading Kubernetes on a control plane node and adding a new node to your cluster using kubeadm
.
Step 1: Checking the Current Kubernetes Version
Before starting the upgrade, it’s important to verify the current version of Kubernetes running on your nodes. Run the following command to check the version:
1 2 3 |
kubectl get node |
Example output:
1 2 3 4 5 6 7 |
NAME STATUS ROLES AGE VERSION cluster3-controlplane1 Ready control-plane 3h28m v1.30.1 cluster3-node1 Ready <none> 3h23m v1.30.1 |
Here, we see that both nodes are running Kubernetes version v1.30.1
.
Step 2: Preparing the Node for Upgrade
Next, SSH into the node that needs to be upgraded. In this example, we’ll work with cluster3-node2
:
1 2 3 |
ssh cluster3-node2 |
Check the versions of kubeadm
, kubectl
, and kubelet
installed on the node:
1 2 3 4 5 |
kubeadm version kubectl version kubelet --version |
If the tools are outdated, upgrade them by running:
1 2 3 4 |
apt update apt install kubectl=1.30.1-1.1 kubelet=1.30.1-1.1 |
After upgrading, restart the kubelet service:
1 2 3 |
service kubelet restart |
Step 3: Adding the Node to the Cluster
To add cluster3-node2
to the cluster, we need to generate a join command from the control plane node. SSH into the control plane node:
1 2 3 |
ssh cluster3-controlplane1 |
Generate a TLS bootstrap token and the join command:
1 2 3 |
kubeadm token create --print-join-command |
This command will output something like this:
1 2 3 |
kubeadm join 192.168.100.31:6443 --token zodhba.wlxmtvumtjpgaevg --discovery-token-ca-cert-hash sha256:6819708bfec2336183a68138d680ea7bf81dfbf9a57b3fca1c51bdc2f4fc6e99 |
Now, return to cluster3-node2
and execute the join command:
1 2 3 4 5 |
ssh cluster3-node2 kubeadm join 192.168.100.31:6443 --token zodhba.wlxmtvumtjpgaevg --discovery-token-ca-cert-hash sha256:6819708bfec2336183a68138d680ea7bf81dfbf9a57b3fca1c51bdc2f4fc6e99 |
This will join the node to the cluster, and you should see confirmation that the node has successfully joined.
Step 4: Verifying the Node Status
Finally, check the status of the node by running kubectl get nodes
from the control plane:
1 2 3 |
kubectl get node |
After a short time, the node should appear as Ready:
1 2 3 4 5 6 7 8 |
NAME STATUS ROLES AGE VERSION cluster3-controlplane1 Ready control-plane 3h34m v1.30.1 cluster3-node1 Ready <none> 3h29m v1.30.1 cluster3-node2 Ready <none> 27s v1.30.1 |
This indicates that cluster3-node2
is now successfully part of the Kubernetes cluster and running the upgraded version of Kubernetes.
Conclusion
In this guide, we covered how to upgrade Kubernetes on a control plane node and add a new node to the cluster. Keeping your cluster up to date ensures compatibility with new features, improved security, and better overall performance. By following these steps, you can maintain a robust and scalable Kubernetes environment.