Skip to main content
Skip table of contents

Azure Delete Cluster

Delete the Kubernetes cluster and clean up your environment

Prepare to delete a self-managed workload cluster

NOTE: 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, proceed to Delete the workload cluster section below.

  1. 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 explicit kubeconfig paths and contexts.

CODE
dkp create bootstrap --kubeconfig $HOME/.kube/config
CODE
✓ Creating a bootstrap cluster
✓ Initializing new CAPI components

2. 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.

CODE
dkp move capi-resources \
    --from-kubeconfig ${CLUSTER_NAME}.conf \
    --from-context ${CLUSTER_NAME}-admin@${CLUSTER_NAME} \
    --to-kubeconfig $HOME/.kube/config \
    --to-context kind-konvoy-capi-bootstrapper
CODE
✓ Moving cluster resources

3. Use the cluster lifecycle services on the workload cluster to check the workload cluster status:

CODE
dkp describe cluster --kubeconfig $HOME/.kube/config -c ${CLUSTER_NAME}
CODE
NAME                                                              READY  SEVERITY  REASON  SINCE  MESSAGE
Cluster/azure-example                                             True                     15s
├─ClusterInfrastructure - AzureCluster/azure-example              True                     29s
├─ControlPlane - KubeadmControlPlane/azure-example-control-plane  True                     15s
│ ├─Machine/azure-example-control-plane-gvj5d                     True                     22s
│ ├─Machine/azure-example-control-plane-l8j9r                     True                     23s
│ └─Machine/azure-example-control-plane-xhxxg                     True                     23s
└─Workers
  └─MachineDeployment/azure-example-md-0                          True                     35s
	├─Machine/azure-example-md-0-d67567c8b-2674r                  True                     24s
	├─Machine/azure-example-md-0-d67567c8b-n276j                  True                     25s
	├─Machine/azure-example-md-0-d67567c8b-pzg8k                  True                     23s
	└─Machine/azure-example-md-0-d67567c8b-z8km9                  True                     24s

NOTE: After 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.

  1. Wait for the cluster control-plane to be ready:

    CODE
    kubectl --kubeconfig $HOME/.kube/config wait --for=condition=controlplaneready "clusters/${CLUSTER_NAME}" --timeout=60m

    CODE
    cluster.cluster.x-k8s.io/azure-example condition met

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.

Delete the workload cluster

  1. Make sure your Azure credentials are up to date. Refresh the credentials using this command:

    CODE
    dkp update bootstrap credentials azure --kubeconfig $HOME/.kube/config

  2. 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.

    CODE
    dkp delete cluster --cluster-name=${CLUSTER_NAME} --kubeconfig $HOME/.kube/config

    CODE
    ✓ Deleting Services with type LoadBalancer for Cluster default/azure-example
    ✓ Deleting ClusterResourceSets for Cluster default/azure-example
    ✓ Deleting cluster resources
    ✓ Waiting for cluster to be fully deleted
    Deleted default/azure-example cluster

    After the workload cluster is deleted, delete the bootstrap cluster.

Delete the bootstrap cluster

CODE
dkp delete bootstrap --kubeconfig $HOME/.kube/config
CODE
✓ Deleting bootstrap cluster

Known Limitations

NOTE: Be aware of these limitations in the current release of Konvoy.

  • The Konvoy version used to create the workload cluster must match the Konvoy version used to delete the workload cluster.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.