Cluster API Upgrade

Cluster API Upgrade

 

This is adapted from: https://cluster-api.sigs.k8s.io/tasks/upgrading-clusters.html

For more complex upgrades, additional context or further considerations the upstream documentation is recommended.

 

1. Overview

Upgrading CAPI clusters is a long process.

Be sure to read this guide carefully and upgrade often to avoid issues

 

The following steps will show you how to upgrade your CAPI cluster from start to finish. There are many components that make up a CAPI cluster, each of these will need to be upgraded in the following order:

  1. Clusterctl: the command-line tool which is used to interact with Cluster API. We use this to perform upgrades on Cluster API and its dependencies

  2. Cluster API and its dependencies: this provides a declarative set of APIs that are used to provision, delete and manage multiple kubernetes clusters https://github.com/kubernetes-sigs/cluster-api

  3. Provisioned Clusters via Helm Charts: each CAPI Cluster that has already been provisioned must be upgrading to the latest supported helm chart version.

 

  1. Kubernetes and OS Upgrades: the Kubernetes version and underlying packages at the OS level must be upgraded by updating your cluster to use the latest CAPI image released by the Cloud team

1.1. Get Latest Supported Dependencies

Clone our cloud-capi-values repo - http://github.com/stfc/cloud-capi-valuesand run source set-env.sh

git clone https://github.com/stfc/cloud-capi-values.git cd cloud-capi-values source set-env.sh


this will load the latest supported dependency versions

 

1.2. Check if you need to Upgrade

Find out if you need to upgrade:

Cluster API Components:

Check the versions of the underlying Cluster API components by running:

clusterctl upgrade plan

You may need to download the latest clusterctl - see section 2.1

This command will show you the CURRENT VERSION and the version you can upgrade to if you need to.

You only need to perform upgrade for this if:

  • cluster-api version < $CLUSTER_API

  • infrastructure-openstack version < $CAPO_PROVIDER_VERSION

If it is equal to or greater you can ignore this upgrade

 

Kubernetes Version:

Check the kubernetes version of your cluster and what image the cluster is using.

You can find it on Openstack or by running:

printf "%s\n" $(kubectl get openstackmachine -n clusters\ -l="capi.stackhpc.com/cluster=<your-cluster-name>" \ -o=jsonpath='{.items[*].spec.image.filter.name}' -A)

compare this to the latest image release - check on openstack by running

openstack image list | grep capi

Make sure that all nodes (worker and control-plane) are using the same image before starting the upgrade

The latest release will have the latest patch version.

We recommend always upgrading to the current kubernetes image once it becomes available.

WE WILL REMOVE ACCESS TO OLD KUBERNETES IMAGES

See our policy Cluster API Upgrade and make sure to check notifications regularly to make sure you don’t experience issues

 

Helm Chart Version: check the helm chart versions by running

helm list -n clusters

You only need to perform upgrade for this if:

  • cluster-api-addon-provider chart version < $ADDON_VERSION

  • <cluster-name> (openstack-cluster chart release) chart version < $CAPI_HELM_CHART_VERSION

If it is equal to or greater you can ignore this upgrade

Upgrading from a very old cluster

If you’re updating from an older cluster (>2 years running without upgrades) You might need to perform intermediary upgrade steps to catch up to the latest version.

Check this table and see what you can upgrade to. https://cluster-api.sigs.k8s.io/reference/versions#supported-versions-matrix-by-provider-or-component

Each Cluster API minor release supports (when it’s initially created):

  • Four Kubernetes minor releases for the management cluster (N - N-3)

  • Six Kubernetes minor releases for the workload cluster (N - N-5)

Cluster API components can only be upgraded by n + 3 minor versions at a time.

Please update regularly to avoid risking a complex upgrade!

 

2. Upgrade Procedure

This Upgrade Procedure docs assumes the reader/administrator is doing a full upgrade of all components. These can be upgraded independently with the caveat that the Infrastructure layer supports the version of Kubernetes planned: https://cluster-api.sigs.k8s.io/reference/versions

2.1 Upgrade Clusterctl

We need to upgrade clusterctl to be aware of the supported CAPI and CAPO components essential for interacting with Openstack

clusterctl is a command-line tool for managing Kubernetes clusters managed by Cluster API.

Find out more here: http://cluster-api.sigs.k8s.io/clusterctl/overview

Download the latest version which supports your cluster version.

In the case of multiple upgrades, download the latest clusterctl which supports your current Kubernetes cluster version including the management plane.

Copy the latest supported release $CLUSTER_API:

wget https://github.com/kubernetes-sigs/cluster-api/releases/download/$CLUSTER_API/clusterctl-linux-amd64 chmod +x ./clusterctl-linux-amd64 sudo mv ./clusterctl-linux-amd64 /usr/local/bin/clusterctl # Validate version clusterctl version

 

2.2. Upgrade Cluster API

Once clusterctl is installed, you can upgrade various CAPI components including the CAPI Openstack Provider:

clusterctl upgrade plan

This will show you which versions you can upgrade to safely, and what command you should run to apply the changes using clusterctl upgrade apply --contract <contract-name>

Alternatively you can run:

clusterctl upgrade apply \ --bootstrap=kubeadm:${CLUSTER_API} \ --control-plane=kubeadm:${CLUSTER_API} \ --core=cluster-api:${CLUSTER_API} \ --infrastructure=openstack:${CAPO_PROVIDER_VERSION}

Be careful when upgrading clusterctl directly, especially on clusters that are running much older versions. CAPI only supports n-3 skip upgrades https://cluster-api.sigs.k8s.io/reference/versions#skip-upgrades.

For example, if you are running Cluster API v1.6.x, you can upgrade up to Cluster API v1.9.x skipping intermediate minor versions (v1.6 is v1.9 minus three minor versions).

Upgrading beyond 3 minor versions at a time can lead to your cluster becoming non-functional. Use clusterctl upgrade plan if you’re not sure

 

2.3. Upgrade CAPI Helm Charts

Updating to the latest helm chart will allow your cluster(s) to utilize updated CAPI components (that you updated in section 1.2).
You must do this to update your clusters

The upstream repo URLs changed during Q3 2024. You need to update the URLs if your helm history <cluster_name> shows 0.9.0 as the latest version for the openstack-cluster

  1. Update the addon provider on all clusters first

# Update URLs to repos if required: helm repo add capi https://azimuth-cloud.github.io/capi-helm-charts --force-update helm repo add capi-addons https://azimuth-cloud.github.io/cluster-api-addon-provider --force-update # Or if this is already using the new URL: helm repo update capi helm repo update capi-addons # Update the capi-addons first, as it's not always forwards compatible: helm upgrade cluster-api-addon-provider capi-addons/cluster-api-addon-provider -n clusters --version $ADDON_VERSION --wait cd <folder_with_values>
  1. Update the K-ORC dependency on any clusters managing infrastructure. (Check with kubectl get machines -A).

    1. This used to be shipped as an implicit requirement for CAPO, but as of CAPO 0.12+ administrators must to install or update the specified version manually:

kubectl apply --kubeconfig=<cluster-name>.kubeconfig -f "https://github.com/k-orc/openstack-resource-controller/releases/download/v${KORC}/install.yaml"
  1. The next step is to update each of your clusters. You can do so in any order, but it is recommended to follow this approach:

    1. Dev Worker cluster(s)

    2. Staging Worker cluster(s)

    3. Management cluster

    4. Production Worker cluster(s)

On your Management cluster run:

helm upgrade <cluster_name> capi/openstack-cluster -f values.yaml -f clouds.yaml -f user-values.yaml -f flavors.yaml --version $CAPI_HELM_CHART_VERSION -n clusters
  • Monitor the upgrade using clusterctl describe cluster <cluster_name> -n clusters

2.4. Kubernetes Version and OS Patches

For development / low risk clusters you can combine this step with 2.3 to speed up the process. For production clusters we recommend performing these steps separately

The operating system and associated packages can be updated independently, e.g. to apply security patches to the host OS.

The Cloud Team provides a lightweight VM image purpose built for CAPI clusters.

The image naming convention is as follows:

capi-<OS>-<OS-Version>-kube-v<kubernetes-version>

e.g. capi-ubuntu-2204-kube-v1.33.4

Images are updated for 2 reasons:

  1. To make compatible with new Kubernetes versions

  2. To patch underlying OS system-level packages to ensure that they come meet the combined UKRI and STFC Cloud security policies - see Terms Of Service

Updating Kubernetes Version requires a rolling restart to be performed on your cluster.

This means that your cluster will delete and re-provision control-plane and worker nodes.

These images may be prone to security vulnerabilities. The Cloud Team will contact you to detail any mitigation steps if any high-risk vulnerabilities are discovered

Steps

  • Lookup the latest image build for Kubernetes, this can be found in images section of the web interface

  • Alternatively, git pull to grab the latest version from the cloud-capi-values repo

    • Note: this will only work if you are 1 major version behind the latest. If you are >=2 versions behind you’ll need to manually edit the fields as described below:

  • Edit the kubernetesVersion in user-values.yaml to match the image name

  • Edit the machineImage in user-values.yaml to use the latest patch release

helm repo update capi helm upgrade <cluster_name> capi/openstack-cluster -f values.yaml -f clouds.yaml -f user-values.yaml -f flavors.yaml -n clusters
  • Wait for the rollout of new infra to complete

    • The rollout can be monitored with kubectl get kcp -A and kubectl get md -A

    • Machine details can be found in kubectl get machines -A and kubectl get openstackmachines -A

  • Repeat for each major upgrade step

    • You can only do a single major upgrade at a time, e.g. 1.29.12 to 1.30.4, then 1.31.6

Multiple K8s Version Upgrades

If you are upgrading multiple major Kubernetes versions you can only upgrade 1 minor version step at a time. Additionally you need to check support against clusterctl here: https://cluster-api.sigs.k8s.io/reference/versions

To upgrade major versions you will need to follow the Cluster API Upgrade section first then Cluster API Upgrade for each hop.

You’ll need to upgrade VM images and Kubernetes version to the latest patch version available before doing any major upgrades:

I.e. if you’re on 1.29.12 upgrade to the latest 1.29.x, this ensures any bug-fixes are applied which could prevent later upgrades.

 

 

3. Supported Kubernetes Versions

We aim to support Kubernetes versions and keep CAPI images for N -1 → all supported End of Life (EOL) versions from: https://kubernetes.io/releases/ OR the oldest CAPI image we have that gives an upgrade path - whichever is the older; where N is the latest Kubernetes version.

For example, as of the 29/01/2025, the latest Kubernetes version is v1.32 and therefore, we will provide CAPI images for Kubernetes versions v1.31 → v1.26 (oldest image we hold).

  • Once we provide the latest N-1 image, we will keep the oldest image (v1.26) for a minimum of 4 weeks to let you upgrade older clusters and notify any users accordingly.

 

Kubernetes Version Support.png

 

Please refer to the Kubernetes Release page for the latest version history and patch notes.

4. Troubleshooting

4.1. On the management cluster

  • Check the machines and openstackmachines CRDs match the VMs in the web interface

    • kubectl get machines -A and kubectl get openstackmachines -A

    • Check the control plane node’s status kubectl describe machine <name> -n clusters

  • Logs are available if nothing is happening / the process is stuck

    • OpenStack logs: kubectl logs deploy/capo-controller-manager -n capo-system -f

    • CAPI logs: kubectl logs deploy/capi-controller-manager -n capi-system -f

  • Check the control plane status:

    • kubectl describe kcp/<name>-control-plane -n clusters

    • Check for events on the management cluster: kubectl get events -n clusters --watch

4.2. On the target cluster

  • Check you have access via kubectl

    • This could indicate an OpenStack networking configuration problem if you do not

    • Check the LBs and networks exist - if not check the CAPO logs on the management cluster

  • Check etcd is healthy with kubectl get pods -n kube-system:

    • If they’re failing to start kubectl describe pod/etcd-<name> -n kube-system

    • If they’re running check they’re healthy with kubectl logs pod/etcd-<name> -n kube-system

    • In the event etcd is unhealthy contact the cloud team to assist with recovery

  • Check the kubeapi pod is starting per machine

    • If they’re failing to start kubectl describe pod/kubeapi-<name> -n kube-system

    • If they’re running check they’re healthy with kubectl logs pod/kubeapi-<name> -n kube-system

    • In the event the Kubelet is failing to start or is unhealthy contact the cloud to assist with recovery

4.3. Can’t access kubectl exec or kubectl logs after upgrade

This affects users upgrading an existing cluster to the following minor versions (or beyond):

  • v1.36.1

  • v1.35.5

  • v1.34.8

  • v1.33.12

Caused by a security improvement in the minor versions above. The cause and a fix is described in these docs.

In short, the following explicit CRB must be applied to restore permissions. Users who have tailored their RBACs or cluster roles will need to adapt the following as appropriate:

apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: kube-apiserver-kubelet-client roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: system:kubelet-api-admin subjects: - kind: User apiGroup: rbac.authorization.k8s.io name: kube-apiserver-kubelet-client