Skip to content

Commit 0af4dd9

Browse files
authored
Merge pull request #30031 from sahilvv/ga_ttl
GA TTLAfterFinished
2 parents 5a58eb4 + 1111731 commit 0af4dd9

File tree

3 files changed

+27
-31
lines changed

3 files changed

+27
-31
lines changed

content/en/docs/concepts/workloads/controllers/cron-jobs.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,5 @@ documents the format of CronJob `schedule` fields.
142142
For instructions on creating and working with cron jobs, and for an example of CronJob
143143
manifest, see [Running automated tasks with cron jobs](/docs/tasks/job/automated-tasks-with-cron-jobs).
144144

145+
For instructions to clean up failed or completed jobs automatically, see
146+
[Clean up Jobs automatically](/docs/concepts/workloads/controllers/job/#clean-up-finished-jobs-automatically)

content/en/docs/concepts/workloads/controllers/ttlafterfinished.md

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,68 @@
11
---
22
reviewers:
33
- janetkuo
4-
title: TTL Controller for Finished Resources
4+
title: Automatic Clean-up for Finished Jobs
55
content_type: concept
66
weight: 70
77
---
88

99
<!-- overview -->
1010

11-
{{< feature-state for_k8s_version="v1.21" state="beta" >}}
11+
{{< feature-state for_k8s_version="v1.23" state="stable" >}}
1212

13-
The TTL controller provides a TTL (time to live) mechanism to limit the lifetime of resource
14-
objects that have finished execution. TTL controller only handles
15-
{{< glossary_tooltip text="Jobs" term_id="job" >}} for now,
16-
and may be expanded to handle other resources that will finish execution,
17-
such as Pods and custom resources.
18-
19-
This feature is currently beta and enabled by default, and can be disabled via
20-
[feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
21-
`TTLAfterFinished` in both kube-apiserver and kube-controller-manager.
13+
TTL-after-finished {{<glossary_tooltip text="controller" term_id="controller">}} provides a
14+
TTL (time to live) mechanism to limit the lifetime of resource objects that
15+
have finished execution. TTL controller only handles
16+
{{< glossary_tooltip text="Jobs" term_id="job" >}}.
2217

2318
<!-- body -->
2419

25-
## TTL Controller
20+
## TTL-after-finished Controller
2621

27-
The TTL controller only supports Jobs for now. A cluster operator can use this feature to clean
22+
The TTL-after-finished controller is only supported for Jobs. A cluster operator can use this feature to clean
2823
up finished Jobs (either `Complete` or `Failed`) automatically by specifying the
2924
`.spec.ttlSecondsAfterFinished` field of a Job, as in this
3025
[example](/docs/concepts/workloads/controllers/job/#clean-up-finished-jobs-automatically).
31-
The TTL controller will assume that a resource is eligible to be cleaned up
32-
TTL seconds after the resource has finished, in other words, when the TTL has expired. When the
33-
TTL controller cleans up a resource, it will delete it cascadingly, that is to say it will delete
34-
its dependent objects together with it. Note that when the resource is deleted,
26+
The TTL-after-finished controller will assume that a job is eligible to be cleaned up
27+
TTL seconds after the job has finished, in other words, when the TTL has expired. When the
28+
TTL-after-finished controller cleans up a job, it will delete it cascadingly, that is to say it will delete
29+
its dependent objects together with it. Note that when the job is deleted,
3530
its lifecycle guarantees, such as finalizers, will be honored.
3631

3732
The TTL seconds can be set at any time. Here are some examples for setting the
3833
`.spec.ttlSecondsAfterFinished` field of a Job:
3934

40-
* Specify this field in the resource manifest, so that a Job can be cleaned up
35+
* Specify this field in the job manifest, so that a Job can be cleaned up
4136
automatically some time after it finishes.
42-
* Set this field of existing, already finished resources, to adopt this new
37+
* Set this field of existing, already finished jobs, to adopt this new
4338
feature.
4439
* Use a
4540
[mutating admission webhook](/docs/reference/access-authn-authz/extensible-admission-controllers/#admission-webhooks)
46-
to set this field dynamically at resource creation time. Cluster administrators can
47-
use this to enforce a TTL policy for finished resources.
41+
to set this field dynamically at job creation time. Cluster administrators can
42+
use this to enforce a TTL policy for finished jobs.
4843
* Use a
4944
[mutating admission webhook](/docs/reference/access-authn-authz/extensible-admission-controllers/#admission-webhooks)
50-
to set this field dynamically after the resource has finished, and choose
51-
different TTL values based on resource status, labels, etc.
45+
to set this field dynamically after the job has finished, and choose
46+
different TTL values based on job status, labels, etc.
5247

5348
## Caveat
5449

5550
### Updating TTL Seconds
5651

5752
Note that the TTL period, e.g. `.spec.ttlSecondsAfterFinished` field of Jobs,
58-
can be modified after the resource is created or has finished. However, once the
53+
can be modified after the job is created or has finished. However, once the
5954
Job becomes eligible to be deleted (when the TTL has expired), the system won't
6055
guarantee that the Jobs will be kept, even if an update to extend the TTL
6156
returns a successful API response.
6257

6358
### Time Skew
6459

65-
Because TTL controller uses timestamps stored in the Kubernetes resources to
60+
Because TTL-after-finished controller uses timestamps stored in the Kubernetes jobs to
6661
determine whether the TTL has expired or not, this feature is sensitive to time
67-
skew in the cluster, which may cause TTL controller to clean up resource objects
62+
skew in the cluster, which may cause TTL-after-finish controller to clean up job objects
6863
at the wrong time.
6964

70-
In Kubernetes, it's required to run NTP on all nodes
71-
(see [#6159](https://github.com/kubernetes/kubernetes/issues/6159#issuecomment-93844058))
72-
to avoid time skew. Clocks aren't always correct, but the difference should be
65+
Clocks aren't always correct, but the difference should be
7366
very small. Please be aware of this risk when setting a non-zero TTL.
7467

7568

content/en/docs/reference/command-line-tools-reference/feature-gates.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,6 @@ different Kubernetes components.
190190
| `StorageVersionHash` | `true` | Beta | 1.15 | |
191191
| `SuspendJob` | `false` | Alpha | 1.21 | 1.21 |
192192
| `SuspendJob` | `true` | Beta | 1.22 | |
193-
| `TTLAfterFinished` | `false` | Alpha | 1.12 | 1.20 |
194-
| `TTLAfterFinished` | `true` | Beta | 1.21 | |
195193
| `TopologyAwareHints` | `false` | Alpha | 1.21 | |
196194
| `TopologyManager` | `false` | Alpha | 1.16 | 1.17 |
197195
| `TopologyManager` | `true` | Beta | 1.18 | |
@@ -439,6 +437,9 @@ different Kubernetes components.
439437
| `SupportPodPidsLimit` | `true` | GA | 1.20 | - |
440438
| `Sysctls` | `true` | Beta | 1.11 | 1.20 |
441439
| `Sysctls` | `true` | GA | 1.21 | |
440+
| `TTLAfterFinished` | `false` | Alpha | 1.12 | 1.20 |
441+
| `TTLAfterFinished` | `true` | Beta | 1.21 | 1.22 |
442+
| `TTLAfterFinished` | `true` | GA | 1.23 | - |
442443
| `TaintBasedEvictions` | `false` | Alpha | 1.6 | 1.12 |
443444
| `TaintBasedEvictions` | `true` | Beta | 1.13 | 1.17 |
444445
| `TaintBasedEvictions` | `true` | GA | 1.18 | - |

0 commit comments

Comments
 (0)