TKG 1.4 on Azure – Part 6 : Delete the clusters

Reading Time: 2 mins

 

This post covers the steps to delete the clusters that were deployed in TKG on Azure. Ensure to follow this doc only after double checking when NO APPLICATIONS ARE RUNNING. Cluster deletion completely wipes the pods running it.

Delete workload cluster:

#Get workload cluster name
reddye@reddye-a02 tkg % tanzu clusters list
NAME NAMESPACE STATUS CONTROLPLANE WORKERS KUBERNETES ROLES PLAN
capv-workload default running 1/1 1/1 v1.21.2+vmware.1 <none> dev


#Syntax to delete workload cluster

tanzu cluster delete <Cluster name>

reddye@reddye-a02 scripts % tanzu cluster delete capv-workload
Deleting workload cluster 'capv-workload'. Are you sure? [y/N]: y
Workload cluster 'capv-workload' is being deleted

reddye@reddye-a02 scripts % tanzu cluster list
NAME NAMESPACE STATUS CONTROLPLANE WORKERS KUBERNETES ROLES PLAN

Delete Management cluster:

Management cluster deletion might usually take some time as it requires bootstrap cluster to be deployed in KIND. To see the boot strap cluster node creation progress, you can run the command docker ps in other terminal. Bootstrap clusters get deleted automatically once the management clusters are completely deleted.

Management cluster deletion
reddye@reddye-a02 scripts % tanzu mc get
NAME NAMESPACE STATUS CONTROLPLANE WORKERS KUBERNETES ROLES
capv-mgmt tkg-system running 1/1 1/1 v1.21.2+vmware.1 management


reddye@reddye-a02 scripts % tanzu mc delete capv-mgmt
Deleting management cluster 'capv-mgmt'. 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-azure" Version="v0.4.15" TargetNamespace="capz-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...

# Check the contexts
reddye@reddye-a02 scripts % kubectl config get-contexts
CURRENT NAME CLUSTER AUTHINFO NAMESPACE

Delete Management Clusters from Tanzu CLI Configuration

After deleting the management cluster, it might continue to appear in the list of management clusters that the CLI tracks when you run tanzu login. In these cases, you can remove the management cluster from the list of management clusters that the Tanzu CLI tracks.

#Lists the available management clusters
reddye@reddye-a02 scripts % tanzu login
? Select a server [Use arrows to move, type to filter]
> capv-mgmt ()
+ new server

#Deletes from config
reddye@reddye-a02 scripts % tanzu config server delete capv-mgmt
Deleting the server entry from the config will remove it from the list of tracked servers. You will need to use tanzu login to track this server again. Are you sure you want to continue? [y/N]: y
ℹ Deleting entry for cluster capv-mgmt
  • Login to Azure portal and see if there are any resources exist as given below, successful deletion shouldn’t leave any resources in Azure portal. In case if they exist, delete them manually to avoid billing.
          • Resource Groups
          • Virtual Machines
          • VNET
          • Load Balancers