**已关闭。**此问题为not about programming or software development。目前不接受答案。
此问题似乎与a specific programming problem, a software algorithm, or software tools primarily used by programmers无关。如果您认为此问题与another Stack Exchange site相关,您可以留下评论,说明在何处可以找到此问题的答案。
7天前关闭。
Improve this question
我想在Kubernetes集群中创建一个cronjob。我得到了错误。它似乎是我的yaml文件中的错误。但我不知道正确的语法是什么。
kubectl应用-f转换器-86-cron.yaml
错误:验证“converter-86-cron.yaml”时出错:验证数据时出错:验证错误(CronJob.规范.作业模板.规范.模板.规范):在io.k8s.api.core.v1.PodSpec中有未知的字段“选择器”;如果您选择忽略这些错误,请使用--validate=false关闭验证
密码:
apiVersion: batch/v1
kind: CronJob
metadata:
name: converter-86-cron
namespace: converter
spec:
schedule: "0 10 * * *" # 3 AM PST
jobTemplate:
spec:
template:
metadata:
namespace: converter
labels:
name: converter-86-cron
spec:
selector:
matchLabels:
architecture: "8.6"
containers:
- name: convert
image: "accountID.dkr.ecr.ap-northeast-2.amazonaws.com/converter:1.1.1b9.2004.cu114.12345668"
resources:
requests:
nvidia.com/gpu: 1
cpu: 2
limits:
nvidia.com/gpu: 1
args:
- python3
- trt-converter.py
- --awsdev
tolerations:
- key: "nvidia.com/gpu"
operator: "Exists"
effect: "NoSchedule"
restartPolicy: Never
使用nodeSelector的新代码。不确定是否正确。
apiVersion: batch/v1
kind: CronJob
metadata:
name: converter-86-cron
namespace: converter
spec:
schedule: "0 10 * * *" # 3 AM PST
jobTemplate:
spec:
template:
metadata:
namespace: converter
labels:
name: converter-86-cron
spec:
nodeSelector:
architecture: "8.6"
containers:
- name: convert
image: "accountID.dkr.ecr.ap-northeast-2.amazonaws.com/converter:1.1.1b9.2004.cu114.12345668"
resources:
requests:
nvidia.com/gpu: 1
cpu: 2
limits:
nvidia.com/gpu: 1
args:
- python3
- trt-converter.py
- --awsdev
tolerations:
- key: "nvidia.com/gpu"
operator: "Exists"
effect: "NoSchedule"
restartPolicy: Never
1条答案
按热度按时间xmd2e60i1#
您应该将
CronJob.spec.jobTemplate.spec.template.spec
读作一个树...所以在CronJob -〉spec -〉jobTemplate等等下...所以在您的例子中,上面第16行spec:
下的selector:
是无效字段。您应该参考文档,了解如何准确地放置选择器/标签和体系结构,以及放置选择器/标签和体系结构的位置。