Use kubectl
or the Tanzu CLI to delete a TKG cluster.
When you delete a
TKG cluster using
kubectl or the Tanzu CLI, Kubernetes garbage collection ensures that all dependent resources are deleted.
Note: Do not attempt to delete a cluster using the
vSphere Client or the
vCenter Server CLI.
Procedure
- Authenticate with the Supervisor.
- Change context to the vSphere Namespace where the TKG you want to delete is provisioned.
kubectl config use-context CLUSTER-NAMESPACE
- List the TKG clusters in the namespace.
- Delete the TKG cluster using the following syntax.
v1alpha3 cluster using kubectl:
kubectl delete tanzukubernetescluster --namespace CLUSTER-NAMESPACE CLUSTER-NAME
v1beta1 cluster using kubectl:
kubectl delete cluster --namespace CLUSTER-NAMESPACE CLUSTER-NAME
v1alpha3 or v1beta1 cluster using the Tanzu CLI:
tanzu cluster delete --namespace CLUSTER-NAMESPACE CLUSTER-NAME
Example result:
tanzukubernetescluster.run.tanzu.vmware.com "tkg-cluster-1" deleted
- Verify that the cluster is deleted.
kubectl:
kubectl get clusters
Tanzu CLI:
tanzu cluster list
- Delete the cluster context from the
kubeconfig
file.
kubectl config delete-context CONTEXT
For example:
kubectl config get-contexts
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
192.0.2.1 192.0.2.1 wcp:192.0.2.1:administrator@vsphere.local
tkg-cluster-1 192.0.2.6 wcp:192.0.2.6:administrator@vsphere.local
* tkg-ns-1 192.0.2.7 wcp:192.0.2.7:administrator@vsphere.local tkg-ns-1
kubectl config delete-context tkg-cluster-1
deleted context tkg-cluster-1 from $HOME/.kube/config
kubectl config get-contexts
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
192.0.2.1 192.0.2.1 wcp:192.0.2.1:administrator@vsphere.local
* tkg-ns-1 192.0.2.7 wcp:192.0.2.7:administrator@vsphere.local tkg-ns-1