In this HowTo we build on the Cluster Provisioning with CAPI guide to demonstrate two
useful operations in the lifecycle of the CAPI management cluster:
- the upgrade of providers
- the migration of the management workloads to another cluster
Upgrading the providers of a management cluster
Prerequisites
We assume we already have a management cluster and the infrastructure provider configured as described in the Cluster Provisioning with CAPI guide. The selected infrastructure provider is AWS. We have not yet called clusterctl init to initialise the cluster.
Initialise the cluster
To demonstrate the steps of upgrading the management cluster, we will begin by initialising an old version of the MicroK8s CAPI providers.
To set the version of the providers to be installed we use the following notation:
clusterctl init --bootstrap microk8s:v0.4.0 --control-plane microk8s:v0.4.0 --infrastructure aws
Check for updates
With clusterctl we can check if there are any new versions on the running providers:
clusterctl upgrade plan
The output shows the existing version of each provider as well as the version that we can upgrade into:
NAME                     NAMESPACE                            TYPE                     CURRENT VERSION   NEXT VERSION
bootstrap-microk8s       capi-microk8s-bootstrap-system       BootstrapProvider        v0.4.0            v0.5.0
control-plane-microk8s   capi-microk8s-control-plane-system   ControlPlaneProvider     v0.4.0            v0.5.0
cluster-api              capi-system                          CoreProvider             v1.3.5            Already up to date
infrastructure-aws       capa-system                          InfrastructureProvider   v2.0.2            Already up to date
Trigger providers upgrade
To apply the upgrade plan recommended by clusterctl upgrade plan simply:
clusterctl upgrade apply --contract v1beta1
To upgrade each provider one by one, issue:
clusterctl upgrade apply --bootstrap capi-microk8s-bootstrap-system/microk8s:v0.5.0
clusterctl upgrade apply --control-plane capi-microk8s-control-plane-system/microk8s:v0.5.0
Migrate the managment cluster
Management cluster migration is a really powerful operation in the cluster’s lifecycle as it allows admins
to move the management cluster in a more reliable substrate or perform maintenance tasks without disruptions.
Prerequisites
In the Cluster Provisioning with CAPI guide we showed how to provision a workloads cluster. Here, we start from the point where the workloads cluster is available and we will migrate the management cluster to the one cluster we just provisioned.
Install the same set of providers to the provisioned cluster
Before migrating a cluster, we must make sure that both the target and source management clusters run the same version of providers (infrastructure, bootstrap, control plane). To do so clusterctl init should be called against he target cluster:
clusterctl get kubeconfig <provisioned-cluster> > targetconfig
clusterctl init --kubeconfig=$PWD/targetconfig --bootstrap microk8s --control-plane microk8s --infrastructure aws
Move the cluster
Simply call:
clusterctl move --to-kubeconfig=$PWD/targetconfig
Links:
Provider upgrade: upgrade - The Cluster API Book
Cluster API move: move - The Cluster API Book