# Uninstall StackState

## Overview

1. [Uninstall the Helm cart](#un-install-the-helm-chart)
2. [Remove remaining resources](#remove-remaining-resources)
3. [Remove manually created resources](#remove-manually-created-resources)

## Un-install the Helm chart

{% hint style="info" %}
Un-installing the helm chart will preserve all data because helm will not remove the Persistent Volume Claims nor the namespace. To remove those as well also [remove the remaining resources](#remove-remaining-resources).
{% endhint %}

To un-install StackState the first action is to run the `helm uninstall` command. This command will remove all resources created by the `helm upgrade --install` command.

Uninstall the `stackstate` release from the `stackstate` namespace like this, replace the namespace or release name with any custom names used during installation:

```
helm uninstall --namespace stackstate stackstate
```

The command will return almost immediately but shutting down all the pods and removing all other resources can take a while. Check if all pods are gone with:

```
kubectl get pods --namespace stackstate
```

If you want to re-install StackState later and have the old data still available this is all, for a full uninstall continue with the next 2 sections.

## Remove remaining resources

{% hint style="warning" %}
Removing the Persistent Volume Claims and/or the namespace will result in all data being lost that was stored in StackState.
{% endhint %}

To remove the namespace and with that, the Persistent Volume Claims and their linked Persistent Volumes simply remove the entire namespace:

```
kubectl delete namespace stackstate
```

When the command returns the namespace and all volumes will have been removed.

To only remove the Persistent Volume Claims (PVCs) and keep the namespace run:

```
kubectl delete pvc --all -n stackstate
```

On OpenShift the Helm chart also created a security context constraint (SCC). It is not cleaned up automatically by Helm but instead needs to be manually removed:

```
# The scc is always named stackstate-k8s-<namespace>
oc delete scc stackstate-k8s-stackstate
```

## Remove manually created resources

{% hint style="info" %}
Even if you intend to re-install StackState on the same cluster but in a different namespace these can be removed. The resources contain references to the StackState namespace.
{% endhint %}

As described in the [required permissions](/self-hosted-setup/install-stackstate/kubernetes_openshift/required_permissions.md#manually-create-cluster-wide-resources) it might have been necessary that your cluster admin created some resources manually. These resources can now be removed again, but that also is a manual task that requires admin permission.

Delete the cluster role and the cluster role bindings that have been created like this:

```
kubectl delete cluster-role stackstate-authorization
kubectl delete cluster-role-binding stackstate-authorization
kubectl delete cluster-role-binding stackstate-authentication
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://archivedocs.stackstate.com/self-hosted-setup/uninstall.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
