website/content/zh-cn/examples/controllers/job-backoff-limit-per-index...

26 lines
875 B
YAML
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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)