sigs.k8s.io/cluster-api-provider-azure@v1.17.0/docs/book/src/managed/troubleshooting.md (about)

     1  # Troubleshooting Managed Clusters (AKS)
     2  
     3  If a user tries to delete the MachinePool which refers to the last system node pool AzureManagedMachinePool webhook will reject deletion, so time stamp never gets set on the AzureManagedMachinePool. However the timestamp would be set on the MachinePool and would be in deletion state. To recover from this state create a new MachinePool manually referencing the AzureManagedMachinePool, edit the required references and finalizers to link the MachinePool to the AzureManagedMachinePool. In the AzureManagedMachinePool remove the owner reference to the old MachinePool, and set it to the new MachinePool. Once the new MachinePool is pointing to the AzureManagedMachinePool you can delete the old MachinePool. To delete the old MachinePool remove the finalizers in that object.
     4  
     5  Here is an Example:
     6  
     7  ```yaml
     8  # MachinePool deleted
     9  apiVersion: cluster.x-k8s.io/v1beta1
    10  kind: MachinePool
    11  metadata:
    12    finalizers:             # remove finalizers once new object is pointing to the AzureManagedMachinePool
    13    - machinepool.cluster.x-k8s.io
    14    labels:
    15      cluster.x-k8s.io/cluster-name: capz-managed-aks
    16    name: agentpool0
    17    namespace: default
    18    ownerReferences:
    19    - apiVersion: cluster.x-k8s.io/v1beta1
    20      kind: Cluster
    21      name: capz-managed-aks
    22      uid: 152ecf45-0a02-4635-987c-1ebb89055fa2
    23    uid: ae4a235a-f0fa-4252-928a-0e3b4c61dbea
    24  spec:
    25    clusterName: capz-managed-aks
    26    minReadySeconds: 0
    27    providerIDList:
    28    - azure:///subscriptions/9107f2fb-e486-a434-a948-52e2929b6f18/resourceGroups/MC_rg_capz-managed-aks_eastus/providers/Microsoft.Compute/virtualMachineScaleSets/aks-agentpool0-10226072-vmss/virtualMachines/0
    29    replicas: 1
    30    template:
    31      metadata: {}
    32      spec:
    33        bootstrap:
    34          dataSecretName: ""
    35        clusterName: capz-managed-aks
    36        infrastructureRef:
    37          apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
    38          kind: AzureManagedMachinePool
    39          name: agentpool0
    40          namespace: default
    41        version: v1.21.2
    42  
    43  ---
    44  # New Machinepool
    45  apiVersion: cluster.x-k8s.io/v1beta1
    46  kind: MachinePool
    47  metadata:
    48    finalizers:
    49    - machinepool.cluster.x-k8s.io
    50    generation: 2
    51    labels:
    52      cluster.x-k8s.io/cluster-name: capz-managed-aks
    53    name: agentpool2    # change the name of the machinepool
    54    namespace: default
    55    ownerReferences:
    56    - apiVersion: cluster.x-k8s.io/v1beta1
    57      kind: Cluster
    58      name: capz-managed-aks
    59      uid: 152ecf45-0a02-4635-987c-1ebb89055fa2
    60    # uid: ae4a235a-f0fa-4252-928a-0e3b4c61dbea     # remove the uid set for machinepool
    61  spec:
    62    clusterName: capz-managed-aks
    63    minReadySeconds: 0
    64    providerIDList:
    65    - azure:///subscriptions/9107f2fb-e486-a434-a948-52e2929b6f18/resourceGroups/MC_rg_capz-managed-aks_eastus/providers/Microsoft.Compute/virtualMachineScaleSets/aks-agentpool0-10226072-vmss/virtualMachines/0
    66    replicas: 1
    67    template:
    68      metadata: {}
    69      spec:
    70        bootstrap:
    71          dataSecretName: ""
    72        clusterName: capz-managed-aks
    73        infrastructureRef:
    74          apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
    75          kind: AzureManagedMachinePool
    76          name: agentpool0
    77          namespace: default
    78        version: v1.21.2
    79  ```