Skip to content

Commit

Permalink
Use kubectl to wait for Jobs to succeed
Browse files Browse the repository at this point in the history
No need to poll: there's a subcommand for that.
  • Loading branch information
sftim committed Oct 29, 2022
1 parent c6ec678 commit 5ed062f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
12 changes: 10 additions & 2 deletions content/en/docs/tasks/job/coarse-parallel-processing-work-queue.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,13 @@ So, now run the Job:
kubectl apply -f ./job.yaml
```

Now wait a bit, then check on the job.
You can wait for the Job to succeed, with a timeout:
```shell
# The check for condition name is case insensitive
kubectl wait --for=condition=complete --timeout=300s job/job-wq-1
```

Next, check on the Job:

```shell
kubectl describe jobs/job-wq-1
Expand Down Expand Up @@ -285,7 +291,9 @@ Events:
14s 14s 1 {job } Normal SuccessfulCreate Created pod: job-wq-1-p17e0
```

All our pods succeeded. Yay.


All the pods for that Job succeeded. Yay.



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,18 @@ Events:
FirstSeen LastSeen Count From SubobjectPath Type Reason Message
--------- -------- ----- ---- ------------- -------- ------ -------
33s 33s 1 {job-controller } Normal SuccessfulCreate Created pod: job-wq-2-lglf8
```

You can wait for the Job to succeed, with a timeout:
```shell
# The check for condition name is case insensitive
kubectl wait --for=condition=complete --timeout=300s job/job-wq-2
```

```shell
kubectl logs pods/job-wq-2-7r7b2
```
```
Worker with sessionID: bbd72d0a-9e5c-4dd6-abf6-416cc267991f
Initial queue state: empty=False
Working on banana
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,14 @@ When you create this Job, the control plane creates a series of Pods, one for ea

Because `.spec.parallelism` is less than `.spec.completions`, the control plane waits for some of the first Pods to complete before starting more of them.

Once you have created the Job, wait a moment then check on progress:
You can wait for the Job to succeed, with a timeout:
```shell
# The check for condition name is case insensitive
kubectl wait --for=condition=complete --timeout=300s job/indexed-job
```

Now, describe the Job and check that it was successful.


```shell
kubectl describe jobs/indexed-job
Expand Down

0 comments on commit 5ed062f

Please sign in to comment.