Upgrade Kubernetes Version
6 minute read
Upgrading a Kubernetes cluster
Upgrading a Kubernetes cluster is essential to maintain security, stability, and compatibility.Like Kubernetes itself, we adhere to the version skew policy and only allow upgrades between releases that differ by a single minor version. This ensures compatibility between components, reduces the risk of instability, and keeps the cluster in a supported and secure state.
For more information about the Version Skew Policy, see the official Kubernetes documentation:
Click here
Use the following steps to upgrade the Kubernetes version of a cluster.
Kubernetes Version Upgrade Process:
Prerequisites
KOSI Login Recommendation
Before performing any action with kubeopsctl, it is recommended to do a login with kosi.
Refer to the official KOSI documentation for details
here.
1. Pull required KOSI packages on your ADMIN
If you do not specify a parameter, the Kubernetes version 1.32.2 will be pulled.
With parameter --kubernetesVersion 1.34.1 you can pull an older Kubernetes version.
Available Kubernetes versions are
1.32.2
,
1.32.3
,
1.32.9
.
1.32.10
.
1.33.3
.
1.33.5
.
1.34.1
.
kubeopsctl pull --kubernetesVersion <x.xx.x>
2. Change your target version inside the cluster-values
3. Start the upgrade
kubeopsctl apply -f cluster-values.yaml
Example 1 - Upgrade all nodes in the cluster to a specific version
In this example, a cluster is upgraded from Kubernetes version v1.33.5 to v1.34.1.
1. Pull required KOSI packages on your ADMIN
Pull the kubernetes v1.34.1 packages on your ADMIN machine.
kubeopsctl pull --kubernetesVersion 1.34.1
2. Update the target version in cluster-values.yaml
Adjust your cluster-values.yaml according to the example below. Make sure you set:
- The current Kubernetes version in
kubernetesVersion. - The target Kubernetes version in the
kubeVersionfield of each node.
# file cluster-values.yaml
apiVersion: kubeops/kubeopsctl/cluster/beta/v1
imagePullRegistry: registry.kubeops.net/kubeops/kubeops
airgap: true
clusterName: myCluster
clusterUser: root
kubernetesVersion: 1.33.5 # -> actual version
kubeVipEnabled: false
virtualIP: 10.2.10.110
firewall: nftables
pluginNetwork: calico
containerRuntime: containerd
kubeOpsRoot: /home/myuser/kubeops
serviceSubnet: 192.168.128.0/17
podSubnet: 192.168.0.0/17
debug: true
systemCpu: 250m
systemMemory: 256Mi
packageRepository: local
changeCluster: true # -> important! Needs to be set for an upgrade
zones:
- name: zone1
nodes:
- name: demo-controlplane01
iPAddress: 10.2.10.110
type: controlplane
kubeVersion: 1.34.1 # -> target version
- name: demo-worker01
iPAddress: 10.2.10.210
type: worker
kubeVersion: 1.34.1 # -> target version
- name: zone2
nodes:
- name: demo-controlplane02
iPAddress: 10.2.10.120
type: controlplane
kubeVersion: 1.34.1 # ->target version
- name: demo-worker02
iPAddress: 10.2.10.220
type: worker
kubeVersion: 1.34.1 # -> target version
- name: zone3
nodes:
- name: demo-controlplane03
iPAddress: 10.2.10.130
type: controlplane
kubeVersion: 1.34.1 # -> target version
- name: demo-worker03
iPAddress: 10.2.10.230
type: worker
kubeVersion: 1.34.1 # -> target version
2. Validate your values and upgrade the cluster
After cluster-values.yaml is updated, review all values carefully.
When you are ready, start the upgrade process:
kubeopsctl apply -f cluster-values.yaml
Example 2 - Tranche upgrade of zones to a specific version
In this example, the cluster is upgraded in tranches. The order is:
- zone1 (because it contains the initial control plane node),
- then zone3,
- and finally zone2.
zone1, because zone1 contains the initial control plane node.
1. Pull required KOSI packages on your ADMIN
Pull the kubernetes v1.33.5 packages on your ADMIN machine.
kubeopsctl pull --kubernetesVersion 1.33.5
2. Adjust your cluster-values in zone1
Adjust your cluster-values.yaml according to the example below. Make sure you set:
- The current Kubernetes version in
kubernetesVersion. - The target Kubernetes version only for the nodes in
zone1. In the snippet below, onlyzone1is configured with the target version.
cluster-values.yaml.
# file cluster-values.yaml
apiVersion: kubeops/kubeopsctl/cluster/beta/v1
imagePullRegistry: registry.kubeops.net/kubeops/kubeops
airgap: true
clusterName: myCluster
clusterUser: root
kubernetesVersion: 1.32.2 # -> actual version
kubeVipEnabled: false
virtualIP: 10.2.10.110
firewall: nftables
pluginNetwork: calico
containerRuntime: containerd
kubeOpsRoot: /home/myuser/kubeops
serviceSubnet: 192.168.128.0/17
podSubnet: 192.168.0.0/17
debug: true
systemCpu: 250m
systemMemory: 256Mi
packageRepository: local
changeCluster: true
zones:
- name: zone1
nodes:
- name: demo-controlplane01
iPAddress: 10.2.10.110
type: controlplane
kubeVersion: 1.33.5 # -> target version
- name: demo-worker01
iPAddress: 10.2.10.210
type: worker
kubeVersion: 1.33.5 # -> target version
- name: zone2
nodes:
- name: demo-controlplane02
iPAddress: 10.2.10.120
type: controlplane
kubeVersion: 1.32.2
- name: demo-worker02
iPAddress: 10.2.10.220
type: worker
kubeVersion: 1.32.2
- name: zone3
nodes:
- name: demo-controlplane03
iPAddress: 10.2.10.130
type: controlplane
kubeVersion: 1.32.2
- name: demo-worker03
iPAddress: 10.2.10.230
type: worker
kubeVersion: 1.32.2
3. Validate your values and upgrade the cluster
After cluster-values.yaml is updated, review all values carefully.
When you are ready, start the upgrade process:
kubeopsctl apply -f cluster-values.yaml
4. Adjust your cluster-values.yaml in zone2
Next, change the target version of zone2:
# file cluster-values.yaml
apiVersion: kubeops/kubeopsctl/cluster/beta/v1
imagePullRegistry: registry.kubeops.net/kubeops/kubeops
airgap: true
clusterName: myCluster
clusterUser: root
kubernetesVersion: 1.32.2 # -> actual version
kubeVipEnabled: false
virtualIP: 10.2.10.110
firewall: nftables
pluginNetwork: calico
containerRuntime: containerd
kubeOpsRoot: /home/myuser/kubeops
serviceSubnet: 192.168.128.0/17
podSubnet: 192.168.0.0/17
debug: true
systemCpu: 250m
systemMemory: 256Mi
packageRepository: local
changeCluster: true
zones:
- name: zone1
nodes:
- name: demo-controlplane01
iPAddress: 10.2.10.110
type: controlplane
kubeVersion: 1.33.5 # -> target version
- name: demo-worker01
iPAddress: 10.2.10.210
type: worker
kubeVersion: 1.33.5 # -> target version
- name: zone2
nodes:
- name: demo-controlplane02
iPAddress: 10.2.10.120
type: controlplane
kubeVersion: 1.33.5 # ->target version
- name: demo-worker02
iPAddress: 10.2.10.220
type: worker
kubeVersion: 1.33.5 # -> target version
- name: zone3
nodes:
- name: demo-controlplane03
iPAddress: 10.2.10.130
type: controlplane
kubeVersion: 1.32.2
- name: demo-worker03
iPAddress: 10.2.10.230
type: worker
kubeVersion: 1.32.2
5. Validate your values and upgrade the cluster
After cluster-values.yaml is updated, review all values carefully.
When you are ready, start the upgrade process:
kubeopsctl apply -f cluster-values.yaml
6. Adjust your cluster-values.yaml in zone3
Finally, change the target version of zone 3.
# file cluster-values.yaml
apiVersion: kubeops/kubeopsctl/cluster/beta/v1
imagePullRegistry: registry.kubeops.net/kubeops/kubeops
airgap: true
clusterName: myCluster
clusterUser: root
kubernetesVersion: 1.32.2 # -> actual version
kubeVipEnabled: false
virtualIP: 10.2.10.110
firewall: nftables
pluginNetwork: calico
containerRuntime: containerd
kubeOpsRoot: /home/myuser/kubeops
serviceSubnet: 192.168.128.0/17
podSubnet: 192.168.0.0/17
debug: true
systemCpu: 250m
systemMemory: 256Mi
packageRepository: local
changeCluster: true
zones:
- name: zone1
nodes:
- name: demo-controlplane01
iPAddress: 10.2.10.110
type: controlplane
kubeVersion: 1.33.5 # -> target version
- name: demo-worker01
iPAddress: 10.2.10.210
type: worker
kubeVersion: 1.33.5 # -> target version
- name: zone2
nodes:
- name: demo-controlplane02
iPAddress: 10.2.10.120
type: controlplane
kubeVersion: 1.33.5 # ->target version
- name: demo-worker02
iPAddress: 10.2.10.220
type: worker
kubeVersion: 1.33.5 # -> target version
- name: zone3
nodes:
- name: demo-controlplane03
iPAddress: 10.2.10.130
type: controlplane
kubeVersion: 1.33.5 # -> target version
- name: demo-worker03
iPAddress: 10.2.10.230
type: worker
kubeVersion: 1.33.5 # -> target version
7. Validate your values and upgrade the cluster
After cluster-values.yaml is updated, review all values carefully.
When you are ready, start the upgrade process:
kubeopsctl apply -f cluster-values.yaml