Kubernetes使用CronJob运行作业

编程入门 行业动态 更新时间:2024-10-25 12:18:42
本文介绍了Kubernetes使用CronJob运行作业的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有没有一种方法可以使用CronJob资源运行现有的Job. 在CronJob Spec模板中,我们可以使用标签应用选择器.像这样:

Is there a way through which I can run an existing Job using CronJob resource. In CronJob Spec template can we apply a selector using labels. Something like this:

工作规范:(链接到工作文档)

apiVersion: batch/v1 kind: Job label: name: pi spec: template: spec: containers: - name: pi image: perl command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"] restartPolicy: Never backoffLimit: 4

Cron Spec:

Cron Spec:

apiVersion: batch/v1beta1 kind: CronJob metadata: name: pi-cron spec: schedule: "*/1 * * * *" jobTemplate: spec: labelSelector: name: pi # refer to the job created above

我碰到了这个.我想尝试与此相反. Create-Job-From-Cronjob

I came across this. I want to try inverse of this. Create-Job-From-Cronjob

推荐答案

不,您不能以所需的方式执行此操作. kubectl仅允许您基于cronjob创建作业,反之亦然.

No, you can not do this in the way you want. kubectl only allows you to create jobs based on cronjob, but not vise-versa.

kubectl create job NAME [--image=image --from=cronjob/name] -- [COMMAND] [args...] [flags] [options]

现在可用于kubectl create的命令:

Available commands right now for kubectl create:

clusterrole Create a ClusterRole. clusterrolebinding Create a ClusterRoleBinding for a particular ClusterRole configmap Create a configmap from a local file, directory or literal value deployment Create a deployment with the specified name. job Create a job with the specified name. namespace Create a namespace with the specified name poddisruptionbudget Create a pod disruption budget with the specified name. priorityclass Create a priorityclass with the specified name. quota Create a quota with the specified name. role Create a role with single rule. rolebinding Create a RoleBinding for a particular Role or ClusterRole secret Create a secret using specified subcommand service Create a service using specified subcommand. serviceaccount Create a service account with the specified name

更多推荐

Kubernetes使用CronJob运行作业

本文发布于:2023-07-16 04:09:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1117696.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:作业   Kubernetes   CronJob

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!