Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling cronjob in Kubernetes

I have scheduled an application to run as a Cronjob in Kubernetes. When there is a code change, I'm also changing the image of the CronJob.

I'm looking for an option where I can disable the currently running CronJob and deploy a new CronJob with the latest Image version.

How can I disable a Cronjob in Kubernetes without deleting its yaml manifest?

like image 397
Jasmitha Meka Avatar asked Oct 12 '18 09:10

Jasmitha Meka


Video Answer


2 Answers

If you want to suspend cronjob via patch, use:

kubectl patch cronjobs <job-name> -p '{"spec" : {"suspend" : true }}' 
like image 189
Amityo Avatar answered Oct 02 '22 17:10

Amityo


Edit your current cronjob resource to include the .spec.suspend field and set it to true. Any currently running jobs will complete but future jobs will be suspended.

If you also need to stop currently running jobs, you'll have to delete them

like image 29
Patrick W Avatar answered Oct 02 '22 17:10

Patrick W