> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/harness-platform/use-harness-platform/delegates/delegate/manage-delegates/delete-a-delegate.md).

# Delete a delegate

Learn how to safely delete Harness delegates from Kubernetes clusters and remove them from your Harness account.

This topic describes how to delete a delegate from your Kubernetes cluster and Harness installation.

#### Identify the delegate type <a href="#identify-the-delegate-type" id="identify-the-delegate-type"></a>

{% hint style="warning" %}
**DELEGATE-LEGACY: END OF SUPPORT (EOS)**

***

<details>

<summary>Upgrade Delegate-Legacy to Delegate image</summary>

This is an End of Support (EOS) notice for the Delegate-Legacy image type. This image type reached End of Support (EOS) as of **January 31, 2024**.

End of Support means the following:

* Harness Support will no longer accept support requests for the Delegate-Legacy image type in both Harness FirstGen and Harness NextGen (including Harness Self-Managed Enterprise Edition (SMP)).
* Security fixes will still be addressed.
* Product defects will not be addressed.

Follow the below steps to upgrade Delegate-Legacy to Delegate image:

* Download new yaml from Harness by keeping the same name as the previous delegate
* Check if the existing delegate has any tags/selector, if yes then add them in DELEGATE\_TAGS
* Compare the permissions given to the legacy delegate in their yaml and give the same permissions to new delegates
* Check if custom image is used, if yes then build a new image with immutable delegate as base image and override the account setting to point to that image
* Ensure that auto upgrade is enabled for Kubernetes delegates
* Our delegate yaml ships with default HPA of min and max replicas to be 1, adjust the desired number of replicas in HPA
* Deploy the new yaml and see new replicas coming under the same delegate
* Scale down the old stateful set and verify that everything is correct

</details>
{% endhint %}

Harness Delegate is installed as a Kubernetes [Deployment](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/deployment-v1/) object. A legacy delegate, on the other hand, is installed as a Kubernetes [StatefulSet](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/stateful-set-v1/) object. This means that the process used to delete a legacy delegate differs from the process used to delete Harness Delegate.

You can verify the delegate you are using by looking at its manifest file or by running `kubectl get all -n harness-delegate-ng`.

To delete a legacy delegate, go to the [Delete a legacy delegate](#delete-a-legacy-delegate) section.

#### Delete a delegate <a href="#delete-a-delegate" id="delete-a-delegate"></a>

Use the following process to delete a delegate.

**Step 1: Delete the deployment for the delegate**

To delete a delegate from your Kubernetes cluster, you delete the **Deployment** object that represents its deployment.

`kubectl delete deployment -n harness-delegate-ng <Deployment name>`

Use the following command to retrieve a list of deployments:

`kubectl get deployments`

The deployment name is specified in the `metadata.name` field of the Kubernetes manifest you used to install the delegate.

```yaml
...
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    harness.io/name: doc-demos
  name: doc-demos
  namespace: harness-delegate-ng
...
```

In this example, the `name` field is specified as `doc-demos`.

Next, delete the Updater **CronJob**:

`kubectl delete cronjob -n harness-delegate-ng <Deployment name>-upgrader-job`

For example, if the **Deployment** name is `quickstart-delegate`:

`kubectl delete cronjob -n harness-delegate-ng quickstart-delegate-upgrader-job`

**Step 2: Delete the delegate in Harness**

Locate the delegate in the Harness account/Project/Org, select more options (⋮), and then select **Delete**.

![](https://173309742-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3F2TpHXhur2QtQnORSM9%2Fuploads%2Fgit-blob-ea51330a0eef3ae806e3eca08e729401c812af67%2Fdelete-a-delegate-15.png?alt=media)

#### Delete replica pods <a href="#delete-replica-pods" id="delete-replica-pods"></a>

Deleted replica pods unregister and clear out during shutdown after they complete all running tasks if the graceful shutdown period is sufficient. The grace period is configurable. Go to [Graceful delegate shutdown](https://developer.harness.io/harness-platform/use-harness-platform/delegates/delegate/delegate-concepts/graceful-delegate-shutdown-process.md) to understand the graceful shutdown process.

If you do not delete the delegate in the UI, Harness automatically removes it after six hours.

#### Delete a legacy delegate <a href="#delete-a-legacy-delegate" id="delete-a-legacy-delegate"></a>

Use the following process to delete a legacy delegate.

**Step 1: Delete the StatefulSet for the delegate**

To delete a legacy delegate from your Kubernetes cluster, you delete the **StatefulSet** object that represents its deployment.

A **StatefulSet** resource is ensures that the desired number of pods are running and available at all times. If you delete a pod that belongs to a **StatefulSet** without deleting the **StatefulSet** itself, the pod is recreated.

For example, you can use the following command to delete the **StatefulSet** that created a delegate pod named `quickstart-vutpmk-0`:

`$ kubectl delete statefulset -n harness-delegate-ng quickstart-vutpmk`

The name of the delegate pod includes the name of the **StatefulSet** followed by the pod identifier `-0`.

**Step 2: Delete the delegate in Harness**

Locate the delegate in the Harness account/Project/Org, select more options (⋮), and then select **Delete**.

![](https://173309742-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3F2TpHXhur2QtQnORSM9%2Fuploads%2Fgit-blob-ea51330a0eef3ae806e3eca08e729401c812af67%2Fdelete-a-delegate-15.png?alt=media)

#### Next steps <a href="#next-steps" id="next-steps"></a>

After you delete a delegate, review related delegate lifecycle information.

* [Graceful delegate shutdown](https://developer.harness.io/harness-platform/use-harness-platform/delegates/delegate/delegate-concepts/graceful-delegate-shutdown-process.md)

{% @harness-feedback/feedback module="harness-ai" pagePath="harness-ai/use-harness-platform/delegates/delegate/manage-delegates/delete-a-delegate" %}
