-
Notifications
You must be signed in to change notification settings - Fork 963
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add documentation on ttlSecondsAfterFinished
Signed-off-by: Jeremy Solbrig <[email protected]>
- Loading branch information
Showing
1 changed file
with
63 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,63 @@ | ||
# How to Configure Volcano Job Time to Live | ||
## Background | ||
Similar to a standard `Job` resource, VolcanoJobs can be configured to be automatically garbage | ||
collected after they finish execution (either Complete or Failed). This is configured by setting | ||
`spec.ttlSecondsAfterFinished` which limits the lifetime of a Job. | ||
|
||
## Key Points | ||
`ttlSecondsAfterFinished` is an optional parameter that can be configured on VolcanoJobs which | ||
defaults to `nil`. The value of `ttlSecondsAfterFinished` must be a positive integer and indicates | ||
the number of seconds after a job finishes executing (either Complete or Failed) before it becomes | ||
eligible for garbage collection. | ||
|
||
If `ttlSecondsAfterFinished` is unset or set to `nil`, the job will remain indefinitely. If set to | ||
zero (`0`), the job will become eligible for garbage collection immediately upon completion. If set | ||
to a positive integer, `N`, the job will become eligible for garbage collection `N` seconds after | ||
the job has completed. | ||
|
||
## Other Reading | ||
While this uses a custom garbage collector, this operates nearly identically to | ||
`ttlSecondsAfterFinished` from a standard `batch.v1.job` resource. The [official Kubernetes | ||
documentation](https://kubernetes.io/docs/concepts/workloads/controllers/ttlafterfinished/) has some | ||
useful tips describing how mutating webhooks can be used to take greater advantage of | ||
`ttlSecondsAfterFinished`. | ||
|
||
## Example | ||
The manifest below creates a job that will be eligible for garbage collection 10 minutes after it | ||
either completes or fails. | ||
|
||
```yaml | ||
apiVersion: batch.volcano.sh/v1alpha1 | ||
kind: job | ||
metadata: | ||
generateName: test-job- | ||
spec: | ||
minAvailable: 1 | ||
schedulerName: volcano | ||
queue: testing | ||
ttlSecondsAfterFinished: 600 | ||
policies: | ||
- event: PodEvicted | ||
action: RestartJob | ||
tasks: | ||
- replicas: 1 | ||
name: sleeper | ||
policies: | ||
- event: TaskCompleted | ||
action: CompleteJob | ||
template: | ||
spec: | ||
restartPolicy: Never | ||
imagePullPolicy: IfNotPresent | ||
containers: | ||
- name: sleeper | ||
image: debian:buster | ||
command: | ||
- /bin/bash | ||
- -c | ||
- | | ||
for i in {0..5}; do | ||
echo "sleeping" | ||
sleep 1 | ||
done | ||
``` |