gpt4 book ai didi

kubernetes - 设置并发 Kubernetes Cronjob

转载 作者:行者123 更新时间:2023-12-01 08:48:48 24 4
gpt4 key购买 nike

这是一个非常基本的问题,我似乎无法找到答案,但我无法弄清楚如何在 cronjob 中设置 concurrencyPolicy。我尝试了当前文件配置的变体:

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

当我跑 kubectl create -f ./job.yaml我收到以下错误:
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

我可能将此属性放在错误的位置或调用了错误的名称,我只是在文档中找不到它。谢谢!

最佳答案

属性(property)concurrencyPolicy是 CronJob 规范的一部分,而不是 PodSpec。您可以使用 kubectl explain 在本地查看给定对象的规范。 , 喜欢

kubectl explain --api-version="batch/v1beta1" cronjobs.spec

在那里你可以看到 CronJob 对象的结构/规范,在你的情况下应该是
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

关于kubernetes - 设置并发 Kubernetes Cronjob,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48253009/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com