# Uninstall the agent

> Remove the LevelFour agent from a Kubernetes cluster, disconnect the cluster in the dashboard and clear the namespace labels.

Source: https://docs.levelfour.ai/kubernetes/uninstall


### Remove the agent

**Helm**

```bash
helm uninstall levelfour-agent -n levelfour
kubectl delete namespace levelfour
```

**Argo CD**

```bash
argocd app delete levelfour-agent --cascade
kubectl delete namespace levelfour
```

If an app of apps or an ApplicationSet creates the Application, remove it from that source instead, or Argo CD creates it again.

**Flux**

Remove the HelmRelease and the OCIRepository from your repository. When Flux deletes the HelmRelease, it uninstalls the release. Then delete the namespace:

```bash
kubectl delete namespace levelfour
```

**Terraform**

Remove the `helm_release` and apply. Then delete the namespace:

```bash
kubectl delete namespace levelfour
```

This removes everything the chart created, including the ClusterRole and its binding. Deleting the namespace also removes the Secret that holds the token or install key.

### Disconnect the cluster

Disconnect the cluster on **Connect Providers > Kubernetes**. For a cluster installed with Helm, this revokes its token. Disconnecting frees the cluster's name for reuse.

Remove the agent first. An agent that keeps running with an install key logs `409 cluster_disconnected` after you disconnect its cluster. The install key keeps working for your other clusters, so [revoke it](/kubernetes/gitops#revoke-an-install-key) only when no cluster uses it.

### Remove the namespace labels

The `levelfour.ai/recommendations` labels on your namespaces do nothing once the agent is gone. To remove them too:

```bash
kubectl label namespace --all levelfour.ai/recommendations-
```
