Migration to ClusterClass
From #600, this repository uses CAPI ClusterClass feature for the creation of new clusters, additionally see k8s blog. This feature is also used e.g. in the SCS cluster-stacks repository.
Note: For now, ClusterClass is created per Cluster, which is not optimal and most likely it can be improved.
Therefore, existing clusters must be migrated from 'old' cluster templates to 'new' cluster class based templates. Based on ClusterClass proposal of update strategy, we shouldn't be able to migrate, but in CAPI PR #6292 the validation webhook was relaxed (via special Cluster annotation unsafe.topology.cluster.x-k8s.io/disable-update-class-name-check) and manual migration is now possible.
The script migrate-to-cluster-class.sh
uses that special annotation for migration. In the beginning, it patches
CAPI and KCP deployments with the ClusterTopology=true container argument. Then creates new resources
(KubeadmControlPlaneTemplate, OpenStackClusterTemplate, ClusterClass). After that, annotates, labels and
patches existing cluster resources. In the end, it patches the Cluster object with .spec.topology and it's done.
Migration
Prerequisites
- CAPI >= v1.5.2 due to NamingStrategy feature
- upgrade can be performed as stated in upgrade guide
Steps
- Git pull/checkout new changes into the
~/k8s-cluster-api-provider
directory - Run
migrate-to-cluster-class.sh <CLUSTER_NAME>
(verify machines were not recreated) - Copy new templates for existing and new clusters (consider backup)
cp ~/k8s-cluster-api-provider/terraform/files/template/cluster-template.yaml ~/<CLUSTER_NAME>/cluster-template.yaml
cp ~/k8s-cluster-api-provider/terraform/files/template/cluster-template.yaml ~/cluster-defaults/cluster-template.yaml - Add the newly introduced generation counter for the OpenStackClusterTemplate to the settings in
clusterctl.yaml
echo "OPENSTACK_CLUSTER_GEN: geno01" >> ~/<CLUSTER_NAME>/clusterctl.yaml
echo "OPENSTACK_CLUSTER_GEN: geno01" >> ~/cluster-defaults/clusterctl.yaml - Next run of
create_cluster.sh <CLUSTER_NAME>
should be idempotent