The utf9k logo which is a cartoon robot utf9k

Kubernetes

How can I pause a recurring cronjob?

If you have a cronjob that you’d like to pause while doing some maintenance for example, you can use the suspend attribute.

> kubectl patch cronjobs does-something -p '{"spec": {"suspend": true }}'
cronjob.batch/does-something patched

Once you’re done, you can just flip true to false

How can I create an instance of a cronjob?

If you’re trying to test out a job, and don’t want to wait for however long, you can manually create a job instance.

Assuming our cronjob is called sports-leaderboard-calc, you can create it like so:

> kubectl create job instance-name --from=cronjob/sports-leaderboard-calc
job.batch/instance-name

You’ll then see the resulting job and pod under kubectl get job and kubectl get pod respectively.