In this blog, we will cover how to bulk delete multiple jobs in Kubernetes. A Kubernetes Job creates one or more Pods and when the specified number of successful runs are complete, the task is considered as complete. To delete a Job, we will need to clean up the Pods it creates. 

Bulk Delete  Jobs

To delete failed or unsuccessful jobs, you can run this command:

kubectl delete jobs --field-selector status.successful=0 -A

To delete passed or successful jobs, you can run this command:

kubectl delete jobs --field-selector status.successful=1 -A

 

Tip:  You can narrow it down to a particular namespace by removing all namespaces (-A) parameter and explictly specifying the namespace using -n, for example:

To delete failed or unsuccessful jobs in namespace ‘production’, you can run this command:

kubectl delete jobs --field-selector status.successful=0 -n production

In this blog, we covered how to delete multiple jobs in kubernetes. Please make sure, to checkout our other blogs here

Leave a Reply

Your email address will not be published. Required fields are marked *