# MicroK8s CAPI - management cluster ops

**URL:** <https://discuss.kubernetes.io/t/microk8s-capi-management-cluster-ops/23370>\
**Category:** microk8s\
**Tags:** docs\
**Created:** [March 8, 2023, 12:11pm UTC](https://discuss.kubernetes.io/t/microk8s-capi-management-cluster-ops/23370 "2023-03-08T12:11:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Konstantinos\_Tsakalo](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/konstantinos_tsakalo/32/3387_2.png) [@Konstantinos\_Tsakalo](https://discuss.kubernetes.io/u/Konstantinos_Tsakalo)\
**Post date:** [March 8, 2023, 12:11pm UTC](https://discuss.kubernetes.io/t/microk8s-capi-management-cluster-ops/23370/1 "2023-03-08T12:11:31Z")

</div>

In this HowTo we build on the [Cluster Provisioning with CAPI](https://discuss.kubernetes.io/t/cluster-provisioning-with-capi/23366) 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](https://discuss.kubernetes.io/t/cluster-provisioning-with-capi/23366) 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:

```auto
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:

```auto
clusterctl upgrade plan

```

The output shows the existing version of each provider as well as the version that we can upgrade into:

```auto
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:

```auto
clusterctl upgrade apply --contract v1beta1

```

To upgrade each provider one by one, issue:

```auto
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](https://discuss.kubernetes.io/t/cluster-provisioning-with-capi/23366) 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:

```auto
clusterctl get kubeconfig <provisioned-cluster> > targetconfig
clusterctl init --kubeconfig=$PWD/targetconfig --bootstrap microk8s --control-plane microk8s --infrastructure aws

```

#### Move the cluster

Simply call:

```auto
clusterctl move --to-kubeconfig=$PWD/targetconfig

```

# Links:

Provider upgrade: [upgrade - The Cluster API Book](https://cluster-api.sigs.k8s.io/clusterctl/commands/upgrade.html)  
Cluster API move: [move - The Cluster API Book](https://cluster-api.sigs.k8s.io/clusterctl/commands/move.html)
