<button class="button button-with-icon cloud-select-dropdown__button button-primary" aria-haspopup="true">Version 1.9 (unsupported)</button>

- [Latest](https://docs.cloud.google.com/anthos/clusters/docs/bare-metal/latest/how-to/reset-clusters)
- [Version 1.16](https://docs.cloud.google.com/anthos/clusters/docs/bare-metal/1.16/how-to/reset-clusters)
- [Earlier versions (unsupported)](https://docs.cloud.google.com/anthos/clusters/docs/bare-metal/1.9/getting-support.md.txt#version-support)

<br />

## Reset clusters with `bmctl reset cluster`

When a cluster fails to install correctly, you can try to return the nodes to
a clean state by resetting the cluster. Resetting a cluster causes it to be
deleted. Once deleted, you can re-install the cluster after making any needed
configuration changes.

In the context of this document, resetting and deleting are used interchangeably.

### Reset self-managed clusters

To reset a cluster that manages itself, such as an admin cluster, issue the
following command:

```bash
bmctl reset --cluster CLUSTER_NAME
```

Replace `CLUSTER_NAME` with the name of the cluster you're
resetting.

### Reset user clusters

There are two ways to delete or reset user clusters, using `bmctl` or `kubectl`
respectively. Using `bmctl` is the recommended way to reset user clusters.

#### Use `bmctl` to reset a user cluster

Run the following command to reset a user cluster with `bmctl`:

```bash
bmctl reset --cluster CLUSTER_NAME --admin-kubeconfig ADMIN_KUBECONFIG_PATH
```

Replace the following:

- `CLUSTER_NAME`: the name of the user cluster you're
  resetting.

- `ADMIN_KUBECONFIG_PATH`: the path to the associated
  admin cluster's `kubeconfig` file. `bmctl` supports the use of `--kubeconfig`
  as an alias for the`--admin-kubeconfig` flag.

#### Use `kubectl` to delete a user cluster

To use `kubectl` to delete a user cluster, you must first delete the cluster
object, then its namespace. Otherwise, the jobs to reset machines can't be
created, and the deletion process might be stuck indefinitely.

To delete a user cluster with `kubectl`:

1. Run the following command to delete the cluster object:

   ```bash
   kubectl delete cluster CLUSTER_NAME -n CLUSTER_NAMESPACE \
       --kubeconfig ADMIN_KUBECONFIG_PATH
   ```

   Replace the following:
   - `CLUSTER_NAME`: the name of the user cluster you're
     deleting.

   - `CLUSTER_NAMESPACE`: the namespace for the
     cluster. By default, the cluster namespaces for Google Distributed Cloud
     are the name of the cluster prefaced with `cluster-`. For example, if
     you name your cluster `test`, the namespace has a name like
     `cluster-test`.

   - `ADMIN_KUBECONFIG_PATH`: the path to the associated
     admin cluster's `kubeconfig` file.

2. After the cluster is deleted successfully, run the following command to
   delete the namespace:

   ```bash
   kubectl delete namespace CLUSTER_NAMESPACE --kubeconfig ADMIN_KUBECONFIG_PATH
   ```

### Reset cluster details

Regardless of cluster type, the reset command applies to the entire cluster.
There is no option to specify a subset of nodes in a cluster.

Output from the `bmctl cluster reset` command looks similar to this sample:

    bmctl reset --cluster cluster1
    Creating bootstrap cluster... OK
    Deleting GKE Hub member admin in project my-gcp-project...
    Successfully deleted GKE Hub member admin in project my-gcp-project
    Loading images... OK
    Starting reset jobs...
    Resetting: 1    Completed: 0    Failed: 0
    ...
    Resetting: 0    Completed: 1    Failed: 0
    Flushing logs... OK

During the reset operation, `bmctl` first attempts to delete the GKE hub
membership registration, and then cleans up the affected nodes. During the
reset, storage mounts and data from the `anthos-system StorageClass`
are also deleted.

For all nodes, `bmctl` runs `kubeadm reset`, removes the tunnel interfaces
used for cluster networking, and deletes the following directories:

- `/etc/kubernetes`
- `/etc/cni/net.d`
- `/root/.kube`
- `/var/lib/kubelet`

For load balancer Nodes, `bmctl` also performs the following actions:

- Disables `keepalived` and `haproxy` services.
- Deletes the configuration files for `keepalived` and `haproxy`.

The `bmctl reset` command expects the cluster configuration file to be in the
current working directory. By default, the path is like the following:
`bmctl-workspace/CLUSTER_NAME/CLUSTER_NAME.yaml`

If you used the `--workspacel-dir` flag to specify a different directory during
cluster creation, you must use the flag to specify the working directory during
cluster reset.