kubernetes - 在 kubernetes 中验证 cronjob 中的数据时出错
问题描述
我被 k8s cron 作业 yaml 语法错误阻止
我试着做
kubectl apply -f cronjob.yaml
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: update-test
spec:
schedule: "0 /5 * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: update-test
image: test:test
imagePullPolicy: IfNotPresent
command: ['echo test']
envFrom:
- configMapRef:
name: test-config
- configMapRef:
name: test-config-globe
resources:
requests:
memory: "512Mi"
cpu: "0.5"
limits:
memory: "1024Mi"
cpu: "2"
restartPolicy: OnFailure
但我收到此错误:
error: error validating "deplyment.yaml": error validating data: [ValidationError(CronJob.spec.jobTemplate.spec.template.spec.containers[0].envFrom[0]): unknown field "name" in io.k8s.api.core.v1.EnvFromSource, ValidationError(CronJob.spec.jobTemplate.spec.template.spec.containers[0].envFrom[1]): unknown field "name" in io.k8s.api.core.v1.EnvFromSource];
解决方案
名称缩进configMapRef
不正确,更改此:
envFrom:
- configMapRef:
name: test-config
到:
envFrom:
- configMapRef:
name: test-config
注意:另外,您的cron
日程安排不正确,您可能需要修复0 /5 * * *
为有效值。也许您需要将其设置为0 */5 * * *
推荐阅读
- node.js - 更改 GruntFile 不会更改 livereload 端口
- java - Solr ClassCastException 与自定义 TokenFilterFactory
- android - 如何以编程方式从 android 设备导入和读取随机 SQLITE 数据库文件 (.db)?
- java - 如何在 Jmeter 中发送 http 表单
- angular - 业力并行 npm 包不适用于圆形 CI
- azure-devops - 尝试从 Azure Dev Ops 创建燃尽图到 Power Bi 时使用哪些字段和计算
- javascript - 确定构造函数是否在 JavaScript 构造函数设计模式中的相同元素上调用
- python - 在多标签数据集不平衡的情况下如何进行过采样?
- c# - 新的语言功能破坏了脚手架 - 无法获取 DbContext 的反射类型
- php - 用户输入如何插入数据库