Upgrading a K8S platform: Step 02 - commands and actions
- Practical application of the upgrade process after the theory in Step 01.
- Cluster control, updating the CSI (including CPI), and then the CNI.
- Node processing: containerd, OS, K8S components.
- Updating add-ons such as Traefik or Cert-Manager.
Introduction
After discussing the theory, it's time to move on to practice. If you haven't read the previous article describing the logic of updating a Vanilla Kubernetes platform, I encourage you to do so before starting this one.
It is very important to prepare your upgrade process and to identify in advance the order and logic of the tasks to be performed. You need to know all the target versions and ensure compatibility matrices before, during, and after the update.
Make sure you have all the necessary backups, starting with the etcd database and the data for your applications hosted on the cluster. And most importantly, know how to restore them!
Before we begin, I want to clarify that the commands and methods described here are specific to updating my personal Kubernetes cluster, which I explain in detail through a dedicated cookbook.
It is very likely that the procedure will change from one cluster to another; it all depends on the additional components used and the advanced configuration of each. Nevertheless, I propose a modular approach, directly derived from my previous article. You should normally be able to use it as inspiration for your own architectures.
If you are using a Kubernetes distribution, such as OpenShift, I recommend that you contact the vendor of your solution. The advantage of K8S distributions is that they simplify upgrade operations and often include automation of upgrade tasks.
The same applies to managed cloud solutions. However, in this article, you can find a description of some components that you might have added to your basic configuration (traefik, cert-manager....).
In my example, I will be upgrading from version 1.29.4 of K8S to version 1.xx.x, incorporating all the additional components I have added. It is possible that as Kubernetes evolves, the upgrade procedure may change. In that case, I will try to update the article.
As it stands, I will primarily use kubeadm, since that is what I used to deploy my cluster. If you have set up a vanilla K8S cluster without kubeadm (congratulations), then you need to follow a different procedure. If you have deployed your cluster with me, then...
I will not go into the details of the compatibility matrices. All these elements are explained to you in the dedicated article .
Cluster control
The first thing to do is to ensure that the cluster being updated is fully functional. Check the status of the nodes using the command kubectl get node and make a list of as many of your K8S objects as possible, starting with the pods in each namespace.

Click the image to enlarge.
For example, if you have sufficient permissions, you can use the command kubectl get all -A
Focus on the kube-system namespace using the command kubectl get pod -n kube-system
It is necessary to have a healthy and error-free cluster as a starting point before beginning the update operations.
Updating the Container Storage Interface (CSI) (including CPI)
Processing vSphere CPI/CSI
The first component to update is the CSI (Container Storage Interface) vSphere driver. Since this driver relies on the same vendor's CPI (Cloud Provider Interface), you also need to apply its update. For those who are not familiar with CPI/CSI, you can find more information at this level.
You need to retrieve the latest version of the vsphere-cloud-controller-manager.yaml file, which is associated with the deployment of the CPI driver, from the project repository.
This file, like during its installation on the cluster, must be customized to include the connection elements for vCenter.

Click the image to enlarge.
Therefore, do not forget to change the elements in the file. Since I use Ansible to deploy my prerequisites when setting up a new cluster, I make sure to update the Jinja template that I use with this new version of the yaml.
Then you can apply the update using the command kubectl apply -f vsphere-cloud-controller-manager.yaml

Click the image to enlarge.
We verify that the pods associated with vsphere-cloud-controller-manager restart correctly using the command kubectl get pod -n kube-system -o wide. We should find one pod per control plane.

Click the image to enlarge.
Next, we proceed with the YAML file associated with the CSI, vsphere-csi-driver.yaml, which can also be retrieved from the project repository.
The advantage is that it does not need to be modified before execution. (For those who want to see the details of its original installation, the procedure is described here). You can then apply it using the command kubectl apply -f vsphere-csi-driver.yaml

Click the image to enlarge.
We ensure that everything went correctly with the command kubectl get pod -n vmware-system-csi

Click the image to enlarge.
Note: Regarding the CPI and CSI, at the time of writing this article, VMware had the good idea to change the hosting of some images called in the YAML files recently retrieved. However, they did not change the new URL of the container repositories.
Indeed, CSI drivers, regardless of their vendors, are intended to be centralized in the global registry registry.k8s.io, which was not yet the case for vSphere.
This has consequences because the images can no longer be retrieved, and the pods remain in an error state. I don't know what it will be like when you read this article, but I had to manually modify the URLs in the retrieved YAML files. If you wish, they are available in my GitHub repository at this location (v1.31 for the CPI [complete access to vCenter], v3.3.1 for the CSI).
Another small tip: if you want to minimize the risk of a pod failing to start because the image(s) it uses are no longer available, you can use the imagePullPolicy: option associated with the container in the pod.
In the case of the CSI, the option is always, which means that even if the image is available locally in the cache on the node, K8S will absolutely want to retrieve it online.
By changing the option to IfNotPresent:, the image will only be retrieved online if it is not found in the cache. This can limit the impact of having an image unavailable online, but it also exposes you to running with a local image that is not up-to-date and different from the one in the repository. It's up to you.
In addition to the CSI, if you have enabled snapshot support, as I explained here, you will also need to run the deploy-csi-snapshot-components.sh script from the repository again to ensure that there are no updates needed at this level either.
Once the vSphere CSI is up to date (with its CPI dependency), we can move on to the other CSIs in the cluster, specifically NFS and SMB.
Processing SMB and NFS CSI
The logic is the same in both cases. As I described in the article dedicated to this topic, I used helm to deploy these.
Therefore, you only need to update the helm repositories using the command helm repo update
Then, run the command helm upgrade along with the original installation parameters, specifying the target version of the CSI driver, which can be found in the repository
helm repo update
helm upgrade csi-driver-nfs csi-driver-nfs/csi-driver-nfs --namespace kube-system --version vNew
The same command applies to the SMB CSI, using the version available in the associated repository.
helm repo update
helm upgrade csi-driver-smb csi-driver-smb/csi-driver-smb --namespace kube-system --version vNew
Updating the Container Network Interface (CNI)
We can now move on to the CNI (Container Network Interface). I am using Cilium. You can find details about its installation here.
As with the NFS and SMB CSIs, I used helm. Therefore, we run the command helm upgrade, along with the original installation instructions (and the original configuration file), specifying the target version (the versions can be found in the project repository).
helm upgrade --version vNew --namespace=kube-system cilium cilium/cilium --values=./cilium-values.yaml --set hubble.relay.enabled=true --set hubble.ui.enabled=true
It is possible that errors will appear during the first attempt... we will see this later with Traefik, but sometimes the syntax of the configuration files used by Helm can vary from one version to another.
This is the case in my example, where it is now required to include the kubeProxyReplacement concept.

Click the image to enlarge.
You must then correct the file passed as a parameter and rerun the command to achieve the correct result.

Click the image to enlarge.
We verify that the CNI is operational by ensuring that the internal pod DNS within the container are up kubectl get pod -n kube-system

Click the image to enlarge.
We also ensure that all nodes are in the ready state kubectl get node

Click the image to enlarge.
Node processing
We can now move on to updating the container runtime, the operating system, and Kubernetes itself.
To do this, we will need to operate node by node, putting the server being operated on into maintenance mode.
We start with the first control plane. To put a Kubernetes node into maintenance mode, we use the command kubectl drain followed by the name of the node.
However, without additional attributes, it is very likely that Kubernetes will not accept your request. In fact, the orchestrator attempts to apply all the constraints that may have been requested during the execution of the pods.
To put a node into maintenance mode, each pod must be evacuated to another node. This is not always the case, depending on the labels, taints, and resources of the cluster.
Therefore, you need to complete the command with the following arguments:
kubectl drain --ignore-daemonsets --delete-emptydir-data nodename --force --disable-eviction
If you run the command kubectl get node, you should now have your first control plane in a SchedulingDisabled state.

Click the image to enlarge.
Updating the container runtime
We will start with the container runtime, which in my case is containerd. Its installation was performed via Ansible, directly from the binaries obtained from the official website, and not from the OS repository. (The details of the installation and the Ansible files can be found here).
For my example, this will involve updating my Ansible variable that specifies the version of containerd to retrieve, and then specifically re-running the installation tasks via the Ansible tag, limiting the deployment to the node currently in maintenance.

Click the image to enlarge.
I will not go into detail on this point; you can find all the necessary information at that level.
In practice, this is done using the following command:
ansible-playbook playbooks/playbook_deploy_k8s.yml --ask-vault-pass -t role_k8s_deploy.containerd -l nodename

Click the image to enlarge.
This is the advantage of having used Ansible from the beginning for the cluster installation. It simplifies a number of upgrade operations later on. You can easily track the evolution of the cluster by storing the Ansible files in Git.
To check that the container engine is up to date, you can connect as root to the node and run the following commands:
systemctl status containerd
containerd -version

Click the image to enlarge.
Also note that from version 1.31, Kubernetes requires support for cgroup v2 at the runtime level. You can therefore take this opportunity to verify whether this is indeed the case, in preparation for the future, using the command:
mount | grep cgroup

Click the image to enlarge.
Operating system update
Now it's time to update the operating system itself. The OS update depends on the family of OS you are using. In my case, it is specific because my cluster is based on PhotonOS, and the tdnf manager is used.
Furthermore, I did not use the default OS repositories to deploy Kubernetes. Therefore, I need to ensure that I do not install any base packages for certain components and exclude all applications that I may have deployed outside of the default repositories (such as containerd, which was previously upgraded).
To do this, the command is as follows:
tdnf -y update --exclude="kubeadm,kubectl,kubelet,kubernetes-cni,containerd"

Click the image to enlarge.
As a precaution, at the end of the update process, I restart the OS.
Updating Kubernetes components
We can now focus on Kubernetes itself.
With each major release of K8S, for example, from 1.29 to 1.30, the default repositories of the project are updated.
Since these are the repositories that we use, and which were added to those of the OS during the system preparation, it will be necessary to modify them so that they correspond to the target version of K8S.
Again, we use Ansible, as this is how they were initially deployed. Simply update the Ansible variable, since the repository has been templated.

Click the image to enlarge.
By postponing only the tasks specific to configuring the repository on the node being maintained, we obtain an updated repository.
yml --ask-vault-pass -t role_k8s_deploy. repos -l nodenameansible-playbook playbooks/playbook_deploy_k8s.

Click the image to enlarge.
If you are not using Ansible, it is up to you to perform this operation directly.
[kubernetes]
name=Kubernetes
baseurl=https://pkgs.k8s.io/core:/stable:/v1.30/rpm/
enabled=1
gpgcheck=1
gpgkey=https://pkgs.k8s.io/core:/stable:/v1.30/rpm/repodata/repomd.xml.key
exclude=kubelet kubeadm kubectl cri-tools kubernetes-cni
It is now possible to update the core components of the cluster. This operation is common to all Vanilla clusters deployed with kubeadm.
kubeadm, in particular, is the first component to be updated. To do this, become root on the node being maintained and then upgrade the associated binary.
tdnf update kubeadm-1.xx.x (the package manager needs to be adapted depending on the OS)

Click the image to enlarge.
You should always specify the version. You can never be completely sure that your package manager will select a different version. At least by specifying the version, you ensure that you are going where you want to go.
Once kubeadm is up to date, still as root, you can run the upgrade command:
kubeadm upgrade apply 1.xx.x

Click the image to enlarge.
Everything should happen automatically. kubeadm detects your version of K8S and will proceed to retrieve the k8s images corresponding to its version and redeploy everything.
This may take some time on the control plane.

Click the image to enlarge.
Be careful if you have customized the default YAML files of the K8S components retrieved by kubeadm during cluster initialization; there is a high chance that these modifications will be lost. You will need to reapply them later.
Once we have regained control, we can update the rest of the Kubernetes binaries, namely the kubelet agent and kubectl, always specifying the version.
tdnf update kubelet-1.xx.x
tdnf update kubectl-1.xx.x

Click the image to enlarge.

Click the image to enlarge.
For the kubelet agent, it is necessary to restart it, after first reloading systemd.
systemctl daemon-reload
systemctl restart kubelet

Click the image to enlarge.
From this step onwards, we can switch back to our standard user and take the node out of maintenance mode using the following command:
kubectl uncordon nodedname

Click the image to enlarge.
If we check the status of the nodes with the command kubectl get node, not only is our node now in a "ready" state, but we can see that its version is now 1.xx.x

Click the image to enlarge.
To avoid being in a situation where the nodes are not on the same release, we need to proceed with the other servers.
The tasks are exactly the same as for the first control plane:
- We put the node into maintenance mode:
kubectl drain --ignore-daemonsets --delete-emptydir-data nodename --force --disable-eviction - We update containerd:
ansible-playbook playbooks/playbook_deploy_k8s.yml --ask-vault-pass -t role_k8s_deploy.containerd -l nodename - We update the operating system:
tdnf -y update --exclude="kubeadm,kubectl,kubelet,kubernetes-cni,containerd" - We restart the node
- We update the repositories:
ansible-playbook playbooks/playbook_deploy_k8s.yml --ask-vault-pass -t role_k8s_deploy.repos -l nodename - We update kubeadm:
tdnf update kubeadm-1.xx.x - We start the K8S upgrade:
kubeadm upgrade node. There is a slight variation here for the other nodes; it is no longer necessary to specify the version to be updated. - We update the kubelet agent by restarting it:
tdnf update kubelet-1.xx.xsystemctl daemon-reloadsystemctl restart kubelet- We update kubectl (control plane only)
tdnf update kubectl-1.xx.x - We take the node out of maintenance mode:
kubectl uncordon nodename
The process should first be carried out on all control planes, and then on the worker nodes. Note that for the worker nodes, updating kubectl is not necessary. You will also notice that updating the worker nodes is much faster.
At the end of the operation, we should have all our nodes at the target version. kubectl get node

Click the image to enlarge.
Of course, do not forget to upgrade kubectl on your workstation as well, so that it also corresponds to the new release. To do this, you need to retrieve the binary corresponding to the operating system of your client machine.

Click the image to enlarge.
Updating add-ons
At this stage, the cluster is finally up to date, with all system components included.
We could stop there, but we will finish with the two additional solutions deployed on the cluster.
Updating Traefik
We start with Traefik; its usage and installation are detailed here.
Its update is relatively simple, as it also uses helm.
In my case, during the installation, I used a specific configuration file. This file was templated to be generated by Ansible and uses a variable indicating the target version of Traefik.
Initially, I need to update this variable and redeploy my configuration file using the following Ansible instruction:

Click the image to enlarge.
ansible-playbook playbooks/playbook_deploy_k8s.yml --ask-vault-pass -t role_k8s_deploy.traefik

Click the image to enlarge.
Feel free to read my dedicated article about Traefik for a better understanding of this section.
Once the file is updated, I can use it in conjunction with the old helm instructions, but with the keyword upgrade
However, be aware that Traefik sometimes tends to modify its logic as versions change.
Helm is supposed to simplify updates, but in this case, and because I rely on a specific configuration file, I discovered that a keyword in that file, namely image, is no longer interpreted by my target version of Traefik.

Click the image to enlarge.
I had to go back to using templates to account for this change, and then redeploy my configuration file with Ansible. Finally, I ran the helm upgrade command again, first to update my Traefik instance in the LAN.
helm upgrade traefik-lan traefik/traefik -f traefik-config-lan.yaml -n inf-traefik-lan --set nodeSelector.traefik-lan=yes --set tolerations[0].key=node-role.kubernetes.io/control-plane --set tolerations[0].operator=Exists --set tolerations[0].effect=NoSchedule
Then, to update my Traefik instance in the DMZ
helm upgrade traefik-dmz traefik/traefik -f traefik-config-dmz.yaml -n inf-traefik-dmz --set nodeSelector.traefik-dmz=yes --set tolerations[0].key=node-role.kubernetes.io/worker-dmz --set tolerations[0].operator=Exists --set tolerations[0].effect=NoSchedule

Click the image to enlarge.
(Feel free to review my Kubernetes architecture for a better understanding of this point).
This time, Traefik updated successfully.
You can check the status of the pods kubectl get pod -n inf-traefik-lan -o wide / kubectl get pod -n inf-traefik-dmz -o wide, as well as the administration URL to see the new version appear.

Click the image to enlarge.

Click the image to enlarge.

Click the image to enlarge.
This update highlights an important point: be careful about functional changes in addons and customized objects.
Besides checking compatibility matrices, you need to carefully study the impact of updates, such as those for Traefik (like Cilium). The vendor may decide to modify not only its installation attributes but also the definition of the custom objects it adds to the Kubernetes API.
Traefik has already made this type of modification, and you might end up with a functional installation, but with orphaned objects that Traefik, in its new version, no longer knows how to handle.
At that point, you need to redeploy all the affected objects that you wrote based on the old definition provided with the previous version of Traefik.
Fortunately, when the vendor makes this choice, they often provide a transition period during which both the old and new definitions of the objects are taken into account for a certain number of releases... but eventually, this backward compatibility ends, and you need to modify your objects. Therefore, think about it as early as possible and carefully analyze the release notes.
Updating Cert-Manager
Now it's cert-manager's turn.
This is one of the simplest methods, as it also uses Helm and doesn't require a custom configuration file. Feel free to read the associated article about its deployment.
The update process involves using the command helm upgrade, specifying the original options and the target version to deploy (see the project repository to select the version).
helm upgrade cert-manager jetstack/cert-manager --namespace inf-cert-lan --version vx.xx.x --set crds.enabled=true

Click the image to enlarge.
You can ensure everything is OK with the following command: kubectl get pod -n inf-cert-lan -o wide

Click the image to enlarge.
Conclusion
The cluster, its components, and its add-ons are now up to date. This article aims to highlight the potential complexity, but manageable aspects, of updating a vanilla K8S cluster.
As long as you are organized and maintain a regular update schedule (at least twice a year), these operations remain achievable within a maintenance program.
Of course, with significant infrastructure, including multiple clusters and numerous nodes, it becomes vital to automate and industrialize all the operations I have described here.
Even in my case, with my small cluster, I would benefit from implementing more automation. Currently, I only use Ansible very little. You can find many examples online of people who have gone much further in updating a cluster using tools like Ansible.
In any case, knowing how to break down your updates and master the update process for all components will increase your maturity and skills with each iteration.
You will be better able to understand what is happening within your cluster. You gradually gain control of the role of each component, and if incidents occur, you will be more capable of understanding and resolving them.
It is undeniable that distributions like OpenShift, or the use of managed clusters in the cloud, greatly simplify update operations. However, you are not immune to problems, and in such cases, you rely exclusively on the vendor's support. Furthermore, you may be subject to update pressure, especially in the cloud, where you often have no choice regarding the timing of updates.
Like hackers (😊), there are no good or bad solutions. It is even quite possible to have different types of K8S clusters. Some vanilla on-premise clusters, and others managed in the cloud. Or multiple OpenShift clusters hosted in different environments, public or private.
It's up to you to choose the solution that best suits your needs and meets the requirements and skills of your teams. But don't necessarily rule out a vanilla cluster out of fear of upgrades... if you build a consistent architecture that is understood by your admin/ops/dev teams (Kubernetes should not be the exclusive domain of one team), there's no reason why your update operations can't ultimately be completed with a simple launch of an Ansible playbook or execution of a Jenkins pipeline.