Cloud Director Delete a Cluster
Prepare to Delete a Self-managed Workload Cluster
A self-managed 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 the New Cloud Director Cluster Self-Managed, proceed to the Delete the workload cluster section below.
Create a bootstrap cluster:
The bootstrap cluster will host the Cluster API controllers that reconcile the cluster objects marked for deletion:
NOTE: To avoid using the wrong
kubeconfig
, the following steps use explicitkubeconfig
paths and contexts.CODEdkp create bootstrap --vcd-bootstrap-credentials=true --kubeconfig $HOME/.kube/config
The output resembles:
CODE✓ Creating a bootstrap cluster ✓ Initializing new CAPI components
Move 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.CODEdkp move capi-resources \ --from-kubeconfig ${CLUSTER_NAME}.conf \ --to-kubeconfig $HOME/.kube/config
Use the cluster lifecycle services on the workload cluster to check the workload cluster status:
CODEdkp describe cluster --kubeconfig $HOME/.kube/config -c ${CLUSTER_NAME}
CODENAME READY SEVERITY REASON SINCE MESSAGE Cluster/vcd-example True 34s ├─ClusterInfrastructure - vcdCluster/vcd-example ├─ControlPlane - KubeadmControlPlane/vcd-example-control-plane True 34s │ ├─Machine/vcd-example-control-plane-6fbzn True 37s │ │ └─MachineInfrastructure - vcdMachine/vcd-example-control-plane-62g6s │ ├─Machine/vcd-example-control-plane-jf6s2 True 37s │ │ └─MachineInfrastructure - vcdMachine/vcd-example-control-plane-bsr2z │ └─Machine/vcd-example-control-plane-mnbfs True 37s │ └─MachineInfrastructure - vcdMachine/vcd-example-control-plane-s8xsx └─Workers └─MachineDeployment/vcd-example-md-0 True 37s ├─Machine/vcd-example-md-0-68b86fddb8-8glsw True 37s │ └─MachineInfrastructure - vcdMachine/vcd-example-md-0-zls8d ├─Machine/vcd-example-md-0-68b86fddb8-bvbm7 True 37s │ └─MachineInfrastructure - vcdMachine/vcd-example-md-0-5zcvc ├─Machine/vcd-example-md-0-68b86fddb8-k9499 True 37s │ └─MachineInfrastructure - vcdMachine/vcd-example-md-0-k8h5p └─Machine/vcd-example-md-0-68b86fddb8-l6vfb True 37s └─MachineInfrastructure - vcdMachine/vcd-example-md-0-9h5vn
NOTE: After moving the cluster lifecycle services to the workload cluster, remember to use
dkp
with the workload cluster kubeconfig.
Delete the Workload Cluster
Evict all workloads that use Persistent Volumes.
We recommend usingdkp
with the bootstrap cluster to delete all worker node pools. This evicts all workloads that use Persistent Volumes. See information on Cloud Director Delete Node Pools.
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. Information for backup of a cluster and PVs is on the page in documentation called Back up your Cluster's Applications and Persistent Volumes .
Use
dkp
with the bootstrap cluster to delete the workload cluster. Delete 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
.CODEdkp delete cluster --kubeconfig $HOME/.kube/config --cluster-name ${CLUSTER_NAME}
CODE✓ Deleting Services with type LoadBalancer for Cluster default/vcd-example ✓ Deleting ClusterResourceSets for Cluster default/vcd-example ✓ Deleting cluster resources ✓ Waiting for cluster to be fully deleted Deleted default/vcd-example cluster
After the workload cluster is deleted, delete the bootstrap cluster.
Delete the Bootstrap Cluster
Delete the bootstrap cluster using
dkp delete
:
dkp delete bootstrap --kubeconfig $HOME/.kube/config
✓ Deleting bootstrap cluster
Delete a Managed Cluster
In the CLI, using the kubeconfig
for the Managed cluster that you want to delete. In order to properly delete a Managed cluster, you must first delete the PVCs using these steps:
Export your workspace namespace:
CODEexport WORKSPACE_NAMESPACE=<your-workspace-namespace>
Get all of the PVCs that you need to delete from the Applications deployed by Kommander:
CODEkubectl get pvc --namespace ${WORKSPACE_NAMESPACE}
Delete those PVCs and the Managed cluster deletion process will continue:
CODEkubectl delete pvc --namespace ${WORKSPACE_NAMESPACE} <pvc-name-1> <pvc-name-2>
Known Limitations
The DKP version used to create the workload cluster must match the DKP version used to delete the workload cluster.