Skip to content

Commit 18638eb

Browse files
authored
Merge pull request #36620 from windsonsea/pfpen
Fix layout of pod-failure-policy.md
2 parents 5f8c8b3 + 926d85d commit 18638eb

File tree

1 file changed

+26
-18
lines changed

1 file changed

+26
-18
lines changed

content/en/docs/tasks/job/pod-failure-policy.md

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ kubectl create -f job-pod-failure-policy-failjob.yaml
5353
```
5454

5555
After around 30s the entire Job should be terminated. Inspect the status of the Job by running:
56+
5657
```sh
5758
kubectl get jobs -l job-name=job-pod-failure-policy-failjob -o yaml
5859
```
@@ -68,9 +69,11 @@ of the Pod, taking at least 2 minutes.
6869
### Clean up
6970

7071
Delete the Job you created:
72+
7173
```sh
7274
kubectl delete jobs/job-pod-failure-policy-failjob
7375
```
76+
7477
The cluster automatically cleans up the Pods.
7578

7679
## Using Pod failure policy to ignore Pod disruptions
@@ -87,34 +90,37 @@ node while the Pod is running on it (within 90s since the Pod is scheduled).
8790

8891
1. Create a Job based on the config:
8992

90-
{{< codenew file="/controllers/job-pod-failure-policy-ignore.yaml" >}}
93+
{{< codenew file="/controllers/job-pod-failure-policy-ignore.yaml" >}}
9194

92-
by running:
95+
by running:
9396

94-
```sh
95-
kubectl create -f job-pod-failure-policy-ignore.yaml
96-
```
97+
```sh
98+
kubectl create -f job-pod-failure-policy-ignore.yaml
99+
```
97100

98101
2. Run this command to check the `nodeName` the Pod is scheduled to:
99102

100-
```sh
101-
nodeName=$(kubectl get pods -l job-name=job-pod-failure-policy-ignore -o jsonpath='{.items[0].spec.nodeName}')
102-
```
103+
```sh
104+
nodeName=$(kubectl get pods -l job-name=job-pod-failure-policy-ignore -o jsonpath='{.items[0].spec.nodeName}')
105+
```
103106

104107
3. Drain the node to evict the Pod before it completes (within 90s):
105-
```sh
106-
kubectl drain nodes/$nodeName --ignore-daemonsets --grace-period=0
107-
```
108+
109+
```sh
110+
kubectl drain nodes/$nodeName --ignore-daemonsets --grace-period=0
111+
```
108112

109113
4. Inspect the `.status.failed` to check the counter for the Job is not incremented:
110-
```sh
111-
kubectl get jobs -l job-name=job-pod-failure-policy-ignore -o yaml
112-
```
114+
115+
```sh
116+
kubectl get jobs -l job-name=job-pod-failure-policy-ignore -o yaml
117+
```
113118

114119
5. Uncordon the node:
115-
```sh
116-
kubectl uncordon nodes/$nodeName
117-
```
120+
121+
```sh
122+
kubectl uncordon nodes/$nodeName
123+
```
118124

119125
The Job resumes and succeeds.
120126

@@ -124,16 +130,18 @@ result in terminating the entire Job (as the `.spec.backoffLimit` is set to 0).
124130
### Cleaning up
125131

126132
Delete the Job you created:
133+
127134
```sh
128135
kubectl delete jobs/job-pod-failure-policy-ignore
129136
```
137+
130138
The cluster automatically cleans up the Pods.
131139

132140
## Alternatives
133141

134142
You could rely solely on the
135143
[Pod backoff failure policy](/docs/concepts/workloads/controllers/job#pod-backoff-failure-policy),
136144
by specifying the Job's `.spec.backoffLimit` field. However, in many situations
137-
it is problematic to find a balance between setting the a low value for `.spec.backoffLimit`
145+
it is problematic to find a balance between setting a low value for `.spec.backoffLimit`
138146
to avoid unnecessary Pod retries, yet high enough to make sure the Job would
139147
not be terminated by Pod disruptions.

0 commit comments

Comments
 (0)