# How to Destroy DigitalOcean Kubernetes Clusters DigitalOcean Kubernetes (DOKS) is a Kubernetes service with a fully managed control plane, high availability, and autoscaling. DOKS integrates with standard Kubernetes toolchains and DigitalOcean’s load balancers, volumes, CPU and GPU Droplets, API, and CLI. ## Destroy a Cluster Using Automation ## How to Delete a Kubernetes Cluster Using the DigitalOcean CLI 1. [Install `doctl`](https://docs.digitalocean.com/reference/doctl/how-to/install/index.html.md), the official DigitalOcean CLI. 2. [Create a personal access token](https://docs.digitalocean.com/reference/api/create-personal-access-token/index.html.md) and save it for use with `doctl`. 3. Use the token to grant `doctl` access to your DigitalOcean account. ```shell doctl auth init ``` 4. Finally, run `doctl kubernetes cluster delete`. Basic usage looks like this, but you can [read the usage docs](https://docs.digitalocean.com/reference/doctl/reference/kubernetes/cluster/delete/index.html.md) for more details: ```shell doctl kubernetes cluster delete ... [flags] ``` The following example deletes a cluster named `example-cluster`: ```shell doctl kubernetes cluster delete example-cluster ``` ## How to Delete a Kubernetes Cluster Using the DigitalOcean API 1. [Create a personal access token](https://docs.digitalocean.com/reference/api/create-personal-access-token/index.html.md) and save it for use with the API. 2. Send a DELETE request to [`https://api.digitalocean.com/v2/kubernetes/clusters/{cluster_id}`](https://docs.digitalocean.com/reference/api/digitalocean//index.html.md#operation/kubernetes_delete_cluster). ### cURL Using cURL: ```shell curl -X DELETE \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ "https://api.digitalocean.com/v2/kubernetes/clusters/bd5f5959-5e1e-4205-a714-a914373942af" ``` ### Go Using [Godo](https://github.com/digitalocean/godo), the official DigitalOcean API client for Go: ```go import ( "context" "os" "github.com/digitalocean/godo" ) func main() { token := os.Getenv("DIGITALOCEAN_TOKEN") client := godo.NewFromToken(token) ctx := context.TODO() _, err := client.Kubernetes.Delete(ctx, "bd5f5959-5e1e-4205-a714-a914373942af") } ``` ### Ruby Using [DropletKit](https://github.com/digitalocean/droplet_kit), the official DigitalOcean API client for Ruby: ```ruby require 'droplet_kit' token = ENV['DIGITALOCEAN_TOKEN'] client = DropletKit::Client.new(access_token: token) client.kubernetes_clusters.delete(id: 'bd5f5959-5e1e-4205-a714-a914373942af') ``` ### Python Using [PyDo](https://github.com/digitalocean/pydo), the official DigitalOcean API client for Python: ```python import os from pydo import Client client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN")) resp = client.kubernetes.delete_cluster(cluster_id="da8fda8") ``` ## Destroy a Cluster Using the Control Panel To destroy a cluster, go to the Kubernetes page in the [control panel](https://cloud.digitalocean.com). From the cluster’s **More** menu, select **Destroy** and click **Destroy**. In the Destroy Kubernetes cluster dialog box, select the resources, such as load balancers and volumes, associated with the cluster to delete them automatically when the cluster is deleted. Enter the name of the cluster, then click **Destroy** to confirm. ![Destroy Kubernetes cluster dialog box with options to select associated load balancers and volumes for deletion.](https://docs.digitalocean.com/screenshots/kubernetes/delete-cluster.838dd6e93c7d173f96f0ce2092c87ce60e013de8ae6b97adc2cf8cfd054c5a54.png) You can also delete the associated load balancers and volumes manually from the control panel after the cluster is destroyed. You will continue to be billed until the resources are destroyed . You can also use [`doctl`](https://docs.digitalocean.com/reference/doctl/reference/kubernetes/cluster/delete/index.html.md) or the [API](https://developers.digitalocean.com/documentation/v2/#delete-a-kubernetes-cluster) to delete the associated resources automatically when you destroy a cluster.