generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 32
/
max-restarts.yaml
61 lines (61 loc) · 1.69 KB
/
max-restarts.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
apiVersion: jobset.x-k8s.io/v1alpha2
kind: JobSet
metadata:
name: max-restarts
spec:
# On failure, restart all jobs up to 3 times.
failurePolicy:
maxRestarts: 3
replicatedJobs:
- name: leader
replicas: 1
template:
spec:
# Set backoff limit to 0 so job will immediately fail if any pod fails.
backoffLimit: 0
completions: 2
parallelism: 2
template:
spec:
containers:
- name: leader
image: bash:latest
# Default failure policy is to recreate all jobs if any jobs fails.
# The bash script provides a simple demonstration of it by failing
# the pod with completion index 0, which will trigger job failure
# and the jobset controller wil recreate all jobs.
command:
- bash
- -xc
- |
echo "JOB_COMPLETION_INDEX=$JOB_COMPLETION_INDEX"
if [[ "$JOB_COMPLETION_INDEX" == "0" ]]; then
for i in $(seq 10 -1 1)
do
echo "Sleeping in $i"
sleep 1
done
exit 1
fi
for i in $(seq 1 1000)
do
echo "$i"
sleep 1
done
- name: workers
replicas: 1
template:
spec:
backoffLimit: 0
completions: 2
parallelism: 2
template:
spec:
containers:
- name: worker
image: bash:latest
command:
- bash
- -xc
- |
sleep 1000