CronJob 在 k8s 1.19.11 中创建为作业
CronJob created as job in k8s 1.19.11
我遇到了一个 API 问题,导致无法从 cron 作业创建作业。
我有一个使用 API 的 CronJob Helm 文件,如下所示:
apiVersion: batch/v1beta1
kind: CronJob
用 helm 部署它工作得很好。
然后在部署之后,我尝试使用该 cronjob 创建一个作业,如下所示:
kubectl create job $(helm-release-name) --from=cronjob/connector-config
这用于根据上面的图表创建作业。但是现在,自升级到 1.19.11 后,我得到了这个错误:
##[error]error: unknown object type *v1beta1.CronJob
commandOutput
##[error]The process
'/opt/hostedtoolcache/kubectl/1.22.1/x64/kubectl' failed with exit code 1
如果我将 Helm 图表中的 api 更改为:
apiVersion: batch/v1
kind: CronJob
然后 Helm chart 部署失败。
UPGRADE FAILED: unable to recognize "": no matches for kind "CronJob" in version
"batch/v1"
建议?
谢谢!
CronJobs 在 Google Kubernetes Engine (GKE) 1.21 及更高版本中正式发布 (GA)。
你应该使用的版本apiVersion: batch/v1
https://kubernetes.io/docs/tasks/job/automated-tasks-with-cron-jobs/
CronJobs was promoted to general availability in Kubernetes v1.21. If
you are using an older version of Kubernetes, please refer to the
documentation for the version of Kubernetes that you are using, so
that you see accurate information. Older Kubernetes versions do not
support the batch/v1 CronJob API.
您可以使用
检查支持的 Kubernetes API 版本
kubectl api-resources OR kubectl api-versions
你也可以试试
kubectl explain <Resource type>
kubectl explain cronjob
我遇到了一个 API 问题,导致无法从 cron 作业创建作业。
我有一个使用 API 的 CronJob Helm 文件,如下所示:
apiVersion: batch/v1beta1
kind: CronJob
用 helm 部署它工作得很好。
然后在部署之后,我尝试使用该 cronjob 创建一个作业,如下所示:
kubectl create job $(helm-release-name) --from=cronjob/connector-config
这用于根据上面的图表创建作业。但是现在,自升级到 1.19.11 后,我得到了这个错误:
##[error]error: unknown object type *v1beta1.CronJob
commandOutput
##[error]The process
'/opt/hostedtoolcache/kubectl/1.22.1/x64/kubectl' failed with exit code 1
如果我将 Helm 图表中的 api 更改为:
apiVersion: batch/v1
kind: CronJob
然后 Helm chart 部署失败。
UPGRADE FAILED: unable to recognize "": no matches for kind "CronJob" in version
"batch/v1"
建议?
谢谢!
CronJobs 在 Google Kubernetes Engine (GKE) 1.21 及更高版本中正式发布 (GA)。
你应该使用的版本apiVersion: batch/v1
https://kubernetes.io/docs/tasks/job/automated-tasks-with-cron-jobs/
CronJobs was promoted to general availability in Kubernetes v1.21. If you are using an older version of Kubernetes, please refer to the documentation for the version of Kubernetes that you are using, so that you see accurate information. Older Kubernetes versions do not support the batch/v1 CronJob API.
您可以使用
检查支持的 Kubernetes API 版本kubectl api-resources OR kubectl api-versions
你也可以试试
kubectl explain <Resource type>
kubectl explain cronjob