TKG 1.4 on AWS – Part 4 : Delete the clusters

Reading Time: 2 mins


Deleting workload cluster takes off all namespaces and is non-reversible. Ensure to double check in case if you are doing it on production workloads. Depending on the cluster contents and cloud infrastructure, you may need to delete in-cluster volumes and services before you delete the cluster itself.

Delete Workload cluster

  • Before proceeding with cluster deletion, ensure to check if there are any services created as Load balancers in AWS as ELB or NLB. If yes, then delete them from AWS console or kubectl delete svc
# get workload cluster list

root@ip-172-31-37-5:~/tanzu# tanzu cluster list
tkg-workload-aws-1 default running 1/1 1/1 v1.21.2+vmware.1 <none> dev

# Initiate workload cluster delete
#Syntax: tanzu cluster delete <workload cluster name>

$ tanzu cluster delete tkg-workload-aws-1
Deleting workload cluster 'tkg-workload-aws-1'. Are you sure? [y/N]: y
Workload cluster 'tkg-workload-aws-1' is being deleted

Delete management cluster

#Syntax: export AWS_REGION=<region name>
export AWS_REGION=ap-south-1

$ tanzu mc delete
Deleting management cluster 'tkg-mgmt-aws'. Are you sure? [y/N]: y
Verifying management cluster...
Setting up cleanup cluster...
Installing providers to cleanup cluster...
Fetching providers
Installing cert-manager Version="v1.1.0"
Waiting for cert-manager to be available...
Installing Provider="cluster-api" Version="v0.3.23" TargetNamespace="capi-system"
Installing Provider="bootstrap-kubeadm" Version="v0.3.23" TargetNamespace="capi-kubeadm-bootstrap-system"
Installing Provider="control-plane-kubeadm" Version="v0.3.23" TargetNamespace="capi-kubeadm-control-plane-system"
Installing Provider="infrastructure-aws" Version="v0.6.6" TargetNamespace="capa-system"
Moving Cluster API objects from management cluster to cleanup cluster...
Performing move...
Discovering Cluster API objects
Moving Cluster API objects Clusters=1
Creating objects in the target cluster
Deleting objects from the source cluster
Waiting for the Cluster API objects to get ready after move...
Deleting management cluster...
Management cluster 'tkg-mgmt-aws' deleted.
Deleting the management cluster context from the kubeconfig file '/root/.kube/config'

Management cluster deleted!
  • In AWS console, navigate to EC2 page to see the status of vm’s

  • Ensure to check if there are any subnet or EC2-backend service in cluster and related resources such as:
      • VPC: Delete under VPC Dashboard > Virtual Private Cloud > Your VPCs.
      • RDS: Delete under RDS Dashboard > Databases.
      • Subnets: Delete under VPC Dashboard > Virtual Private Cloud > Subnets.
      • Route Tables: Delete under VPC Dashboard > Virtual Private Cloud > Route Tables.
      • Internet Gateways: Delete under VPC Dashboard > Virtual Private Cloud > Internet Gateways.
      • Elastic IP Addresses: Delete under VPC Dashboard > Virtual Private Cloud > Elastic IPs.
      • NAT Gateways: Delete under VPC Dashboard > Virtual Private Cloud > NAT Gateways.
      • Network ACLs: Delete under VPC Dashboard > Security > Network ACLs.
      • Security Groups: Delete under VPC Dashboard > Security > Security Groups.

Take a quick walk through in AWS console and see if everything is cleared to avoid unnecessary billing.