To delete a Tanzu Kubernetes cluster, run the tanzu cluster delete
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.
To list all of the Tanzu Kubernetes clusters that a management cluster is managing, run the tanzu cluster list
command.
tanzu cluster list
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
kubectl delete
command.Other Services: Any subnet and EC2-backed service in the cluster’s VPC, such as an RDS or VPC, and related resources such as:
Delete these resources in the AWS UI as above or with the aws
CLI.
Persistent Volumes and Persistent Volume Claims: Delete these resources with the kubectl delete
command as described in Delete Persistent Volume Claims and Persistent Volumes, below.
Azure
To delete Service type LoadBalancer (Service) in a cluster:
Set kubectl
to the cluster’s context.
kubectl config use-context my-cluster@user
Retrieve the cluster’s list of services.
kubectl get service
Delete each Service type LoadBalancer
.
kubectl delete service <my-svc>
To delete Persistent Volume (PV) and Persistent Volume Claim (PVC) objects in a cluster:
Run kubectl config use-context my-cluster@user
to set kubectl
to the cluster’s context.
Run kubectl get pvc
to retrieve the cluster’s Persistent Volume Claims (PVCs).
For each PVC:
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.
Run kubectl describe pv <my-pv>
to describe to determine if its bound PV Reclaim Policy
is Retain
or Delete
.
Run kubectl delete pvc <my-pvc>
to delete the PVC.
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.
To delete a cluster, run tanzu cluster delete
.
tanzu cluster delete 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.
tanzu cluster delete my-cluster --namespace=my-namespace
To skip the yes/no
verification step when you run tanzu cluster delete
, specify the --yes
option.
tanzu cluster delete my-cluster --namespace=my-namespace --yes
Amazon EC2: to delete a cluster on Amazon EC2, the AWS_REGION
variable must be set to the region where the cluster is running.
You can set AWS_REGION
in the local environment or credential profile, as described in Configure AWS Account Credentials.
Or to delete the cluster in a different region, prepend the setting to the tanzu cluster delete
command:
AWS_REGION=eu-west-1 tanzu cluster delete my-cluster
Important: Do not change context or edit the .kube-tkg/config
file while Tanzu Kubernetes Grid operations are running.