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:
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
When I run kubectl create -f ./job.yaml
I get the following error:
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
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!
The property concurrencyPolicy
is part of the CronJob spec, not the PodSpec. You can locally see the spec for a given object using kubectl explain
, like
kubectl explain --api-version="batch/v1beta1" cronjobs.spec
There you can see the structure/spec of the CronJob object, which in your case should be
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With