To delete a Tanzu Kubernetes cluster, run the tkg delete cluster command. Depending on the cluster contents and cloud infrastructure, you may need to delete in-cluster volumes and services before you delete the cluster itself.

Step One: List Clusters

To list all of the Tanzu Kubernetes clusters that a management cluster is managing, run the tkg get cluster command.

tkg get cluster

Step Two: Delete Volumes and Services

If the cluster you want to delete contains persistent volumes or services such as load balancers and databases, you may need to manually delete them before you delete the cluster itself. What you need to pre-delete depends on your cloud infrastructure:

  • vSphere

  • Amazon EC2

    • Load Balancers: Application or Network Load Balancers (ALBs or NLBs) in the cluster's VPC, but not Classic Load Balancers (ELB v1).
    • Other Services: Any subnet/EC2 backed service in cluster's VPC, such as an RDS.
    • Persistent Volumes and Persistent Volume Claims: see Delete Persistent Volume Claims and Persistent Volumes, below.
  • Azure

    • No action required. Deleting a cluster deletes everything that TKG created in the cluster's resource group.

Delete Persistent Volumes and Persistent Volume Claims

To delete Persistent Volume (PV) and Persistent Volume Claim (PVC) objects in a cluster:

  1. Run kubectl config set-context my-cluster@user to set kubectl to the cluster's context.

  2. Run kubectl get pvc to retrieve the cluster's Persistent Volume Claims (PVCs).

  3. For each PVC:

    1. Run kubectl describe pvc <my-pvc> to identify the PV it is bound to. The PV is listed in the command output as Volume, after Status: Bound.

    2. Run kubectl describe pv <my-pv> to describe to determine if its bound PV Reclaim Policy is Retain or Delete.

    3. Run kubectl delete pvc <my-pvc> to delete the PVC.

    4. If the PV reclaim policy is Retain, run kubectl delete pv <my-pvc> and then log into your cloud portal and delete the PV object there. For example, delete a vSphere CNS volume from your datastore pane > Monitor > Cloud Native Storage > Container Volumes. For more information about vSphere CNS, see Getting Started with VMware Cloud Native Storage.

Step Three: Delete Cluster

  1. To delete a cluster, run tkg delete cluster.

    tkg delete cluster my-cluster

    If the cluster is running in a namespace other than the default namespace, you must specify the --namespace option to delete that cluster.

    tkg delete cluster my-cluster --namespace=my-namespace

    To skip the yes/no verification step when you run tkg delete cluster, specify the --yes option.

    tkg delete cluster my-cluster --namespace=my-namespace --yes

IMPORTANT: Do not change context or edit the .kube-tkg/config file while Tanzu Kubernetes Grid operations are running.

check-circle-line exclamation-circle-line close-line
Scroll to top icon