我正在尝试部署我的第一个 Cron 作业。
从一个非常简单的开始,如 k8s tutorial 中所述:
apiVersion: batch/v1
kind: CronJob
metadata:
name: hello
spec:
schedule: "*/1 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: hello
image: busybox
imagePullPolicy: IfNotPresent
command:
- /bin/sh
- -c
- date; echo Hello from the Kubernetes cluster
restartPolicy: OnFailure
我已连接到我的 EKS 集群。这是命令和输出:
➜ Dev kubectl apply -f cronjob.yaml
error: unable to recognize "cronjob.yaml": no matches for kind "CronJob" in version "batch/v1"
batch/v1 确实存在于我的 apiVersion 列表中。
无法理解有什么问题..
答案 0 :(得分:4)
kubernetes 1.18 中的 Cronjob apiVersion 是 batch/v1beta1
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: hello
spec:
schedule: "*/1 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: hello
image: busybox
args:
- /bin/sh
- -c
- date; echo Hello from the Kubernetes cluster