Skip to main content
Skip table of contents

Delete a GCP Cluster

Prepare to Delete a 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 the New GCP Cluster Self-Managed, proceed to the 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 --with-gcp-bootstrap-credentials=true --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 \
        --to-kubeconfig $HOME/.kube/config
  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/gcp-example                                                       True                     34s
    ├─ClusterInfrastructure - GCPCluster/gcp-example
    ├─ControlPlane - KubeadmControlPlane/gcp-example-control-plane            True                     34s
    │ ├─Machine/gcp-example-control-plane-6fbzn                               True                     37s
    │ │ └─MachineInfrastructure - GCPMachine/gcp-example-control-plane-62g6s
    │ ├─Machine/gcp-example-control-plane-jf6s2                               True                     37s
    │ │ └─MachineInfrastructure - GCPMachine/gcp-example-control-plane-bsr2z
    │ └─Machine/gcp-example-control-plane-mnbfs                               True                     37s
    │   └─MachineInfrastructure - GCPMachine/gcp-example-control-plane-s8xsx
    └─Workers
      └─MachineDeployment/gcp-example-md-0                                    True                     37s
        ├─Machine/gcp-example-md-0-68b86fddb8-8glsw                           True                     37s
        │ └─MachineInfrastructure - GCPMachine/gcp-example-md-0-zls8d
        ├─Machine/gcp-example-md-0-68b86fddb8-bvbm7                           True                     37s
        │ └─MachineInfrastructure - GCPMachine/gcp-example-md-0-5zcvc
        ├─Machine/gcp-example-md-0-68b86fddb8-k9499                           True                     37s
        │ └─MachineInfrastructure - GCPMachine/gcp-example-md-0-k8h5p
        └─Machine/gcp-example-md-0-68b86fddb8-l6vfb                           True                     37s
          └─MachineInfrastructure - GCPMachine/gcp-example-md-0-9h5vn

    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.

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. To delete a cluster, you would use dkp delete cluster and pass in the name of the cluster you are trying to delete with --cluster-name flag. You would use kubectl get clusters to get those details (--cluster-name and --namespace) of the Kubernetes cluster to delete it.
    NOTE: Do not use dkp get clusters since that gets you Kommander cluster details rather than Konvoy kubernetes cluster details.

    CODE
    kubectl get clusters

     

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

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

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

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

Delete the Bootstrap Cluster

  1. Delete the bootstrap cluster using dkp delete:

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

Next Step:

Once your cluster is built in the Konvoy component of DKP for your infrastructure/environment, you will install the Kommander component of DKP to see your dashboard and continue customization.

Known Limitations

Be aware of these limitations in the current release of DKP.

The DKP version used to create the workload cluster must match the DKP 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.