generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add examples for three existing failure policy actions.
Add examples for each of the following failure policy actions: 1. FailJobSet, 2. RestartJobSet, 3. RestartJobSetAndIgnoreMaxRestarts.
- Loading branch information
Justin Edwins
committed
Jun 13, 2024
1 parent
938519f
commit c08778c
Showing
3 changed files
with
181 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
apiVersion: jobset.x-k8s.io/v1alpha2 | ||
kind: JobSet | ||
metadata: | ||
name: failjobset-action-example | ||
spec: | ||
failurePolicy: | ||
maxRestarts: 3 | ||
rules: | ||
- action: FailJobSet | ||
targetReplicatedJobs: | ||
- leader | ||
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 | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
apiVersion: jobset.x-k8s.io/v1alpha2 | ||
kind: JobSet | ||
metadata: | ||
name: restartjobset-action-example | ||
spec: | ||
failurePolicy: | ||
maxRestarts: 3 | ||
rules: | ||
- action: RestartJobSet | ||
targetReplicatedJobs: | ||
- leader | ||
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 | ||
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 |
61 changes: 61 additions & 0 deletions
61
examples/failure-policy/restartjobsetandignoremaxrestarts-action.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
apiVersion: jobset.x-k8s.io/v1alpha2 | ||
kind: JobSet | ||
metadata: | ||
# rjimr stands for "restartjobsetandignoremaxrestarts" | ||
name: rjimr-action-example | ||
spec: | ||
failurePolicy: | ||
maxRestarts: 3 | ||
rules: | ||
- action: RestartJobSetAndIgnoreMaxRestarts | ||
targetReplicatedJobs: | ||
- leader | ||
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 | ||
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 |