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

# Uninstall koperator

> Choose what happens to your agents when you uninstall koperator, and recover from a failed uninstall.

`helm uninstall` runs a hook first. It stops koperator, applies `uninstall.policy` to every agent
that koperator applied, reports the result to the Komodor Agentic Operation Platform (KAOP), and
releases koperator's namespace claims. Set the policy in your values before you uninstall.

## Choose the uninstall policy

| `uninstall.policy` | The agents | To manage them again |
| - | - | - |
| `keep` (default) | Keep running. No pod restarts. | Install koperator again; a developer [adopts](https://docs.komodor.com/manage-your-agents/build/koperator/adopt-helm-agents.md) each agent. |
| `scale_to_zero` | Scale to zero. Koperator deletes their ScaledObjects and TriggerAuthentications so KEDA cannot scale them up. | Install koperator again; adoption scales each agent back up. |
| `delete` | Koperator deletes the objects it applied for each agent. | Install koperator again on the same deploy target: it applies each agent again from KAOP. |

`keep` is the default because an accidental uninstall cannot turn it into an outage. `delete` never
deletes an object koperator did not apply, such as a Secret you labelled `agent-usable`. In every
case the agent stays in KAOP with its worker token. To revoke the token, delete the agent in KAOP:
that is the kill switch that works even when the hook does not run.

With `keep` or `scale_to_zero`, each agent's **Deployment** panel shows **Unmanaged on** the deploy
target, and its open changes are closed. With `keep`, KAOP also discards each open [revision](https://docs.komodor.com/manage-your-agents/build/koperator/deploy-agents.md#revisions-on-a-deploy-target)
on the deploy target: its objects stay but get no traffic, and its worker token is revoked. Remove
them with:

```sh theme={null}
kubectl -n <namespace> delete deployments,scaledobjects,triggerauthentications,serviceaccounts,secrets \
  -l agentops.komodor.io/revision-of=<agent>
```

## When the uninstall fails

If the policy fails for an agent, the hook starts koperator again and fails, so `helm uninstall`
stops and the release stays. Read the hook log, fix the cause and run `helm uninstall` again:

```sh theme={null}
kubectl -n agentops logs job/koperator-<name>-uninstall
```

If KAOP does not answer, the hook retries for one minute and then continues without the report. If
the policy succeeds but the hook cannot delete a namespace claim, the hook fails after its report and
koperator stays stopped; the log gives the `kubectl delete lease` command. If you deleted a managed
namespace first, the hook cannot start: uninstall without it, as below.

## Uninstall without the hook

To uninstall without the hook, use `helm uninstall --no-hooks`. Koperator then applies no policy, the
agents keep running, and the claims stay. Delete the claims before you install again:

```sh theme={null}
kubectl -n <namespace> delete lease koperator-claim            # each managed namespace
kubectl -n kube-system delete lease koperator-cluster-claim    # cluster-wide mode
```

## Next steps

> [card] [Argo CD and Flux](https://docs.komodor.com/manage-your-agents/build/koperator/gitops.md)
>
> A GitOps tool can skip the uninstall hook.

> [card] [Install koperator](https://docs.komodor.com/manage-your-agents/build/koperator/install.md)
>
> Install koperator again on a deploy target.


## Related topics

- [Koperator](https://docs.komodor.com/manage-your-agents/build/koperator/overview.md)
- [Adopt agents installed with Helm](https://docs.komodor.com/manage-your-agents/build/koperator/adopt-helm-agents.md)
- [Configure koperator](https://docs.komodor.com/manage-your-agents/build/koperator/configure.md)
- [Install koperator on a deploy target](https://docs.komodor.com/manage-your-agents/build/koperator/install.md)
- [Argo CD and Flux](https://docs.komodor.com/manage-your-agents/build/koperator/gitops.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.