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

  1. Authenticate with the Supervisor Cluster.
  2. Change context to the Supervisor 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
    
  3. List the Tanzu Kubernetes clusters in the namespace.
    kubectl get clusters
    For example:
    kubectl get clusters
    NAME             PHASE
    tkgs-cluster-1   provisioned
  4. 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
  5. Verify that the cluster is deleted.
    kubectl get clusters
    For example:
    kubectl get clusters
    No resources found in tkgs-ns-1 namespace.
  6. Delete the cluster context from the kube config 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
              tkgs-cluster-1   192.0.2.6       wcp:192.0.2.6:administrator@vsphere.local
    *         tkgs-ns-1        192.0.2.7       wcp:192.0.2.7:administrator@vsphere.local       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:administrator@vsphere.local
    *         tkgs-ns-1        192.0.2.7       wcp:192.0.2.7:administrator@vsphere.local       tkgs-ns-1