# Why does Okteto delete my Kubernetes resources when I click “Destroy All”? How can I prevent that?

**URL:** https://community.okteto.com/t/why-does-okteto-delete-my-kubernetes-resources-when-i-click-destroy-all-how-can-i-prevent-that/1458
**Category:** How Do I?
**Created:** [March 27, 2026, 5:50pm UTC](https://community.okteto.com/t/why-does-okteto-delete-my-kubernetes-resources-when-i-click-destroy-all-how-can-i-prevent-that/1458 "2026-03-27T17:50:39Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![ramiro](https://sea1.discourse-cdn.com/flex019/user_avatar/community.okteto.com/ramiro/32/6_2.png) [@ramiro](https://community.okteto.com/u/ramiro)
#### Post date: [March 27, 2026, 5:50pm UTC](https://community.okteto.com/t/why-does-okteto-delete-my-kubernetes-resources-when-i-click-destroy-all-how-can-i-prevent-that/1458/1 "2026-03-27T17:50:39Z")

</div>

I ran into this today. I hit the “Destroy” button in Okteto expecting a clean reset of my environment, and it wiped out all resources, even when ones that were not displayed in the UI (e.g. a volume snapshot)

How do I prevent that?

---

<div class="post-metadata">

### Author: ![ramiro](https://sea1.discourse-cdn.com/flex019/user_avatar/community.okteto.com/ramiro/32/6_2.png) [@ramiro](https://community.okteto.com/u/ramiro)
#### Post date: [March 27, 2026, 5:51pm UTC](https://community.okteto.com/t/why-does-okteto-delete-my-kubernetes-resources-when-i-click-destroy-all-how-can-i-prevent-that/1458/2 "2026-03-27T17:51:16Z")

</div>

If you’re using **Okteto** and hit the **“Destroy All”** button (or run the `okteto destroy --all`), you might be surprised to see important Kubernetes resources disappear along with everything else.

Here’s how to prevent that 👇

### 🛑 The problem

`Destroy All` (`okteto destroy --all`) is designed to clean up _everything_ in your namespace:

- Deployments
- Services
- Helm releases
- Pipeline resources

That’s great for cleanup… but not if you have shared or persistent resources (like secrets, databases, or config maps) you want to keep.

### ✅ The solution

Annotate any resource you want to preserve with:

```yaml
metadata:
  annotations:
    dev.okteto.com/policy: keep

```

### 🔒 Example

```yaml
apiVersion: v1
kind: Secret
metadata:
  name: my-important-secret
  annotations:
    dev.okteto.com/policy: keep

```

With this annotation in place, Okteto will **skip deleting this resource** during `Destroy All`.

### 💡 When to use this

This is especially useful for:

- Shared databases
- API keys / secrets
- Persistent configs
- Anything managed outside your dev lifecycle

### ⚠ Tip

Be intentional about what you mark as `keep`. If overused, your environment can drift from a clean state.

* * *

Simple trick, but it can save you from painful data loss 👍
