This topic describes how to remove any deployed Kubernetes resources with the K8s Delete step.
Looking for Canary Delete? See Canary Delete Step.### Before You Begin
- Define Kubernetes Manifests
- Create a Kubernetes Canary Deployment
- Create a Kubernetes Blue/Green Deployment
- Create a Kubernetes Rolling Deployment
Where to add the Kubernetes Delete Step
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.
Step 1: Add Delete Step
In your Harness stage Execution, click Add Step, and select K8s Delete. The K8s Delete settings appear:
You can add a K8s Delete step anywhere in your stage.
Enter a name for the step.
Step 2: Select Resources to Delete
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.
Option: Resource Name
Identify a resource name in the format
namespace being optional.
You must add a
Kind before the resource name, like this:
Enter multiple resources using Add.
To delete all resources, use the Release Name option, explained below.
Option: Manifest Path
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:
Enter multiple resources using Add File.
Option: Release Name
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.
Ensure that you are not deleting a namespace that is used by other deployments.### Example: Deleting a Deployment
Here is an example of the log from a Delete command:
Resources to delete are:
Example 2: Deleting All Resources and Namespaces
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:
- 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.