Kubernetes使用CronJob运行作业 [英] Kubernetes Run job using 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:
工作规范:(
Cron Spec: Cron Spec: 我碰到了这个.我想尝试与此相反.
Create-Job-From-Cronjob I came across this. I want to try inverse of this.
Create-Job-From-Cronjob 不,您不能以所需的方式执行此操作. No, you can not do this in the way you want. 现在可用于kubectl create的命令: Available commands right now for kubectl create: 这篇关于Kubernetes使用CronJob运行作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: pi-cron
spec:
schedule: "*/1 * * * *"
jobTemplate:
spec:
labelSelector:
name: pi # refer to the job created above
推荐答案
kubectl
仅允许您基于cronjob创建作业,反之亦然.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]
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