Skip to content

Commit 2f22cfd

Browse files
authored
Merge pull request #5305 from nojnhuh/aso-migrate
add docs on migrating to new ASO API
2 parents 77fde16 + d711276 commit 2f22cfd

File tree

3 files changed

+36
-6
lines changed

3 files changed

+36
-6
lines changed

.markdownlinkcheck.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"ignorePatterns": [
33
{ "pattern": "^https://calendar.google.com/calendar" },
4-
{ "pattern": "^../reference/" }
4+
{ "pattern": "^\.\.?/" }
55
],
66
"httpHeaders": [{
77
"comment": "Workaround as suggested here: https://github.com/tcort/markdown-link-check/issues/201",

docs/book/src/managed/adopting-clusters.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
### Option 1: Using the new AzureASOManaged API
44

5-
<!-- markdown-link-check-disable-next-line -->
65
The [AzureASOManagedControlPlane and related APIs](./asomanagedcluster.md) support
76
adoption as a first-class use case. Going forward, this method is likely to be easier, more reliable, include
87
more features, and better supported for adopting AKS clusters than Option 2 below.
@@ -15,10 +14,10 @@ and AzureASOManagedMachinePools. The [`asoctl import
1514
azure-resource`](https://azure.github.io/azure-service-operator/tools/asoctl/#import-azure-resource) command
1615
can help generate the required YAML.
1716

18-
Caveats:
19-
- The `asoctl import azure-resource` command has at least [one known
20-
bug](https://github.com/Azure/azure-service-operator/issues/3805) requiring the YAML it generates to be
21-
edited before it can be applied to a cluster.
17+
This method can also be used to [migrate](./asomanagedcluster#migrating-existing-clusters-to-azureasomanagedcontrolplane) from AzureManagedControlPlane and its associated APIs.
18+
19+
#### Caveats
20+
2221
- CAPZ currently only records the ASO resources in the CAPZ resources' `spec.resources` that it needs to
2322
function, which include the ManagedCluster, its ResourceGroup, and associated ManagedClustersAgentPools.
2423
Other resources owned by the ManagedCluster like Kubernetes extensions or Fleet memberships are not
@@ -29,6 +28,8 @@ Caveats:
2928
- Adopting existing clusters created with the GA AzureManagedControlPlane API to the experimental API with
3029
this method is theoretically possible, but untested. Care should be taken to prevent CAPZ from reconciling
3130
two different representations of the same underlying Azure resources.
31+
- This method cannot be used to import existing clusters as a ClusterClass or a topology, only as a standalone
32+
Cluster.
3233

3334
### Option 2: Using the current AzureManagedControlPlane API
3435

docs/book/src/managed/asomanagedcluster.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,32 @@ spec:
8989
name: ${CLUSTER_NAME}-user-kubeconfig # NOT ${CLUSTER_NAME}-kubeconfig
9090
key: value
9191
```
92+
93+
### Migrating existing Clusters to AzureASOManagedControlPlane
94+
95+
Existing CAPI Clusters using the AzureManagedControlPlane and associated APIs can be migrated to use the new
96+
AzureASOManagedControlPlane and its associated APIs. This process relies on CAPZ's ability to
97+
[adopt](./adopting-clusters#option-1-using-the-new-azureasomanaged-api) existing clusters that may not have
98+
been created by CAPZ, which comes with some [caveats](./adopting-clusters#caveats) that should be reviewed first.
99+
100+
To migrate one cluster to the ASO-based APIs:
101+
102+
1. Pause the cluster by setting the Cluster's `spec.paused` to `true`.
103+
1. Wait for the cluster to be paused by waiting for the _absence_ of the `clusterctl.cluster.x-k8s.io/block-move`
104+
annotation on the AzureManagedControlPlane and its AzureManagedMachinePools. This should be fairly instantaneous.
105+
1. Create a new namespace to contain the new resources to avoid conflicting ASO definitions.
106+
1. [Adopt](./adopting-clusters#option-1-using-the-new-azureasomanaged-api) the underlying AKS resources from
107+
the new namespace, which creates the new CAPI and CAPZ resources.
108+
1. Forcefully delete the old Cluster. This is more complicated than normal because CAPI controllers do not reconcile
109+
paused resources at all, even when they are deleted. The underlying Azure resources will not be affected.
110+
- Delete the cluster: `kubectl delete cluster <name> --wait=false`
111+
- Delete the cluster infrastructure object: `kubectl delete azuremanagedcluster <name> --wait=false`
112+
- Delete the cluster control plane object: `kubectl delete azuremanagedcontrolplane <name> --wait=false`
113+
- Delete the machine pools: `kubectl delete machinepool <names...> --wait=false`
114+
- Delete the machine pool infrastructure resources: `kubectl delete azuremanagedmachinepool <names...> --wait=false`
115+
- Remove finalizers from the machine pool infrastructure resources: `kubectl patch azuremanagedmachinepool <names...> --type merge -p '{"metadata": {"finalizers": null}}'`
116+
- Remove finalizers from the machine pools: `kubectl patch machinepool <names...> --type merge -p '{"metadata": {"finalizers": null}}'`
117+
- Remove finalizers from the cluster control plane object: `kubectl patch azuremanagedcontrolplane <name> --type merge -p '{"metadata": {"finalizers": null}}'`
118+
- Note: the cluster infrastructure object should not have any finalizers and should already be deleted
119+
- Remove finalizers from the cluster: `kubectl patch cluster <name> --type merge -p '{"metadata": {"finalizers": null}}'`
120+
- Verify the old ASO resources like ResourceGroup and ManagedCluster managed by the old Cluster are deleted.

0 commit comments

Comments
 (0)