Lab26 - Upgrading Kubernetes Cluster

Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

Lab: Upgrading Kubernetes Cluster

Introduction:
Note: -

• All containers are restarted after upgrade, because the container spec hash value is changed.
• You only can upgrade from one MINOR version to the next MINOR version, or between PATCH
versions of the same MINOR. That is, you cannot skip MINOR versions when you upgrade. For
example, you can upgrade from 1.y to 1.y+1, but not from 1.y to 1.y+2

1. Ensure that you have logged-in as root user with password as linux on kube-master node.
1.1 Let us view kubeadm configuration file

# kubectl get cm kubeadm-config -n kube-system -o yaml


Output:

Student Material – Do Not Re-distribute. For any queries contact:


[email protected] or https://www.linkedin.com/in/naushadpasha/
1.2 Let us verify the kubernetes version (Cluster)

# kubectl get nodes -o wide


Output:

1.3 Let us unlock the version, by executing the below command.

# dnf versionlock list


# dnf versionlock clear
Output:

1.4 Let us check any updates available

# kubeadm upgrade plan


Output:

Student Material – Do Not Re-distribute. For any queries contact:


[email protected] or https://www.linkedin.com/in/naushadpasha/
1.5 Let us Determine which version to upgrade to

# dnf list --showduplicates kubeadm --


disableexcludes=kubernetes
Output:

1.6 Let us upgrade master node (kube-master)

# dnf install -y kubeadm-1.19.4-0 --


disableexcludes=kubernetes
Output:

Student Material – Do Not Re-distribute. For any queries contact:


[email protected] or https://www.linkedin.com/in/naushadpasha/
1.7 Let us verify that the download works and has the expected version:

# kubeadm version
Output:

1.8 Let us drain master node (kube-master)

# kubectl drain kube-master --ignore-daemonsets


Output:

1.9 Let us apply the version as v1.19.4 to upgrade

# kubeadm upgrade apply v1.19.4


Output:

1.10 Let us uncordon the master, by executing the below command.


# kubectl uncordon kube-master
Output:

Student Material – Do Not Re-distribute. For any queries contact:


[email protected] or https://www.linkedin.com/in/naushadpasha/
2. Upgrade kubelet and kubectl
2.1 Let us upgrade kubelet and kubectl on master node (kube-master)

# dnf install -y kubelet-1.19.4-0 kubectl-1.19.4-0 --


disableexcludes=kubernetes
Output:

2.2 Let us restart the kubelet

# systemctl daemon-reload
# systemctl restart kubelet

# kubectl get nodes


Output:

Student Material – Do Not Re-distribute. For any queries contact:


[email protected] or https://www.linkedin.com/in/naushadpasha/
3. Upgrade worker nodes - (kube-node1) (kube-node2)
3.1 Let us drain the worker nodes (kube-node1) (kube-node2)

# kubectl drain kube-node1 --ignore-daemonsets


# kubectl drain kube-node2 --ignore-daemonsets
Output:

3.2 Ssh to kube-node1 to perform the upgrade operation


3.3 Let us unlock the version, by executing the below command.

# dnf versionlock list


# dnf versionlock clear
Output:

3.4 Upgrade kubeadm on kube-node1 worker node

# dnf install -y kubeadm-1.19.4-0 --


disableexcludes=kubernetes

Output:

Student Material – Do Not Re-distribute. For any queries contact:


[email protected] or https://www.linkedin.com/in/naushadpasha/
3.5 Upgrade the kubelet and kubectl on kube-node1 worker node:

# dnf install -y kubelet-1.19.4-0 kubectl-1.19.4-0 --


disableexcludes=kubernetes

Output:

3.6 Let us Restart the kubelet

# systemctl daemon-reload
# systemctl restart kubelet
3.7 Exit from the kube-node1
# exit

3.8 Let us uncordon the kube-node1

# kubectl uncordon kube-node1


Output:

3.9 Let us list the nodes

# kubectl get nodes


Output:

Student Material – Do Not Re-distribute. For any queries contact:


[email protected] or https://www.linkedin.com/in/naushadpasha/
3.10 Ssh to kube-node2 to perform the upgrade operation
3.11 Let us unlock the version, by executing the below command.

# dnf versionlock list


# dnf versionlock clear
Output:

3.12 Upgrade kubeadm on kube-node2 worker node

# dnf install -y kubeadm-1.19.4-0 --


disableexcludes=kubernetes

Output:

3.13 Upgrade the kubelet and kubectl on kube-node2 worker node:

# dnf install -y kubelet-1.19.4-0 kubectl-1.19.4-0 --


disableexcludes=kubernetes

Output:

Student Material – Do Not Re-distribute. For any queries contact:


[email protected] or https://www.linkedin.com/in/naushadpasha/
3.14 Let us Restart the kubelet

# systemctl daemon-reload
# systemctl restart kubelet

3.15 Exit from the kube-node2

# exit

3.16 Let us uncordon the kube-node1

# kubectl uncordon kube-node2


Output:

3.17 Let us list the nodes

# kubectl get nodes


Output:

Student Material – Do Not Re-distribute. For any queries contact:


[email protected] or https://www.linkedin.com/in/naushadpasha/

You might also like