Merge pull request #34484 from ydFu/update-cronjobs
[zh] Update Cronjobs
This commit is contained in:
@@ -54,7 +54,7 @@ recommended in a production cluster.
|
||||
-->
|
||||
|
||||
{{< caution >}}
|
||||
如 [v1 CronJob API](/zh/docs/reference/kubernetes-api/workload-resources/cron-job-v1/) 所述,官方并不支持设置时区。
|
||||
如 [v1 CronJob API](/zh-cn/docs/reference/kubernetes-api/workload-resources/cron-job-v1/) 所述,官方并不支持设置时区。
|
||||
|
||||
Kubernetes 项目官方并不支持设置如 `CRON_TZ` 或者 `TZ` 等变量。
|
||||
`CRON_TZ` 或者 `TZ` 是用于解析和计算下一个 Job 创建时间所使用的内部库中一个实现细节。
|
||||
@@ -69,7 +69,7 @@ append 11 characters to the job name provided and there is a constraint that the
|
||||
maximum length of a Job name is no more than 63 characters.
|
||||
-->
|
||||
为 CronJob 资源创建清单时,请确保所提供的名称是一个合法的
|
||||
[DNS 子域名](/zh/docs/concepts/overview/working-with-objects/names#dns-subdomain-names).
|
||||
[DNS 子域名](/zh-cn/docs/concepts/overview/working-with-objects/names#dns-subdomain-names)。
|
||||
名称不能超过 52 个字符。
|
||||
这是因为 CronJob 控制器将自动在提供的 Job 名称后附加 11 个字符,并且存在一个限制,
|
||||
即 Job 名称的最大长度不能超过 63 个字符。
|
||||
@@ -84,8 +84,7 @@ report generation, and so on. Each of those tasks should be configured to recur
|
||||
indefinitely (for example: once a day / week / month); you can define the point
|
||||
in time within that interval when the job should start.
|
||||
-->
|
||||
## CronJob
|
||||
|
||||
## CronJob {#cronjob}
|
||||
|
||||
CronJob 用于执行周期性的动作,例如备份、报告生成等。
|
||||
这些任务中的每一个都应该配置为周期性重复的(例如:每天/每周/每月一次);
|
||||
@@ -96,19 +95,19 @@ CronJob 用于执行周期性的动作,例如备份、报告生成等。
|
||||
|
||||
This example CronJob manifest prints the current time and a hello message every minute:
|
||||
-->
|
||||
### 示例
|
||||
### 示例 {#example}
|
||||
|
||||
下面的 CronJob 示例清单会在每分钟打印出当前时间和问候消息:
|
||||
|
||||
{{< codenew file="application/job/cronjob.yaml" >}}
|
||||
|
||||
[使用 CronJob 运行自动化任务](/zh/docs/tasks/job/automated-tasks-with-cron-jobs/)
|
||||
[使用 CronJob 运行自动化任务](/zh-cn/docs/tasks/job/automated-tasks-with-cron-jobs/)
|
||||
一文会为你详细讲解此例。
|
||||
|
||||
<!--
|
||||
### Cron schedule syntax
|
||||
-->
|
||||
### Cron 时间表语法
|
||||
### Cron 时间表语法 {#cron-schedule-syntax}
|
||||
|
||||
```
|
||||
# ┌───────────── 分钟 (0 - 59)
|
||||
@@ -168,17 +167,17 @@ When you have the feature enabled, you can set `spec.timeZone` to the name of a
|
||||
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.
|
||||
-->
|
||||
|
||||
## 时区 {#time-zones}
|
||||
## 时区 {#time-zones}
|
||||
对于没有指定时区的 CronJob,kube-controller-manager 基于本地时区解释排期表(Schedule)。
|
||||
|
||||
{{< feature-state for_k8s_version="v1.24" state="alpha" >}}
|
||||
|
||||
如果启用了 `CronJobTimeZone` [特性门控](/zh/docs/reference/command-line-tools-reference/feature-gates/),
|
||||
如果启用了 `CronJobTimeZone` [特性门控](/zh-cn/docs/reference/command-line-tools-reference/feature-gates/),
|
||||
你可以为 CronJob 指定一个时区(如果你没有启用该特性门控,或者你使用的是不支持试验性时区功能的
|
||||
Kubernetes 版本,集群中所有 CronJob 的时区都是未指定的)。
|
||||
|
||||
启用该特性后,你可以将 `spec.timeZone`
|
||||
设置为有效[时区](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)名称。
|
||||
设置为有效[时区](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)名称。
|
||||
例如,设置 `spec.timeZone: "Etc/UTC"` 指示 Kubernetes 采用 UTC 来解释排期表。
|
||||
|
||||
Go 标准库中的时区数据库包含在二进制文件中,并用作备用数据库,以防系统上没有可用的外部数据库。
|
||||
@@ -188,7 +187,7 @@ Go 标准库中的时区数据库包含在二进制文件中,并用作备用
|
||||
## Time zones
|
||||
For CronJobs with no time zone specified, the kube-controller-manager interprets schedules relative to its local time zone.
|
||||
-->
|
||||
## 时区 {#time-zones}
|
||||
## 时区 {#time-zones}
|
||||
对于没有指定时区的 CronJob,kube-controller-manager 会根据其本地时区来解释其排期表(schedule)。
|
||||
|
||||
{{< 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
|
||||
Kubernetes that does not have experimental time zone support, all CronJobs in your cluster have an unspecified
|
||||
timezone).
|
||||
-->
|
||||
如果启用 `CronJobTimeZone` [特性门控](/zh/docs/reference/command-line-tools-reference/feature-gates/),
|
||||
如果启用 `CronJobTimeZone` [特性门控](/zh-cn/docs/reference/command-line-tools-reference/feature-gates/),
|
||||
你可以为 CronJob 指定时区(如果你不启用该特性门控,或者如果你使用的 Kubernetes 版本不支持实验中的时区特性,
|
||||
则集群中的所有 CronJob 都属于未指定时区)。
|
||||
|
||||
@@ -209,7 +208,7 @@ When you have the feature enabled, you can set `spec.timeZone` to the name of a
|
||||
|
||||
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.
|
||||
-->
|
||||
当你启用该特性时,你可以将 `spec.timeZone` 设置为有效的[时区](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)名称。
|
||||
当你启用该特性时,你可以将 `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)名称。
|
||||
例如,设置 `spec.timeZone: "Etc/UTC"` 表示 Kubernetes
|
||||
使用协调世界时(Coordinated Universal Time)进行解释排期表。
|
||||
|
||||
@@ -221,7 +220,7 @@ A cron job creates a job object _about_ once per execution time of its schedule.
|
||||
are certain circumstances where two jobs might be created, or no job might be created. We attempt to make these rare,
|
||||
but do not completely prevent them. Therefore, jobs should be _idempotent_.
|
||||
-->
|
||||
## CronJob 限制 {#cron-job-limitations}
|
||||
## CronJob 限制 {#cronjob-limitations}
|
||||
|
||||
CronJob 根据其计划编排,在每次该执行任务的时候大约会创建一个 Job。
|
||||
我们之所以说 "大约",是因为在某些情况下,可能会创建两个 Job,或者不会创建任何 Job。
|
||||
@@ -306,12 +305,12 @@ and use the original CronJob controller instead, one pass the `CronJobController
|
||||
flag to the {{< glossary_tooltip term_id="kube-controller-manager" text="kube-controller-manager" >}},
|
||||
and set this flag to `false`. For example:
|
||||
-->
|
||||
## 控制器版本 {#new-controller}
|
||||
## 控制器版本 {#new-controller}
|
||||
|
||||
从 Kubernetes v1.21 版本开始,CronJob 控制器的第二个版本被用作默认实现。
|
||||
要禁用此默认 CronJob 控制器而使用原来的 CronJob 控制器,请在
|
||||
{{< glossary_tooltip term_id="kube-controller-manager" text="kube-controller-manager" >}}
|
||||
中设置[特性门控](/zh/docs/reference/command-line-tools-reference/feature-gates/)
|
||||
中设置[特性门控](/zh-cn/docs/reference/command-line-tools-reference/feature-gates/)
|
||||
`CronJobControllerV2`,将此标志设置为 `false`。例如:
|
||||
|
||||
```
|
||||
@@ -335,11 +334,11 @@ and set this flag to `false`. For example:
|
||||
object definition to understand the API for Kubernetes cron jobs.
|
||||
-->
|
||||
|
||||
* 了解 CronJob 所依赖的 [Pods](/zh/docs/concepts/workloads/pods/) 与 [Job](/zh/docs/concepts/workloads/controllers/job/) 的概念。
|
||||
* 了解 CronJob 所依赖的 [Pod](/zh-cn/docs/concepts/workloads/pods/) 与 [Job](/zh-cn/docs/concepts/workloads/controllers/job/) 的概念。
|
||||
* 阅读 CronJob `.spec.schedule` 字段的[格式](https://pkg.go.dev/github.com/robfig/cron/v3#hdr-CRON_Expression_Format)。
|
||||
* 有关创建和使用 CronJob 的说明及示例规约文件,请参见
|
||||
[使用 CronJob 运行自动化任务](/zh/docs/tasks/job/automated-tasks-with-cron-jobs/)。
|
||||
* 有关自动清理失败或完成作业的说明,请参阅[自动清理作业](/zh/docs/concepts/workloads/controllers/job/#clean-up-finished-jobs-automatically)
|
||||
[使用 CronJob 运行自动化任务](/zh-cn/docs/tasks/job/automated-tasks-with-cron-jobs/)。
|
||||
* 有关自动清理失败或完成作业的说明,请参阅[自动清理作业](/zh-cn/docs/concepts/workloads/controllers/job/#clean-up-finished-jobs-automatically)
|
||||
* `CronJob` 是 Kubernetes REST API 的一部分,
|
||||
阅读 {{< api-reference page="workload-resources/cron-job-v1" >}}
|
||||
对象定义以了解关于该资源的 API。
|
||||
|
||||
Reference in New Issue
Block a user