26 lines
875 B
YAML
26 lines
875 B
YAML
apiVersion: batch/v1
|
||
kind: Job
|
||
metadata:
|
||
name: job-backoff-limit-per-index-example
|
||
spec:
|
||
completions: 10
|
||
parallelism: 3
|
||
completionMode: Indexed # 此特性所必需的字段
|
||
backoffLimitPerIndex: 1 # 每个索引最大失败次数
|
||
maxFailedIndexes: 5 # 终止 Job 执行之前失败索引的最大个数
|
||
template:
|
||
spec:
|
||
restartPolicy: Never # 此特性所必需的字段
|
||
containers:
|
||
- name: example
|
||
image: python
|
||
command: # 作业失败,因为至少有一个索引失败(此处所有偶数索引均失败),
|
||
# 但由于未超过 maxFailedIndexes,所以所有索引都会被执行
|
||
- python3
|
||
- -c
|
||
- |
|
||
import os, sys
|
||
print("Hello world")
|
||
if int(os.environ.get("JOB_COMPLETION_INDEX")) % 2 == 0:
|
||
sys.exit(1)
|