标签:dead limited limit 超时 失败 complete temp class mit
Begin:
kubectl explain job.spec
apiVersion: batch/v1
kind: Job
metadata:
name: batch-job
namespace: controller-test
spec:
template:
metadata:
labels:
app: batch-job
spec:
restartPolicy: OnFailure
containers:
- name: main
image: luksa/batch-job
command: ["echo"]
args: ["正在执行"]
restartPolicy: OnFailure
??:??????????????????????????????????????????容器在结束时会做什么,默认为Always,Job不建议用默认值,因为他们并不是要一直运行下去;绝大多数是OnFailure或Never。一般无特别指明,一个Job运行一个Pod,Pod完成后处于completed状态结束。
运行多个Pods,通过指定属性completions
和parallelism
来实现。
Case1:Job完成需要5个pod completed,顺序执行(一次只能run一个)
apiVersion: batch/v1
kind: Job
metadata:
name: multi-completion-job
namespace: controller-test
spec:
completions: 5
template:
metadata:
labels:
app: batch-job
spec:
restartPolicy: OnFailure
containers:
- name: main
image: luksa/batch-job
Case 2:Job完成需要 5个pod completed,同时可以运行2个Pod
apiVersion: batch/v1
kind: Job
metadata:
name: multi-completion-batch-job
namespace: controller-test
spec:
completions: 5
parallelism: 2
template:
metadata:
labels:
app: batch-job
spec:
restartPolicy: OnFailure
containers:
- name: main
image: luksa/batch-job
activeDeadlineSeconds: 30
:如果job超过这个时间,job将终止尝试pod,并把job标记为失败
sapiVersion: batch/v1
kind: Job
metadata:
name: time-limited-batch-job
namespace: controller-test
spec:
activeDeadlineSeconds: 30
template:
metadata:
labels:
app: batch-job
spec:
restartPolicy: OnFailure
containers:
- name: main
image: luksa/batch-job
指定.spec.backoffLimit
,指定失败之前可以重试次数,默认为6
标签:dead limited limit 超时 失败 complete temp class mit
原文地址:https://www.cnblogs.com/voyaging/p/13526174.html