Delete vSphere Cluster
Prepare to delete a self-managed workload cluster
A self-managed workload cluster cannot delete itself. If your workload cluster is self-managed, you must create a bootstrap cluster and move the cluster lifecycle services to the bootstrap cluster before deleting the workload cluster.
If you did not make your workload cluster self-managed, as described in Make New Cluster Self-Managed, see Delete the workload cluster.
Create a bootstrap cluster:
The bootstrap cluster will host the Cluster API controllers that reconcile the cluster objects marked for deletion. To avoid using the wrong kubeconfig, the following steps use explicit kubeconfig paths and contexts.
dkp create bootstrap --kubeconfig $HOME/.kube/config
CODEThe output resembles this example:
✓ Creating a bootstrap cluster ✓ Initializing new CAPI components
CODEMove the Cluster API objects from the workload to the bootstrap cluster: The cluster lifecycle services on the bootstrap cluster are ready, but the workload cluster configuration is on the workload cluster. The
move
command moves the configuration, which takes the form of Cluster API Custom Resource objects, from the workload to the bootstrap cluster. This process is also called a Pivot.dkp move \ --from-kubeconfig ${CLUSTER_NAME}.conf \ --from-context konvoy-${CLUSTER_NAME}-admin@konvoy-${CLUSTER_NAME} \ --to-kubeconfig $HOME/.kube/config \ --to-context kind-konvoy-capi-bootstrapper
CODEINFO[2021-06-09T11:47:11-07:00] Running pivot command fromClusterKubeconfig=aws-example.conf fromClusterContext= src="move/move.go:83" toClusterKubeconfig=/home/clusteradmin/.kube/config toClusterContext= INFO[2021-06-09T11:47:36-07:00] Pivot operation complete. src="move/move.go:108" INFO[2021-06-09T11:47:36-07:00] You can now view resources in the moved cluster by using the --kubeconfig flag with kubectl. For example: kubectl --kubeconfig=/home/clusteradmin/.kube/config get nodes src="move/move.go:155"
CODEUse the cluster lifecycle services on the workload cluster to check the workload cluster status:
dkp describe cluster --kubeconfig $HOME/.kube/config -c ${CLUSTER_NAME}
CODENAME READY SEVERITY REASON SINCE MESSAGE Cluster/d2iq-e2e-cluster_name-1 True 13h ├─ClusterInfrastructure - VSphereCluster/d2iq-e2e-cluster_name-1 True 13h ├─ControlPlane - KubeadmControlPlane/d2iq-control-plane True 13h │ ├─Machine/d2iq--control-plane-7llgd True 13h │ ├─Machine/d2iq--control-plane-vncbl True 13h │ └─Machine/d2iq--control-plane-wbgrm True 13h └─Workers └─MachineDeployment/d2iq--md-0 True 13h ├─Machine/d2iq--md-0-74c849dc8c-67rv4 True 13h ├─Machine/d2iq--md-0-74c849dc8c-n2skc True 13h ├─Machine/d2iq--md-0-74c849dc8c-nkftv True 13h └─Machine/d2iq--md-0-74c849dc8c-sqklv True 13h
CODEAfter moving the cluster lifecycle services to the workload cluster, remember to use dkp with the workload cluster kubeconfig. Use DKP with the bootstrap cluster to delete the workload cluster.
Wait for the cluster control-plane to be ready:
kubectl --kubeconfig $HOME/.kube/config wait --for=condition=controlplaneready "clusters/${CLUSTER_NAME}" --timeout=60m
CODEThe output should be similar to this example:
d2iq-e2e-cluster-1-control-plane/vsphere-example condition met
CODE
Persistent Volumes (PVs) are not deleted automatically by design in order to preserve your data. However, they take up storage space if not deleted. You must delete PVs manually. With Vsphere clusters, dkp delete
doesn't delete the virtual disks backing the PVs for DKP add ons. Therefore internal VMware cluster runs out of storage eventually. Theses PVs are only visible if VSAN is installed which gives users a Container Native Storage tab.
Delete the workload cluster
Make sure your vSphere credentials are up-to-date. Refresh the credentials using this command:
dkp update bootstrap credentials vsphere --kubeconfig $HOME/.kube/config
CODEDelete the Kubernetes cluster and wait a few minutes:
Before deleting the cluster, DKP deletes all Services of type LoadBalancer on the cluster.
To skip this step, use the flag
--delete-kubernetes-resources=false
.dkp delete cluster --cluster-name=${CLUSTER_NAME} --kubeconfig $HOME/.kube/config
CODEINFO[2022-03-30T11:53:42-07:00] Running cluster delete command clusterName=d2iq-e2e-cluster-1 managementClusterKubeconfig= namespace=default src="cluster/delete.go:95" INFO[2022-03-30T11:53:42-07:00] Waiting for cluster to be fully deleted src="cluster/delete.go:123" INFO[2022-03-30T12:14:03-07:00] Deleted default/d2iq-e2e-cluster-1 cluster src="cluster/delete.go:129"
CODEAfter the workload cluster is deleted, delete the bootstrap cluster with the following command.
Delete the Bootstrap Cluster
dkp delete bootstrap --kubeconfig $HOME/.kube/config
INFO[2021-06-09T12:15:20-07:00] Deleting bootstrap cluster src="bootstrap/bootstrap.go:182"
Known Limitations
Be aware of these limitations in the current release of DKP Konvoy.
The DKP Konvoy version used to create the workload cluster must match the DKP Konvoy version used to delete the workload cluster.