> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gcore.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Delete a GPU Kubernetes cluster

export const MethodSection = ({children}) => children ?? null;

export const MethodSwitch = ({children}) => {
  const tabs = React.Children.toArray(children).map(c => {
    if (!c || !c.props) return null;
    if (c.props.id) return c;
    const inner = c.props.children;
    if (inner && inner.props && inner.props.id) return inner;
    return null;
  }).filter(Boolean);
  const firstId = tabs.length > 0 ? tabs[0].props.id : "";
  const [active, setActive] = React.useState(firstId);
  React.useEffect(() => {
    try {
      const saved = localStorage.getItem("gcore_docs_method");
      if (saved && tabs.find(t => t.props.id === saved)) {
        setActive(saved);
      }
    } catch (_) {}
  }, []);
  React.useEffect(() => {
    try {
      document.querySelectorAll("h2[id], h3[id]").forEach(heading => {
        const visible = heading.offsetParent !== null;
        document.querySelectorAll(`a[href="#${heading.id}"]`).forEach(link => {
          if (link.closest("h1,h2,h3,h4,h5,h6")) return;
          const li = link.closest("li");
          if (li) li.style.display = visible ? "" : "none";
        });
      });
    } catch (_) {}
    window.dispatchEvent(new Event("scroll"));
  }, [active]);
  const handleClick = id => {
    setActive(id);
    try {
      localStorage.setItem("gcore_docs_method", id);
    } catch (_) {}
  };
  return <div>
      <div className="not-prose flex gap-0 border-b border-zinc-200 dark:border-zinc-800 mb-8 mt-2" role="tablist">
        {tabs.map(tab => {
    const isActive = active === tab.props.id;
    return <button key={tab.props.id} role="tab" aria-selected={isActive} onClick={() => handleClick(tab.props.id)} className={["px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors cursor-pointer", isActive ? "border-primary text-primary" : "border-transparent text-zinc-500 hover:text-zinc-800 dark:hover:text-zinc-200"].join(" ")}>
              {tab.props.label}
            </button>;
  })}
      </div>

      {tabs.map(tab => <div key={tab.props.id} style={{
    display: active === tab.props.id ? "" : "none"
  }}>
          {tab.props.children}
        </div>)}
    </div>;
};

<MethodSwitch>
  <MethodSection id="portal" label="Customer Portal">
    <p>Cluster deletion removes all nodes, pools, and associated resources. External resources — Object Storage buckets and Persistent Volumes created outside the cluster — are not affected.</p>

    <Warning>
      Cluster deletion is irreversible. Export the kubeconfig and back up any required data before proceeding.
    </Warning>

    <Steps>
      <Step title="Navigate to the cluster overview" />

      <Step title="Click Delete cluster" />

      <Step title="Type Delete in the confirmation field">
        <Frame>
          <img src="https://mintcdn.com/gcore/c2W3cwtGjSbFG_V1/images/docs/edge-ai/managed-kubernetes/manage-node-pools/delete-cluster-dialog.png?fit=max&auto=format&n=c2W3cwtGjSbFG_V1&q=85&s=36c2388cb391d505ddeb50741a10d4e2" alt="Delete cluster confirmation dialog requiring 'Delete' text input" width="649" height="322" data-path="images/docs/edge-ai/managed-kubernetes/manage-node-pools/delete-cluster-dialog.png" />
        </Frame>
      </Step>

      <Step title="Click Yes, delete" />
    </Steps>
  </MethodSection>

  <MethodSection id="api" label="REST API">
    <p>Deletes the cluster, all its node pools, and associated control plane resources. External storage is not deleted.</p>

    <Info>
      An [API token](/account-settings/api-tokens) is required, along with a
      [project ID](/api-reference/cloud/projects/list-projects)
      and a [region ID](/api-reference/cloud/regions/list-regions).
    </Info>

    <p>Set these environment variables before running the examples:</p>

    ```bash theme={null}
    export GCORE_API_KEY="{YOUR_API_KEY}"
    export GCORE_CLOUD_PROJECT_ID="{YOUR_PROJECT_ID}"
    export GCORE_CLOUD_REGION_ID="{YOUR_REGION_ID}"
    export GCORE_CLUSTER_NAME="{YOUR_CLUSTER_NAME}"
    ```

    ## Delete the cluster

    <p>Submits a deletion request. The operation runs asynchronously — poll the task until it finishes.</p>

    <Warning>
      Cluster deletion is irreversible. Download the kubeconfig and back up any required data before proceeding.
    </Warning>

    <Tabs>
      <Tab title="Python SDK">
        ```python theme={null}
        import os
        import time
        from gcore import Gcore

        client = Gcore(api_key=os.environ["GCORE_API_KEY"])
        PROJECT = int(os.environ["GCORE_CLOUD_PROJECT_ID"])
        REGION = int(os.environ["GCORE_CLOUD_REGION_ID"])
        CLUSTER = os.environ["GCORE_CLUSTER_NAME"]

        task_list = client.cloud.k8s.clusters.delete(
            cluster_name=CLUSTER,
            project_id=PROJECT,
            region_id=REGION,
        )
        task_id = task_list.tasks[0]

        while True:
            task = client.cloud.tasks.get(task_id)
            if task.state == "FINISHED":
                print("Cluster deleted.")
                break
            if task.state == "ERROR":
                raise RuntimeError(f"Deletion failed: {task}")
            time.sleep(15)
        ```
      </Tab>

      <Tab title="Go SDK">
        ```go theme={null}
        package main

        import (
        	"context"
        	"fmt"
        	"os"
        	"strconv"
        	"time"

        	gcore "github.com/G-Core/gcore-go"
        	"github.com/G-Core/gcore-go/cloud"
        	"github.com/G-Core/gcore-go/option"
        )

        func main() {
        	projectID, _ := strconv.ParseInt(os.Getenv("GCORE_CLOUD_PROJECT_ID"), 10, 64)
        	regionID, _ := strconv.ParseInt(os.Getenv("GCORE_CLOUD_REGION_ID"), 10, 64)
        	clusterName := os.Getenv("GCORE_CLUSTER_NAME")

        	client := gcore.NewClient(option.WithAPIKey(os.Getenv("GCORE_API_KEY")))

        	taskList, err := client.Cloud.K8S.Clusters.Delete(
        		context.TODO(),
        		clusterName,
        		cloud.K8SClusterDeleteParams{
        			ProjectID: gcore.Int(projectID),
        			RegionID:  gcore.Int(regionID),
        		},
        	)
        	if err != nil {
        		panic(err)
        	}
        	taskID := taskList.Tasks[0]

        	for {
        		task, err := client.Cloud.Tasks.Get(context.TODO(), taskID)
        		if err != nil {
        			panic(err)
        		}
        		if task.State == "FINISHED" {
        			fmt.Println("Cluster deleted.")
        			break
        		}
        		if task.State == "ERROR" {
        			panic(fmt.Sprintf("Deletion failed: %+v", task))
        		}
        		time.Sleep(15 * time.Second)
        	}
        }
        ```
      </Tab>

      <Tab title="curl">
        ```bash theme={null}
        curl -X DELETE "https://api.gcore.com/cloud/v2/k8s/clusters/$GCORE_CLOUD_PROJECT_ID/$GCORE_CLOUD_REGION_ID/$GCORE_CLUSTER_NAME" \
          -H "Authorization: APIKey $GCORE_API_KEY"
        ```

        Response:

        ```json theme={null}
        {"tasks": ["d3b8f2a1-4c5e-6789-abcd-ef0123456789"]}
        ```

        <p>Run <code>GET /cloud/v1/tasks/{task_id}</code> every 15 seconds until `state` is `FINISHED`.</p>
      </Tab>
    </Tabs>
  </MethodSection>
</MethodSwitch>
