实现运行pod数6台 。并行运行2台。总运行时间360s

apiVersion: batch/v1
kind: Job
metadata:
  name: test-job
spec:
  completions: 6      			# 需要运行的pod数量
  parallelism: 2      			# 允许并发运行的pod数量
  activeDeadlineSeconds: 360  	# pod运行的超时时间 
  template:
    metadata:
      labels:
        app: test-job
    spec:
      containers:
      - name: test-job
        image: luksa/batch-job
        imagePullPolicy: IfNotPresent
      restartPolicy: OnFailure

固定结束次数的 Job 示例

apiVersion: batch/v1
kind: Job
metadata:
  name: busybox
spec:
  completions: 3
  template:
    metadata:
      name: busybox
    spec:
      containers:
      - name: busybox
        image: busybox
        command: ["echo", "hello"]
      restartPolicy: Never

结果

[root@k8s-master job]# kubectl get pods
NAME             READY   STATUS      RESTARTS   AGE
busybox-4cjq7    0/1     Completed   0          40s
busybox-79x79    0/1     Completed   0          22s
busybox-frk5t    0/1     Completed   0          52s
Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐