Azure Hosted Control Plane Deployment#
Follow these steps to set up a k0smotron-hosted control plane on Azure:
- 
Prerequisites Before you start, make sure you have the following: - A management Kubernetes cluster (Kubernetes v1.28+) deployed on Azure with k0rdent installed.
- A default storage class configured on the management cluster to support Persistent Volumes.
 Note All control plane components for managed clusters will run in the management cluster. Make sure the management cluster has sufficient CPU, memory, and storage to handle the additional workload. 
- 
Gather Pre-existing Resources In a hosted control plane setup, some Azure resources must exist before deployment and must be explicitly provided in the ClusterDeploymentconfiguration. These resources can also be reused by the management cluster.If you deployed your Azure Kubernetes cluster using the Cluster API Provider for Azure (CAPZ), you can retrieve the required information using the following commands: Location: kubectl get azurecluster <cluster-name> -o go-template='{{.spec.location}}'Subscription ID: kubectl get azurecluster <cluster-name> -o go-template='{{.spec.subscriptionID}}'Resource Group: kubectl get azurecluster <cluster-name> -o go-template='{{.spec.resourceGroup}}'VNet Name: kubectl get azurecluster <cluster-name> -o go-template='{{.spec.networkSpec.vnet.name}}'Subnet Name: kubectl get azurecluster <cluster-name> -o go-template='{{(index .spec.networkSpec.subnets 1).name}}'Route Table Name: kubectl get azurecluster <cluster-name> -o go-template='{{(index .spec.networkSpec.subnets 1).routeTable.name}}'Security Group Name: kubectl get azurecluster <cluster-name> -o go-template='{{(index .spec.networkSpec.subnets 1).securityGroup.name}}'
- 
Create the ClusterDeployment manifest After collecting the required data, create a ClusterDeploymentmanifest to configure the hosted control plane. It should look something like this:apiVersion: k0rdent.mirantis.com/v1beta1 kind: ClusterDeployment metadata: name: azure-hosted-cp spec: template: azure-hosted-cp-1-0-19 credential: azure-credential config: clusterLabels: {} location: "westus" subscriptionID: ceb131c7-a917-439f-8e19-cd59fe247e03 vmSize: Standard_A4_v2 resourceGroup: mgmt-cluster network: vnetName: mgmt-cluster-vnet nodeSubnetName: mgmt-cluster-node-subnet routeTableName: mgmt-cluster-node-routetable securityGroupName: mgmt-cluster-node-nsgAlternatively, you can generate the ClusterDeploymentmanifest.If the management cluster you prepared in the first step was deployed using k0rdent or the CAPI AWS provider, you can simplify the creation of a ClusterDeploymentmanifest, and use the following template, which dynamically inserts the appropriate values:apiVersion: k0rdent.mirantis.com/v1beta1 kind: ClusterDeployment metadata: name: azure-hosted-cp spec: template: azure-hosted-cp-1-0-19 credential: azure-credential config: clusterLabels: {} location: "{{.spec.location}}" subscriptionID: "{{.spec.subscriptionID}}" vmSize: Standard_A4_v2 resourceGroup: "{{.spec.resourceGroup}}" network: vnetName: "{{.spec.networkSpec.vnet.name}}" nodeSubnetName: "{{(index .spec.networkSpec.subnets 1).name}}" routeTableName: "{{(index .spec.networkSpec.subnets 1).routeTable.name}}" securityGroupName: "{{(index .spec.networkSpec.subnets 1).securityGroup.name}}"Save this YAML as clusterdeployment.yaml.tpland render the manifest with the following command:kubectl get azurecluster <management-cluster-name> -o go-template="$(cat clusterdeployment.yaml.tpl)" > clusterdeployment.yaml
- 
Create the ClusterDeploymentTo actually create the cluster, apply the ClusterDeploymentmanifest to the management cluster, as in:kubectl apply clusterdeployment.yaml -n kcm-system
- 
Manually update the AzureClusterobjectDue to a limitation in k0smotron, (see k0sproject/k0smotron#668), after applying the ClusterDeploymentmanifest, you must manually update the status of theAzureClusterobject.Use the following command to set the AzureClusterobject status toReady:kubectl patch azurecluster <cluster-name> --type=merge --subresource status --patch '{"status": {"ready": true}}'
Important Notes on Cluster Deletion#
Due to these same k0smotron limitations, you must take some manual steps in order to delete a cluster properly:
- 
Add a Custom Finalizer to the AzureCluster Object: To prevent the AzureClusterobject from being deleted too early, add a custom finalizer:kubectl patch azurecluster <cluster-name> --type=merge --patch '{"metadata": {"finalizers": ["manual"]}}'
- 
Delete the ClusterDeployment: After adding the finalizer, delete the ClusterDeploymentobject as usual. Confirm that allAzureMachinesobjects have been deleted successfully.
- 
Remove Finalizers from Orphaned AzureMachines: If any AzureMachinesare left orphaned, delete their finalizers manually after confirming no VMs remain in Azure. Use this command to remove the finalizer:kubectl patch azuremachine <machine-name> --type=merge --patch '{"metadata": {"finalizers": []}}'
- 
Allowing Updates to Orphaned Objects: If Azure admission controls prevent updates to orphaned objects, you must disable the associated MutatingWebhookConfigurationby deleting it:kubectl delete mutatingwebhookconfiguration <webhook-name>