Skip to content

Commit 988505d

Browse files
committed
adapt review suggestions
1 parent 6dcaacb commit 988505d

File tree

1 file changed

+42
-25
lines changed

1 file changed

+42
-25
lines changed

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

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Unix system. It runs a job periodically on a given schedule, written in
2020
[Cron](https://en.wikipedia.org/wiki/Cron) format.
2121

2222
CronJobs have limitations and idiosyncrasies.
23-
For example, in certain circumstances, a single cron job can create multiple jobs. See the [limitations](#cron-job-limitations) below.
23+
For example, in certain circumstances, a single CronJob can create multiple concurrent Jobs. See the [limitations](#cron-job-limitations) below.
2424

2525
When the control plane creates new Jobs and (indirectly) Pods for a CronJob, the `.metadata.name`
2626
of the CronJob is part of the basis for naming those Pods. The name of a CronJob must be a valid
@@ -44,8 +44,8 @@ This example CronJob manifest prints the current time and a hello message every
4444
takes you through this example in more detail).
4545

4646
## Writing a CronJob spec
47-
### Schedule
48-
The `.spec.schedule` is a required field and follows the [Cron](https://en.wikipedia.org/wiki/Cron) syntax below:
47+
### Schedule syntax
48+
The `.spec.schedule` field is required. The value of that field follows the [Cron](https://en.wikipedia.org/wiki/Cron) syntax:
4949

5050
```
5151
# ┌───────────── minute (0 - 59)
@@ -88,20 +88,29 @@ Other than the standard syntax, some macros like `@monthly` can also be used:
8888

8989
To generate CronJob schedule expressions, you can also use web tools like [crontab.guru](https://crontab.guru/).
9090

91-
### Job Template
91+
### Job template
9292

93-
The `.spec.jobTemplate` is the template for the job, and it is required.
93+
The `.spec.jobTemplate` defines a template for the Jobs that the CronJob creates, and it is required.
9494
It has exactly the same schema as a [Job](/docs/concepts/workloads/controllers/job/), except that
9595
it is nested and does not have an `apiVersion` or `kind`.
96-
For information about writing a job `.spec`, see [Writing a Job Spec](/docs/concepts/workloads/controllers/job/#writing-a-job-spec).
96+
You can specify common metadata for the templated Jobs, such as
97+
{{< glossary_tooltip text="labels" term_id="label" >}} or
98+
{{< glossary_tooltip text="annotations" term_id="annotation" >}}.
99+
For information about writing a Job `.spec`, see [Writing a Job Spec](/docs/concepts/workloads/controllers/job/#writing-a-job-spec).
97100

98-
### Starting Deadline
101+
### Deadline for delayed job start {#starting-deadline}
99102

100103
The `.spec.startingDeadlineSeconds` field is optional.
101-
It stands for the deadline in seconds for starting the job if it misses its scheduled time for any reason.
102-
After the deadline, the CronJob does not start the job.
103-
Jobs that do not meet their deadline in this way count as failed jobs.
104-
If this field is not specified, the jobs have no deadline.
104+
This field defines a deadline (in whole seconds) for starting the Job, if that Job misses its scheduled time
105+
for any reason.
106+
107+
After missing the deadline, the CronJob skips that instance of the Job (future occurrences are still scheduled).
108+
For example, if you have a backup job that runs twice a day, you might allow it to start up to 8 hours late,
109+
but no later, because a backup taken any later wouldn't be useful: you would instead prefer to wait for
110+
the next scheduled run.
111+
112+
For Jobs that miss their configured deadline, Kubernetes treats them as failed Jobs.
113+
If you don't specify `startingDeadlineSeconds` for a CronJob, the Job occurrences have no deadline.
105114

106115
If the `.spec.startingDeadlineSeconds` field is set (not null), the CronJob
107116
controller measures the time between when a job is expected to be created and
@@ -110,7 +119,7 @@ now. If the difference is higher than that limit, it will skip this execution.
110119
For example, if it is set to `200`, it allows a job to be created for up to 200
111120
seconds after the actual schedule.
112121

113-
### Concurrency Policy
122+
### Concurrency policy
114123

115124
The `.spec.concurrencyPolicy` field is also optional.
116125
It specifies how to treat concurrent executions of a job that is created by this CronJob.
@@ -125,20 +134,24 @@ The spec may specify only one of the following concurrency policies:
125134
Note that concurrency policy only applies to the jobs created by the same cron job.
126135
If there are multiple CronJobs, their respective jobs are always allowed to run concurrently.
127136

128-
### Suspend
137+
### Schedule suspension
138+
139+
You can suspend execution of Jobs for a CronJob, by setting the optional `.spec.suspend` field
140+
to true. The field defaults to false.
141+
142+
This setting does _not_ affect Jobs that the CronJob has already started.
129143

130-
The `.spec.suspend` field is also optional.
131-
If it is set to `true`, all subsequent executions are suspended.
132-
This setting does not apply to already started executions.
133-
Defaults to false.
144+
If you do set that field to true, all subsequent executions are suspended (they remain
145+
scheduled, but the CronJob controller does not start the Jobs to run the tasks) until
146+
you unsuspend the CronJob.
134147

135148
{{< caution >}}
136149
Executions that are suspended during their scheduled time count as missed jobs.
137150
When `.spec.suspend` changes from `true` to `false` on an existing CronJob without a
138151
[starting deadline](#starting-deadline), the missed jobs are scheduled immediately.
139152
{{< /caution >}}
140153

141-
### Jobs History Limits
154+
### Jobs history limits
142155

143156
The `.spec.successfulJobsHistoryLimit` and `.spec.failedJobsHistoryLimit` fields are optional.
144157
These fields specify how many completed and failed jobs should be kept.
@@ -178,15 +191,19 @@ A time zone database from the Go standard library is included in the binaries an
178191
## CronJob limitations {#cron-job-limitations}
179192

180193
### Modifying a CronJob
181-
If you modify a CronJob, the changes you make will apply to new jobs that start to run after your modification
182-
is complete. Jobs (and their Pods) that have already started continue to run without changes.
183-
That is, the CronJob does _not_ update existing jobs, even if those remain running.
194+
By design, a CronJob contains a template for _new_ Jobs.
195+
If you modify an existing CronJob, the changes you make will apply to new Jobs that
196+
start to run after your modification is complete. Jobs (and their Pods) that have already
197+
started continue to run without changes.
198+
That is, the CronJob does _not_ update existing Jobs, even if those remain running.
184199

185200
### Job creation
186201

187-
A CronJob creates a job object _about_ once per execution time of its schedule. We say "about" because there
188-
are certain circumstances where two jobs might be created, or no job might be created. We attempt to make these rare,
189-
but do not completely prevent them. Therefore, jobs should be _idempotent_.
202+
A CronJob creates a Job object approximately once per execution time of its schedule.
203+
The scheduling is approximate because there
204+
are certain circumstances where two Jobs might be created, or no Job might be created.
205+
Kubernetes tries to avoid those situations, but do not completely prevent them. Therefore,
206+
the Jobs that you define should be _idempotent_.
190207

191208
If `startingDeadlineSeconds` is set to a large value or left unset (the default)
192209
and if `concurrencyPolicy` is set to `Allow`, the jobs will always run
@@ -230,4 +247,4 @@ the Job in turn is responsible for the management of the Pods it represents.
230247
see [Running automated tasks with CronJobs](/docs/tasks/job/automated-tasks-with-cron-jobs/).
231248
* `CronJob` is part of the Kubernetes REST API.
232249
Read the {{< api-reference page="workload-resources/cron-job-v1" >}}
233-
reference doc for more details.
250+
API reference for more details.

0 commit comments

Comments
 (0)