# Uninstalling Connectware Agents with the connectware-agent Helm Chart

## Prerequisites

* [Helm version 3](https://helm.sh/docs/intro/quickstart/#install-helm) is installed on your system.
* [kubectl](https://kubernetes.io/docs/tasks/tools/#kubectl) is installed on your system.
* kubectl configured with the current context pointing to your target cluster ([Configure Access to Multiple Clusters](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/)).

## Uninstalling All Agents from One Installation

To remove all agents installed with the `connectware-agent` Helm chart, run the `helm uninstall` command followed by the name of your installation (also known as the *release*). You assigned this name yourself when deploying with the `connectware-agent` chart.

In the examples provided in this documentation, the release is called `connectware-agent`. If you’re unsure of the name you chose, you can look it up by running `helm list` for the namespace where you installed your agents.

**Example**

{% code lineNumbers="true" %}

```bash
helm list -n ${NAMESPACE}
```

{% endcode %}

{% code lineNumbers="true" %}

```yaml
NAME             	NAMESPACE	REVISION	UPDATED                                	STATUS  	CHART                    	APP VERSION
connectware-agent	<namespace>	1       	2023-03-29 14:49:49.29654165 +0200 CEST	deployed	connectware-agent-2.1.0 	2.1.0
```

{% endcode %}

Once you determined the name of your installation, you can uninstall it.

**Example**

{% code lineNumbers="true" %}

```bash
helm uninstall -n ${NAMESPACE} connectware-agent
```

{% endcode %}

This terminates running pods and removes their Kubernetes objects, however `PersistentVolumeClaims`, and with them the Persistent Volumes are retained. If you wish to clean them up, you can do so by using the label `app.kubernetes.io/instance` in combination with `kubectl delete`. The value for this label is again the release name you already used to uninstall.

**Example**

{% code lineNumbers="true" %}

```bash
kubectl delete -n ${NAMESPACE} pvc -l app.kubernetes.io/instance=connectware-agent
```

{% endcode %}

## Uninstalling Single Agents from a Larger Installation

If you want to remove one or more agents from a larger group of agents installed using the `connectware-agent` Helm chart, you can remove their whole configuration from your `values.yaml` file and running a Helm upgrade as described in [Configuring agents with the connectware-agent Helm chart](https://docs.cybus.io/2-1-0/documentation/agents/agents-in-kubernetes/configuring-agents-with-the-connectware-agent-helm-chart).

**Example**

{% code lineNumbers="true" %}

```yaml
protocolMapperAgentDefaults:
  connectwareHost: connectware.cybus # adjust to actual hostname of Connectware
protocolMapperAgents:
  - name: bender-robots
    resources:
      limits:
        cpu: 2000m
        memory: 4000Mi
  - name: welder-robots # remove all configuration for this agent
    resources: #
      limits: #
        cpu: 500m #
        memory: 1000Mi #
  - name: painter-robots
    resources:
      limits:
        cpu: 1000m
        memory: 2000Mi
```

{% endcode %}
