Skip to content

Commit 0256078

Browse files
authored
Merge pull request #34484 from ydFu/update-cronjobs
[zh] Update Cronjobs
2 parents bdadfbc + e6fb3e1 commit 0256078

File tree

1 file changed

+18
-19
lines changed
  • content/zh-cn/docs/concepts/workloads/controllers

1 file changed

+18
-19
lines changed

content/zh-cn/docs/concepts/workloads/controllers/cron-jobs.md

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ recommended in a production cluster.
5454
-->
5555

5656
{{< caution >}}
57-
[v1 CronJob API](/zh/docs/reference/kubernetes-api/workload-resources/cron-job-v1/) 所述,官方并不支持设置时区。
57+
[v1 CronJob API](/zh-cn/docs/reference/kubernetes-api/workload-resources/cron-job-v1/) 所述,官方并不支持设置时区。
5858

5959
Kubernetes 项目官方并不支持设置如 `CRON_TZ` 或者 `TZ` 等变量。
6060
`CRON_TZ` 或者 `TZ` 是用于解析和计算下一个 Job 创建时间所使用的内部库中一个实现细节。
@@ -69,7 +69,7 @@ append 11 characters to the job name provided and there is a constraint that the
6969
maximum length of a Job name is no more than 63 characters.
7070
-->
7171
为 CronJob 资源创建清单时,请确保所提供的名称是一个合法的
72-
[DNS 子域名](/zh/docs/concepts/overview/working-with-objects/names#dns-subdomain-names).
72+
[DNS 子域名](/zh-cn/docs/concepts/overview/working-with-objects/names#dns-subdomain-names)
7373
名称不能超过 52 个字符。
7474
这是因为 CronJob 控制器将自动在提供的 Job 名称后附加 11 个字符,并且存在一个限制,
7575
即 Job 名称的最大长度不能超过 63 个字符。
@@ -84,8 +84,7 @@ report generation, and so on. Each of those tasks should be configured to recur
8484
indefinitely (for example: once a day / week / month); you can define the point
8585
in time within that interval when the job should start.
8686
-->
87-
## CronJob
88-
87+
## CronJob {#cronjob}
8988

9089
CronJob 用于执行周期性的动作,例如备份、报告生成等。
9190
这些任务中的每一个都应该配置为周期性重复的(例如:每天/每周/每月一次);
@@ -96,19 +95,19 @@ CronJob 用于执行周期性的动作,例如备份、报告生成等。
9695
9796
This example CronJob manifest prints the current time and a hello message every minute:
9897
-->
99-
### 示例
98+
### 示例 {#example}
10099

101100
下面的 CronJob 示例清单会在每分钟打印出当前时间和问候消息:
102101

103102
{{< codenew file="application/job/cronjob.yaml" >}}
104103

105-
[使用 CronJob 运行自动化任务](/zh/docs/tasks/job/automated-tasks-with-cron-jobs/)
104+
[使用 CronJob 运行自动化任务](/zh-cn/docs/tasks/job/automated-tasks-with-cron-jobs/)
106105
一文会为你详细讲解此例。
107106

108107
<!--
109108
### Cron schedule syntax
110109
-->
111-
### Cron 时间表语法
110+
### Cron 时间表语法 {#cron-schedule-syntax}
112111

113112
```
114113
# ┌───────────── 分钟 (0 - 59)
@@ -168,17 +167,17 @@ When you have the feature enabled, you can set `spec.timeZone` to the name of a
168167
A time zone database from the Go standard library is included in the binaries and used as a fallback in case an external database is not available on the system.
169168
-->
170169

171-
## 时区 {#time-zones}
170+
## 时区 {#time-zones}
172171
对于没有指定时区的 CronJob,kube-controller-manager 基于本地时区解释排期表(Schedule)。
173172

174173
{{< feature-state for_k8s_version="v1.24" state="alpha" >}}
175174

176-
如果启用了 `CronJobTimeZone` [特性门控](/zh/docs/reference/command-line-tools-reference/feature-gates/)
175+
如果启用了 `CronJobTimeZone` [特性门控](/zh-cn/docs/reference/command-line-tools-reference/feature-gates/)
177176
你可以为 CronJob 指定一个时区(如果你没有启用该特性门控,或者你使用的是不支持试验性时区功能的
178177
Kubernetes 版本,集群中所有 CronJob 的时区都是未指定的)。
179178

180179
启用该特性后,你可以将 `spec.timeZone`
181-
设置为有效[时区](https://zh.wikipedia.org/zh-hant/%E6%97%B6%E5%8C%BA%E4%BF%A1%E6%81%AF%E6%95%B0%E6%8D%AE%E5%BA%93s)名称。
180+
设置为有效[时区](https://zh.wikipedia.org/wiki/%E6%97%B6%E5%8C%BA%E4%BF%A1%E6%81%AF%E6%95%B0%E6%8D%AE%E5%BA%93)名称。
182181
例如,设置 `spec.timeZone: "Etc/UTC"` 指示 Kubernetes 采用 UTC 来解释排期表。
183182

184183
Go 标准库中的时区数据库包含在二进制文件中,并用作备用数据库,以防系统上没有可用的外部数据库。
@@ -188,7 +187,7 @@ Go 标准库中的时区数据库包含在二进制文件中,并用作备用
188187
## Time zones
189188
For CronJobs with no time zone specified, the kube-controller-manager interprets schedules relative to its local time zone.
190189
-->
191-
## 时区 {#time-zones}
190+
## 时区 {#time-zones}
192191
对于没有指定时区的 CronJob,kube-controller-manager 会根据其本地时区来解释其排期表(schedule)。
193192

194193
{{< feature-state for_k8s_version="v1.24" state="alpha" >}}
@@ -199,7 +198,7 @@ you can specify a time zone for a CronJob (if you don't enable that feature gate
199198
Kubernetes that does not have experimental time zone support, all CronJobs in your cluster have an unspecified
200199
timezone).
201200
-->
202-
如果启用 `CronJobTimeZone` [特性门控](/zh/docs/reference/command-line-tools-reference/feature-gates/)
201+
如果启用 `CronJobTimeZone` [特性门控](/zh-cn/docs/reference/command-line-tools-reference/feature-gates/)
203202
你可以为 CronJob 指定时区(如果你不启用该特性门控,或者如果你使用的 Kubernetes 版本不支持实验中的时区特性,
204203
则集群中的所有 CronJob 都属于未指定时区)。
205204

@@ -209,7 +208,7 @@ When you have the feature enabled, you can set `spec.timeZone` to the name of a
209208
210209
A time zone database from the Go standard library is included in the binaries and used as a fallback in case an external database is not available on the system.
211210
-->
212-
当你启用该特性时,你可以将 `spec.timeZone` 设置为有效的[时区](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)名称。
211+
当你启用该特性时,你可以将 `spec.timeZone` 设置为有效的[时区](https://zh.wikipedia.org/wiki/%E6%97%B6%E5%8C%BA%E4%BF%A1%E6%81%AF%E6%95%B0%E6%8D%AE%E5%BA%93)名称。
213212
例如,设置 `spec.timeZone: "Etc/UTC"` 表示 Kubernetes
214213
使用协调世界时(Coordinated Universal Time)进行解释排期表。
215214

@@ -221,7 +220,7 @@ A cron job creates a job object _about_ once per execution time of its schedule.
221220
are certain circumstances where two jobs might be created, or no job might be created. We attempt to make these rare,
222221
but do not completely prevent them. Therefore, jobs should be _idempotent_.
223222
-->
224-
## CronJob 限制 {#cron-job-limitations}
223+
## CronJob 限制 {#cronjob-limitations}
225224

226225
CronJob 根据其计划编排,在每次该执行任务的时候大约会创建一个 Job。
227226
我们之所以说 "大约",是因为在某些情况下,可能会创建两个 Job,或者不会创建任何 Job。
@@ -306,12 +305,12 @@ and use the original CronJob controller instead, one pass the `CronJobController
306305
flag to the {{< glossary_tooltip term_id="kube-controller-manager" text="kube-controller-manager" >}},
307306
and set this flag to `false`. For example:
308307
-->
309-
## 控制器版本 {#new-controller}
308+
## 控制器版本 {#new-controller}
310309

311310
从 Kubernetes v1.21 版本开始,CronJob 控制器的第二个版本被用作默认实现。
312311
要禁用此默认 CronJob 控制器而使用原来的 CronJob 控制器,请在
313312
{{< glossary_tooltip term_id="kube-controller-manager" text="kube-controller-manager" >}}
314-
中设置[特性门控](/zh/docs/reference/command-line-tools-reference/feature-gates/)
313+
中设置[特性门控](/zh-cn/docs/reference/command-line-tools-reference/feature-gates/)
315314
`CronJobControllerV2`,将此标志设置为 `false`。例如:
316315

317316
```
@@ -335,11 +334,11 @@ and set this flag to `false`. For example:
335334
object definition to understand the API for Kubernetes cron jobs.
336335
-->
337336

338-
* 了解 CronJob 所依赖的 [Pods](/zh/docs/concepts/workloads/pods/)[Job](/zh/docs/concepts/workloads/controllers/job/) 的概念。
337+
* 了解 CronJob 所依赖的 [Pod](/zh-cn/docs/concepts/workloads/pods/)[Job](/zh-cn/docs/concepts/workloads/controllers/job/) 的概念。
339338
* 阅读 CronJob `.spec.schedule` 字段的[格式](https://pkg.go.dev/github.com/robfig/cron/v3#hdr-CRON_Expression_Format)
340339
* 有关创建和使用 CronJob 的说明及示例规约文件,请参见
341-
[使用 CronJob 运行自动化任务](/zh/docs/tasks/job/automated-tasks-with-cron-jobs/)
342-
* 有关自动清理失败或完成作业的说明,请参阅[自动清理作业](/zh/docs/concepts/workloads/controllers/job/#clean-up-finished-jobs-automatically)
340+
[使用 CronJob 运行自动化任务](/zh-cn/docs/tasks/job/automated-tasks-with-cron-jobs/)
341+
* 有关自动清理失败或完成作业的说明,请参阅[自动清理作业](/zh-cn/docs/concepts/workloads/controllers/job/#clean-up-finished-jobs-automatically)
343342
* `CronJob` 是 Kubernetes REST API 的一部分,
344343
阅读 {{< api-reference page="workload-resources/cron-job-v1" >}}
345344
对象定义以了解关于该资源的 API。

0 commit comments

Comments
 (0)