cronkuberneteskubernetes-cronjob

Kubernetes CronJob - Skip job if previous is still running AND wait for the next schedule time


I have scheduled the K8s cron to run every 30 mins.

If the current job is still running and the next cron schedule has reached it shouldn't create a new job but rather wait for the next schedule.

And repeat the same process if the previous job is still in Running state.


Solution

  • set the following property to Forbid in CronJob yaml

    .spec.concurrencyPolicy
    

    https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#concurrency-policy