Last modified September 29, 2021

Delete a cluster using gsctl

gsctl and the REST API are being phased out. We don't have an end-of-life date yet. However, we recommend to familiarize yourself with our Management API and the kubectl gs plugin as a future-proof replacement.

Deleting a cluster means that all workloads running on the cluster are terminated. Both control plane and worker nodes are deprovisioned. All data stored on the nodes will be deleted.

Caution: There is no way to undo the deletion of a cluster. All data stored on the nodes will be lost.

Command usage

To delete a cluster, issue a command like below, applying the ID of the cluster you want to delete:

gsctl delete cluster --cluster f01r4

You can also use the cluster’s name for identifying the cluster:

gsctl delete cluster --cluster "Cluster name"

You will be asked for confirmation that you really want to delete the cluster.

To prevent the interactive confirmation, you can use the --force flag. This will simplify the use in a non-interactive scenario. Example:

gsctl delete cluster --force --cluster f01r4

Argument reference

  • --force: Disable any confirmations.
  • --output: By specifying this flag with value json, the output can be printed in JSON format. Disables any confirmations. This is convenient for use in automation. See JSON output for examples.

JSON output

Passing flag --output with value json to gsctl delete cluster changes the printed output to be formatted as a JSON object.

Example success output:

{
  "result": "deletion scheduled",
  "id": "f01r4"
}

Example error output:

{
  "result": "error",
  "id": "",
  "error": {
    "kind": "CouldNotDeleteClusterError",
    "annotation": "Unauthorized",
    "stack": [
      {
        "file": "/go/src/giantswarm/gsctl/commands/delete/cluster/command.go",
        "line": 295
      }
    ]
  }
}