Does Kubernetes CronJob concurrencyPolicy works as expected?

7/19/2019

Due to the Kubernetes docs

A cron job creates a job object about once per execution time of its schedule. We say “about” because there are certain circumstances where two jobs might be created, or no job might be created. We attempt to make these rare, but do not completely prevent them. Therefore, jobs should be idempotent

But also CronJob has parameter: concurrencyPolicy (Allow, Forbid)

So could I expect that if I will set concurrencyPolicy=Forbid the CronJob will run always in single instance ?

-- Dmitry
kubernetes
kubernetes-cronjob

1 Answer

7/19/2019

CronJob, in some cases, can schedule more than one Job per run, this is the CronJob concurrency and is set to Allow by default.

When you set the policy to Forbid, it won't allow Jobs to be started until previous Jobs have completed or timed out.

So basically, with the Forbid policy, the upcoming Jobs will be skipped if a previous run is still active.

-- yyyyahir
Source: StackOverflow