Disabling cronjob in Kubernetes

10/12/2018

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

I'm looking for an option where I can disable currently running CronJob and deploy new CronJob with newly created Image.

How to disable a Cronjob in Kubernetes without deleting yaml?

-- Jasmitha
google-kubernetes-engine
kubernetes

4 Answers

3/10/2019

If you want to suspend cronjob via patch, use:

kubectl patch cronjobs <job-name> -p '{"spec" : {"suspend" : true }}'
-- Amityo
Source: StackOverflow

10/12/2018

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

-- Patrick W
Source: StackOverflow

12/6/2019
kubectl patch cronjobs job-name -p "{\"spec\" : {\"suspend\" : true }}"
-- Iulian Alexandru
Source: StackOverflow

10/12/2018

You can use something which will be valid with respect to Cron Job format but actually that date should not appear anytime in calendar date like 31 Feb.

* * 31 2 *
-- PRADEEP PANDEY
Source: StackOverflow