Deleting a Management Cluster with "tanzu mc delete"
command gets stuck after the Kind cleanup cluster has been deployed and the Management Cluster resources cleanup has started.
Information on how the cleanup process works is in the official Docs: Delete Management Clusters
There're many possible causes for this issue.
For example, if Kind can't connect to vCenter/NSX/AVI to proceed with the infra resources cleanup, the Management Cluster cleanup may get stuck with stale ClusterAPI objects, such as Cluster, Machines, vSphereMachines and vSphereVMs.
To troubleshoot the issue you can execute into the Kind cleanup cluster and examine Management Cluster resources there.
# kind get nodes -A
# docker ps | grep kind
# docker exec -it <kind-container-id-from-command-2> bash
# kubectl get cluster,kcp,md,ma,vspheremachine,vspherevm -A
If we need to make changes to the cluster resources' manifests, for example, removing finalizers, "kubectl edit"
doesn't work on Kind as it doesn't have any text editor installed.
In this case, the best way forward is:
# kubectl get <resource-type> <resource-name> -n tkg-system -o yaml > <resource-name>.yaml
# docker cp <container-id>:/<file-path>/<resource-name>.yaml .
# vim <resource-name>.yaml
# docker cp ./<resource-name>.yaml <container-id>:/<file-path>/<resource-name>-edited.yaml
# kubectl apply -f <resource-name>-edited.yaml
After the issues have been resolved and the Management Cluster cleaned up, if the "tanzu mc delete"
command has timed out or failed, you may end up with a stale Kind cluster that needs to be removed.
To remove the stale Kind cluster, follow the official Docs: Kind Cluster Remains after Deleting Management Cluster