# Restore a deleted cluster

Bring back a cluster deleted in the last 7 days from its final etcd snapshot, or purge what it kept.

Replace _my-cluster_ with the deleted cluster's name. When several deleted clusters have the name,
use its id (`ewk-…`).

## Prerequisites

- To list deleted clusters, `eks:ListClusters`. To restore, `eks:RestoreCluster` on the cluster; to
  purge, `eks:DeleteCluster` on it.
- A cluster deleted without `permanent`, whose final snapshot was taken and verified, less than 7
  days ago.

## Restore it

**Console**
1. Open **Kubernetes**. Under **Recently deleted**, find the cluster.
2. Choose **Restore**.
3. In the dialog, enter the cluster name, and choose **Restore**.

**CLI**
```sh
dcloud eks deleted-clusters list
dcloud eks deleted-clusters restore my-cluster --confirm my-cluster
```

**API**
```http
POST /eks/api/deleted-clusters/my-cluster/restore
{ "confirm": "my-cluster" }
```

## Result

The answer is `202` with the cluster in status `creating`, under the same id and name.
Deutsche Cloud builds its control plane again from the final snapshot, with the same CA, keys and
endpoint name, so kubeconfigs and in-cluster credentials keep working; then its node groups'
nodes. Its node groups, access entries, add-ons and pod identity associations come back. The kept
volumes attach again when their pods are scheduled.

Two things may change: the endpoint's address (it gets a new load balancer; the name follows it),
and the addresses of the Services' load balancers, which are made again. The cluster counts in your quota
from the restore on, and its control-plane fee runs again once it is `active`. The kept volumes are
billed again from the restore on.

## Purge it now

Purging deletes the final snapshot, the key material and the kept volumes at once. The cluster can
no longer be restored. Otherwise this happens 7 days after the deletion.

**Console**
1. Open **Kubernetes**. Under **Recently deleted**, choose **Purge now** on the cluster.
2. Enter the cluster name, and choose **Purge**.

**CLI**
```sh
dcloud eks deleted-clusters purge my-cluster --confirm my-cluster
```

**API**
```http
POST /eks/api/deleted-clusters/my-cluster/purge
{ "confirm": "my-cluster" }
```

A purge that could not delete every part answers `502`; ask again.

## Refusals

- `400` "Confirm with the cluster’s name (_my-cluster_)".
- `409` "Several deleted clusters have this name; use the id (ewk-…)".
- `409` on restore when the retention has ended, the final snapshot is gone, another cluster has
  the name, the Kubernetes minor is no longer offered, the network no longer exists, or the
  clusters quota is full.

## Related

- [Delete a cluster](delete-a-cluster.md)
- `eks.deleted-clusters.restore` · `dcloud eks deleted-clusters restore` · `dcloud eks deleted-clusters purge`
