Kubernetes Version Upgrade
When upgrading Kubernetes version, each minor version between the current and target versions (e.g., from 1.25 to 1.26, then from 1.26 to 1.27, etc.) must be upgraded sequentially.
Kubernetes: v1.18 → Current version, v1.30 → Target version
Required Files
v1.18 - v1.30 → Kubectl, kubeadm, kubelet files
Installing once is sufficient when transitioning from Kubernetes 1.18 to 1.19. Installation is not necessary in versions 1.19 and above.
When transitioning to Kubernetes 1.24 version, transition to containerd usage should be made. Containerd should be 1.6+ and docker should be removed.
Version Upgrade
The version upgrade process consists of "1.18-1.19", "1.20-1.23", and "1.24-1.30" sections. In each section, the version upgrade process and solutions to possible errors are addressed.
1.1) Upgrade from 1.18 to 1.19
Very Important
A flannel issue may occur when transitioning from 1.18 to 1.19. Check node status with the following command.
kubectl get nodes
If node status is NotReady, check logs on the relevant server with the following command.
journalctl -xeu kubelet
Solution: Transfer the flannel file from any (master or worker) server to the server you are upgrading using scp command.
scp /opt/cni/bin/flannel <USERNAME>@<NODE_IP>:/opt/cni/bin
When you check the node status, you should see "READY".
Upgrade for Control Plane (Master) Node
Switch to the server that is Master(control-plane) and apply the following steps.
Check kubeadm, kubelet, and kubectl versions before starting the upgrade process:
kubeadm version
kubelet --version
kubectl version --client
Remove package hold for Kubeadm:
sudo apt-mark unhold kubeadm
Go to the folder where you extracted the file you downloaded from fss.apinizer.com:
cd 1.19.3
Install the .deb extension kubeadm file found inside:
sudo dpkg -i kubeadm_1.19.3-00_amd64.deb
sudo apt-mark hold kubeadm
The drain command below puts the specified Kubernetes node in maintenance mode and transfers pods to other nodes. If you do not have an alternative master node for your Master (control-plane) node, this command will cause system interruption. You may not apply this operation for clusters with a single node.
kubectl drain <MASTER_NODE_NAME> --ignore-daemonsets
Upgrade Kubeadm to the installed v1.19.3 version with upgrade command:
# For Master (control-plane):
# change the version part for each version
sudo kubeadm upgrade apply v1.19.3
You should see a message indicating that the operation was successful as output on the screen.
kubectl uncordon <MASTER_NODE_NAME>
sudo apt-mark unhold kubelet kubectl
sudo dpkg -i kubelet_1.19.3-00_amd64.deb
sudo dpkg -i kubectl_1.19.3-00_amd64.deb
sudo apt-mark hold kubelet kubectl
systemctl daemon-reload
systemctl restart kubelet
To view the version of the Master (control-plane) node:
kubectl get nodes
Check that the upgrade operation was successful as the version.
Upgrade for Worker Node
Worker node version upgrade is also performed with similar steps.
The drain command below puts the specified Kubernetes node in maintenance mode and transfers pods to other nodes. If you do not have an alternative node for your Worker node, this command will cause system interruption. You may not apply this operation for clusters with a single worker node.
The command is run on the master(control-plane) server and initiates maintenance and pod evacuation for the worker node.
kubectl drain <WORKER_NODE_NAME> --ignore-daemonsets
Switch to the server where the worker node is located and perform kubeadm upgrade operation.
Go to the folder where you extracted the file you downloaded from fss.apinizer.com:
sudo apt-mark unhold kubeadm
sudo dpkg -i kubeadm_1.19.3-00_amd64.deb
sudo apt-mark hold kubeadm
sudo kubeadm upgrade node
sudo apt-mark unhold kubelet kubectl
sudo dpkg -i kubelet_1.19.3-00_amd64.deb
sudo dpkg -i kubectl_1.19.3-00_amd64.deb
sudo apt-mark hold kubelet kubectl
systemctl daemon-reload
systemctl restart kubelet
Run the following command on the master(control-plane) node to make the node available again:
kubectl uncordon <WORKER_NODE_NAME>
To view the version of the Worker node:
kubectl get nodes
1.2) Upgrade from 1.20 to 1.23
Versions 1.20-1.23 are updated one by one. The steps above are repeated for each version.
1.3) Upgrade from 1.24 to 1.30
Very Important
When transitioning to Kubernetes 1.24 version, transition to containerd usage should be made instead of Docker. Containerd should be 1.6+ and docker should be removed.
Versions 1.24-1.30 are updated one by one. The steps above are repeated for each version. However, containerd installation must be done when transitioning to 1.24.
Containerd Installation (for Kubernetes 1.24)
When transitioning to Kubernetes 1.24 version, transition to containerd usage should be made instead of Docker.
You can download the necessary file for Containerd installation.
See the relevant documentation pages for Containerd installation and Docker transition operations.