> 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/continuous-delivery/use-continuous-delivery/deploy-services-on-different-platforms/kubernetes/kubernetes-executions/delete-kubernetes-resources.md).

# Delete Kubernetes resources with the Kubernetes Delete step

This topic describes how to remove any deployed Kubernetes resources with the **K8s Delete** step.

Looking for Canary Delete? See [Canary Delete Step](/continuous-delivery/use-continuous-delivery/deploy-services-on-different-platforms/kubernetes/cd-k8s-ref/kubernetes-canary-delete-step.md).

#### Before you begin <a href="#before-you-begin" id="before-you-begin"></a>

* [Define Kubernetes Manifests](/continuous-delivery/use-continuous-delivery/deploy-services-on-different-platforms/kubernetes/cd-kubernetes-category/define-kubernetes-manifests.md)
* [Create a Kubernetes Canary Deployment](/continuous-delivery/use-continuous-delivery/deploy-services-on-different-platforms/kubernetes/kubernetes-executions/create-a-kubernetes-canary-deployment.md)
* [Create a Kubernetes Blue Green Deployment](/continuous-delivery/use-continuous-delivery/deploy-services-on-different-platforms/kubernetes/kubernetes-executions/create-a-kubernetes-blue-green-deployment.md)
* [Create a Kubernetes Rolling Deployment](/continuous-delivery/use-continuous-delivery/deploy-services-on-different-platforms/kubernetes/kubernetes-executions/create-a-kubernetes-rolling-deployment.md)

### Where to add the Kubernetes Delete step <a href="#where-to-add-the-kubernetes-delete-step" id="where-to-add-the-kubernetes-delete-step"></a>

You can add a Kubernetes Delete step anywhere in your Pipeline, but the resource you want to delete must already exist by the time Pipeline execution reaches the Kubernetes Delete step.

If you are using a Kubernetes Apply step, Canary Deployment, Rolling Deployment, or some provisioning step to create resources, ensure that you only add the Kubernetes Delete step after its target resource is created.

### Add Delete step <a href="#add-delete-step" id="add-delete-step"></a>

In your Harness stage Execution, click **Add Step**, and select **K8s** **Delete**. The K8s Delete settings appear:

![](/files/F3KX8bbn5VDlYjm7iHtb)

You can add a K8s Delete step anywhere in your stage.

Enter a name for the step.

### Select resources to delete <a href="#select-resources-to-delete" id="select-resources-to-delete"></a>

In **Delete resources by**, select how you want to select the resources to be deleted.

There are a few ways to specify the resource to be removed.

#### Resource name <a href="#resource-name" id="resource-name"></a>

Identify a resource name in the format `[namespace]/Kind/Name`, with `namespace` being optional.

You must add a `Kind` before the resource name, like this:

`Deployment/harness-example-deployment-canary`

Enter multiple resources using **Add**.

![](/files/vjuog1XdSU7mULiy73KA)

To delete all resources, use the **Release Name** option, explained below.

#### Manifest path <a href="#manifest-path" id="manifest-path"></a>

Enter the path to the manifest for the resource you want to delete. The path is relative to the folder path entered in **File/Folder Path** in the **Manifest Details** settings:

![](/files/IiBJVzmaziRpI0odbs8m)

Enter multiple resources using **Add File**.

![](/files/CUFjlfvVyP0C0dhAkZS9)

#### Release name <a href="#release-name" id="release-name"></a>

During deployment Harness creates a ConfigMap listing the resources of the release and uses the release name for tracking them. The release name is defined in the **Infrastructure** settings, in **Cluster Details**, in **Advanced**.

If you want to delete all of the resources for a release, select **Release Name**.

If you select the **Delete namespace** option, Harness will delete the namespace(s) defined in the release.

![](/files/9HDIxzZz1Oc2MnyzhbgE)

Ensure that you are not deleting a namespace that is used by other deployments.

### Advanced Settings <a href="#advanced-settings" id="advanced-settings"></a>

See the following:

* [Delegate Selector](/harness-ai/use-harness-platform/delegates/delegate/manage-delegates/select-delegates-with-selectors.md)
* [Conditional Execution](/harness-ai/use-harness-platform/pipelines/step-skip-condition-settings.md)
* [Failure Strategy](/harness-ai/use-harness-platform/pipelines/failure-handling/define-a-failure-strategy-on-stages-and-steps.md)
* [Looping Strategy](/harness-ai/use-harness-platform/pipelines/looping-strategies/looping-strategies-matrix-repeat-and-parallelism.md)
* [Command Flags](/continuous-delivery/use-continuous-delivery/deploy-services-on-different-platforms/kubernetes/cd-kubernetes-category/k8s-command-flags.md)
* [Policy Enforcement](/harness-ai/use-harness-platform/governance/policy-as-code/harness-governance-overview.md)

#### Example: Deleting a Deployment <a href="#example-deleting-a-deployment" id="example-deleting-a-deployment"></a>

Here is an example of the log from a Delete command:

```
Initializing..  
...  
Resources to delete are:   
- Deployment/harness-example-deployment-canary  
Done.
```

### Deleting all resources and namespaces <a href="#deleting-all-resources-and-namespaces" id="deleting-all-resources-and-namespaces"></a>

Here is an example deleting all resources in the release and the namespace:

```
All Resources are selected for deletion  
Delete Namespace is set to: true  
Fetching all resources created for release: release-44e74aca-279f-3b4a-bb15-06d750393a8d  
  
Resources to delete are:   
- adwait-12/Deployment/harness-example-deployment  
- adwait-12/Service/harness-example-svc  
- adwait-12/ConfigMap/release-44e74aca-279f-3b4a-bb15-06d750393a8d  
- adwait-12/ConfigMap/harness-example-2  
- adwait-12/ConfigMap/harness-example-1  
- adwait-12/Secret/harness-example-2  
- adwait-12/Secret/harness-example-1  
- adwait-12/Namespace/adwait-12  
Done.
```

### Notes <a href="#notes" id="notes"></a>

* **Delete and Traffic Management**: If you are splitting traffic using the **Apply step**, move the **K8s** **Delete** step after the traffic shifting. This will prevent any traffic from being routed to deleted pods before traffic is routed to stable pods.

### See also <a href="#see-also" id="see-also"></a>

* [Canary Delete Step](/continuous-delivery/use-continuous-delivery/deploy-services-on-different-platforms/kubernetes/cd-k8s-ref/kubernetes-canary-delete-step.md)
