Delete Kubernetes Resources
Remove any deployed Kubernetes resources with the K8s Delete step.
In this topic:
- Before You Begin
- Step 1: Add Delete Step
- Step 2: Select Resources to Delete
- Example: Deleting a Deployment
- Example 2: Deleting All Resources and Namespaces
- See Also
Before You Begin
- Define Kubernetes Manifests
- Create a Kubernetes Canary Deployment
- Create a Kubernetes Blue/Green Deployment
- Create a Kubernetes Rolling Deployment
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.
Wherever you add a K8s Delete step, the resource you want to delete must already exist in the cluster. For example, if the resource is added in Canary phase of a stage, the K8s Delete step should not be placed in the Primary Deployment phase that follows it.
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
Using 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.
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.