<p>This is a pretty basic question that I cannot seem to find an answer to, but I cannot figure out how to set the concurrencyPolicy in a cronjob. I have tried variations of my current file config:</p>

<pre><code>apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: job-newspaper
spec:
  schedule: "* */3 * * *"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
           - name: job-newspaper
            image: bdsdev.azurecr.io/job-newspaper:latest
            imagePullPolicy: Always
            resources:
              limits:
                cpu: "2048m"
                memory: "10G"
              requests:
                cpu: "512m"
                memory: "2G"
            command: ["spark-submit","/app/newspaper_job.py"]
          restartPolicy: OnFailure
          concurrencyPolicy: Forbid
</code></pre>

<p>When I run <code>kubectl create -f ./job.yaml</code> I get the following error:</p>

<pre><code>error: error validating "./job.yaml": error validating data: 
ValidationError(CronJob.spec.jobTemplate.spec.template.spec): unknown 
field "concurrencyPolicy" in io.k8s.api.core.v1.PodSpec; if you choose 
to ignore these errors, turn validation off with --validate=false
</code></pre>

<p>I am probably either putting this property in the wrong place or calling it the wrong name, I just cannot find it in documentation. Thanks!</p>

<p>The property <code>concurrencyPolicy</code> is part of the CronJob spec, not the PodSpec. You can locally see the spec for a given object using <code>kubectl explain</code>, like</p>

<pre><code>kubectl explain --api-version="batch/v1beta1" cronjobs.spec
</code></pre>

<p>There you can see the structure/spec of the CronJob object, which in your case should be</p>

<pre><code>apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: job-newspaper
spec:
  schedule: "* */3 * * *"
  concurrencyPolicy: Forbid
  jobTemplate:
    spec:
      template:
        spec:
          containers:
           - name: job-newspaper
            image: bdsdev.azurecr.io/job-newspaper:latest
            imagePullPolicy: Always
            resources:
              limits:
                cpu: "2048m"
                memory: "10G"
              requests:
                cpu: "512m"
                memory: "2G"
            command: ["spark-submit","/app/newspaper_job.py"]
          restartPolicy: OnFailure
</code></pre>
