Use kubectl
to delete a Tanzu Kubernetes cluster provisioned by the Tanzu Kubernetes Grid Service.
When you delete a
Tanzu Kubernetes cluster using
kubectl, Kubernetes garbage collection ensures that all dependent resources are deleted.
Note: Do not attempt to delete a
Tanzu Kubernetes cluster using the
vSphere Client or the
vCenter Server CLI.
Procedure
- Authenticate with the Supervisor Cluster.
- Change context to the vSphere Namespace where the Tanzu Kubernetes you want to delete is provisioned.
kubectl config use-context CLUSTER-NAMESPACE
For example:
kubectl config use-context tkgs-ns-1
- List the Tanzu Kubernetes clusters in the namespace.
For example:
kubectl get clusters
NAME PHASE
tkgs-cluster-1 provisioned
- Delete the Tanzu Kubernetes cluster using the following syntax.
kubectl delete tanzukubernetescluster --namespace CLUSTER-NAMESPACE CLUSTER-NAME
For example:
kubectl delete tanzukubernetescluster --namespace tkgs-ns-1 tkgs-cluster-1
Expected result:
tanzukubernetescluster.run.tanzu.vmware.com "tkgs-cluster-1" deleted
- Verify that the cluster is deleted.
For example:
kubectl get clusters
No resources found in tkgs-ns-1 namespace.
- 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:[email protected]
tkgs-cluster-1 192.0.2.6 wcp:192.0.2.6:[email protected]
* tkgs-ns-1 192.0.2.7 wcp:192.0.2.7:[email protected] tkgs-ns-1
kubectl config delete-context tkgs-cluster-1
deleted context tkgs-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:[email protected]
* tkgs-ns-1 192.0.2.7 wcp:192.0.2.7:[email protected] tkgs-ns-1