Skip to content

Commit 65a5f83

Browse files
committed
[zh] Resync concepts section (9)
1 parent c8ce980 commit 65a5f83

File tree

4 files changed

+175
-61
lines changed

4 files changed

+175
-61
lines changed

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

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ weight: 80
1212

1313
<!-- overview -->
1414

15-
{{< feature-state for_k8s_version="v1.8" state="beta" >}}
15+
{{< feature-state for_k8s_version="v1.21" state="stable" >}}
1616

1717
<!--
18-
A _Cron Job_ creates [Jobs](/docs/concepts/workloads/controllers/jobs-run-to-completion/) on a time-based schedule.
18+
A _CronJob_ creates {{< glossary_tooltip term_id="job" text="Jobs" >}} on a repeating schedule.
1919
2020
One CronJob object is like one line of a _crontab_ (cron table) file. It runs a job periodically
2121
on a given schedule, written in [Cron](https://en.wikipedia.org/wiki/Cron) format.
2222
-->
23-
_Cron Job_ 创建基于时间调度的 [Jobs](/zh/docs/concepts/workloads/controllers/job/)
23+
_CronJob_ 创建基于时隔重复调度的 {{< glossary_tooltip term_id="job" text="Jobs" >}}
2424

2525
一个 CronJob 对象就像 _crontab_ (cron table) 文件中的一行。
2626
它用 [Cron](https://en.wikipedia.org/wiki/Cron) 格式进行编写,
@@ -102,24 +102,22 @@ This example CronJob manifest prints the current time and a hello message every
102102
# * * * * *
103103
```
104104

105-
106105
<!--
107-
| Entry | Description | Equivalent to |
108-
| ------------- | ------------- |------------- |
109-
| @yearly (or @annually) | Run once a year at midnight of 1 January | 0 0 1 1 * |
110-
| @monthly | Run once a month at midnight of the first day of the month | 0 0 1 * * |
111-
| @weekly | Run once a week at midnight on Sunday morning | 0 0 * * 0 |
112-
| @daily (or @midnight) | Run once a day at midnight | 0 0 * * * |
113-
| @hourly | Run once an hour at the beginning of the hour | 0 * * * * |
114-
-->
115-
| 输入 | 描述 | 相当于 |
116-
| ------------- | ------------- |------------- |
117-
| @yearly (or @annually) | 每年 1 月 1 日的午夜运行一次 | 0 0 1 1 * |
118-
| @monthly | 每月第一天的午夜运行一次 | 0 0 1 * * |
119-
| @weekly | 每周的周日午夜运行一次 | 0 0 * * 0 |
120-
| @daily (or @midnight) | 每天午夜运行一次 | 0 0 * * * |
121-
| @hourly | 每小时的开始一次 | 0 * * * * |
122-
106+
| Entry | Description | Equivalent to |
107+
| ------------- | ------------- |------------- |
108+
| @yearly (or @annually) | Run once a year at midnight of 1 January | 0 0 1 1 * |
109+
| @monthly | Run once a month at midnight of the first day of the month | 0 0 1 * * |
110+
| @weekly | Run once a week at midnight on Sunday morning | 0 0 * * 0 |
111+
| @daily (or @midnight) | Run once a day at midnight | 0 0 * * * |
112+
| @hourly | Run once an hour at the beginning of the hour | 0 * * * * |
113+
-->
114+
| 输入 | 描述 | 相当于 |
115+
| ------------- | ------------- |------------- |
116+
| @yearly (or @annually) | 每年 1 月 1 日的午夜运行一次 | 0 0 1 1 * |
117+
| @monthly | 每月第一天的午夜运行一次 | 0 0 1 * * |
118+
| @weekly | 每周的周日午夜运行一次 | 0 0 * * 0 |
119+
| @daily (or @midnight) | 每天午夜运行一次 | 0 0 * * * |
120+
| @hourly | 每小时的开始一次 | 0 * * * * |
123121

124122
<!--
125123
For example, the line below states that the task must be started every Friday at midnight, as well as on the 13th of each month at midnight:
@@ -192,8 +190,10 @@ For example, suppose a CronJob is set to schedule a new Job every one minute beg
192190
`startingDeadlineSeconds` field is not set. If the CronJob controller happens to
193191
be down from `08:29:00` to `10:21:00`, the job will not start as the number of missed jobs which missed their schedule is greater than 100.
194192
-->
195-
例如,假设一个 CronJob 被设置为从 `08:30:00` 开始每隔一分钟创建一个新的 Job,并且它的 `startingDeadlineSeconds` 字段
196-
未被设置。如果 CronJob 控制器从 `08:29:00``10:21:00` 终止运行,则该 Job 将不会启动,因为其错过的调度次数超过了100。
193+
例如,假设一个 CronJob 被设置为从 `08:30:00` 开始每隔一分钟创建一个新的 Job,
194+
并且它的 `startingDeadlineSeconds` 字段未被设置。如果 CronJob 控制器从
195+
`08:29:00``10:21:00` 终止运行,则该 Job 将不会启动,因为其错过的调度
196+
次数超过了 100。
197197

198198
<!--
199199
To illustrate this concept further, suppose a CronJob is set to schedule a new Job every one minute beginning at `08:30:00`, and its
@@ -214,22 +214,25 @@ the Job in turn is responsible for the management of the Pods it represents.
214214
CronJob 仅负责创建与其调度时间相匹配的 Job,而 Job 又负责管理其代表的 Pod。
215215

216216
<!--
217-
## New controller
218-
219-
There's an alternative implementation of the CronJob controller, available as an alpha feature since Kubernetes 1.20. To select version 2 of the CronJob controller, pass the following [feature gate](/docs/reference/command-line-tools-reference/feature-gates/) flag to the {{< glossary_tooltip term_id="kube-controller-manager" text="kube-controller-manager" >}}.
217+
## Controller version {#new-controller}
220218
221-
```
222-
--feature-gates="CronJobControllerV2=true"
223-
```
219+
Starting with Kubernetes v1.21 the second version of the CronJob controller
220+
is the default implementation. To disable the default CronJob controller
221+
and use the original CronJob controller instead, one pass the `CronJobControllerV2`
222+
[feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
223+
flag to the {{< glossary_tooltip term_id="kube-controller-manager" text="kube-controller-manager" >}},
224+
and set this flag to `false`. For example:
224225
-->
225-
## 新控制器
226+
## 控制器版本 {#new-controller}
226227

227-
CronJob 控制器有一个替代的实现,自 Kubernetes 1.20 开始以 alpha 特性引入。
228-
如果选择 CronJob 控制器的 v2 版本,请在 {{< glossary_tooltip term_id="kube-controller-manager" text="kube-controller-manager" >}}
229-
中设置以下[特性门控](/zh/docs/reference/command-line-tools-reference/feature-gates/) 标志。
228+
从 Kubernetes v1.21 版本开始,CronJob 控制器的第二个版本被用作默认实现。
229+
要禁用此默认 CronJob 控制器而使用原来的 CronJob 控制器,请在
230+
{{< glossary_tooltip term_id="kube-controller-manager" text="kube-controller-manager" >}}
231+
中设置[特性门控](/zh/docs/reference/command-line-tools-reference/feature-gates/)
232+
`CronJobControllerV2`,将此标志设置为 `false`。例如:
230233

231234
```
232-
--feature-gates="CronJobControllerV2=true"
235+
--feature-gates="CronJobControllerV2=false"
233236
```
234237

235238
## {{% heading "whatsnext" %}}
@@ -240,7 +243,8 @@ documents the format of CronJob `schedule` fields.
240243
For instructions on creating and working with cron jobs, and for an example of a spec file for a cron job, see [Running automated tasks with cron jobs](/docs/tasks/job/automated-tasks-with-cron-jobs).
241244
-->
242245

243-
* 进一步了解 [Cron 表达式的格式](https://en.wikipedia.org/wiki/Cron),学习设置 CronJob `schedule` 字段
246+
* 进一步了解 [Cron 表达式的格式](https://en.wikipedia.org/wiki/Cron),学习设置
247+
CronJob `schedule` 字段
244248
* 有关创建和使用 CronJob 的说明及示例规约文件,请参见
245249
[使用 CronJob 运行自动化任务](/zh/docs/tasks/job/automated-tasks-with-cron-jobs/)
246250

content/zh/docs/concepts/workloads/controllers/replicaset.md

Lines changed: 97 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ curl -X DELETE 'localhost:8080/apis/apps/v1/namespaces/default/replicasets/fron
472472
<!--
473473
### Deleting just a ReplicaSet
474474

475-
You can delete a ReplicaSet without affecting any of its Pods using [`kubectl delete`](/docs/reference/generated/kubectl/kubectl-commands#delete) with the `--cascade=orphan` option.
475+
You can delete a ReplicaSet without affecting any of its Pods using [`kubectl delete`](/docs/reference/generated/kubectl/kubectl-commands#delete) with the `-cascade=orphan` option.
476476
When using the REST API or the `client-go` library, you must set `propagationPolicy` to `Orphan`.
477477
For example:
478478
-->
@@ -531,6 +531,102 @@ ensures that a desired number of pods with a matching label selector are availab
531531
通过更新 `.spec.replicas` 字段,ReplicaSet 可以被轻松的进行缩放。ReplicaSet
532532
控制器能确保匹配标签选择器的数量的 Pod 是可用的和可操作的。
533533

534+
<!--
535+
When scaling down, the ReplicaSet controller chooses which pods to delete by sorting the available pods to
536+
prioritize scaling down pods based on the following general algorithm:
537+
-->
538+
在降低集合规模时,ReplicaSet 控制器通过对可用的 Pods 进行排序来优先选择
539+
要被删除的 Pods。其一般性算法如下:
540+
541+
<!--
542+
1. Pending (and unschedulable) pods are scaled down first
543+
2. If controller.kubernetes.io/pod-deletion-cost annotation is set, then
544+
the pod with the lower value will come first.
545+
3. Pods on nodes with more replicas come before pods on nodes with fewer replicas.
546+
4. If the pods' creation times differ, the pod that was created more recently
547+
comes before the older pod (the creation times are bucketed on an integer log scale
548+
when the `LogarithmicScaleDown` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/) is enabled)
549+
-->
550+
1. 首先选择剔除悬决(Pending,且不可调度)的 Pods
551+
2. 如果设置了 `controller.kubernetes.io/pod-deletion-cost` 注解,则注解值
552+
较小的优先被裁减掉
553+
3. 所处节点上副本个数较多的 Pod 优先于所处节点上副本较少者
554+
4. 如果 Pod 的创建时间不同,最近创建的 Pod 优先于早前创建的 Pod 被裁减。
555+
(当 `LogarithmicScaleDown` 这一
556+
[特性门控](/zh/docs/reference/command-line-tools-reference/feature-gates/)
557+
被启用时,创建时间是按整数幂级来分组的)。
558+
559+
如果以上比较结果都相同,则随机选择。
560+
561+
<!--
562+
### Pod deletion cost
563+
-->
564+
### Pod 删除开销 {#pod-deletion-cost}
565+
566+
{{< feature-state for_k8s_version="v1.21" state="alpha" >}}
567+
568+
<!--
569+
Using the [`controller.kubernetes.io/pod-deletion-cost`](/docs/reference/labels-annotations-taints/#pod-deletion-cost)
570+
annotation, users can set a preference regarding which pods to remove first when downscaling a ReplicaSet.
571+
-->
572+
通过使用 [`controller.kubernetes.io/pod-deletion-cost`](/zh/docs/reference/labels-annotations-taints/#pod-deletion-cost)
573+
注解,用户可以对 ReplicaSet 缩容时要先删除哪些 Pods 设置偏好。
574+
575+
<!--
576+
The annotation should be set on the pod, the range is [-2147483647, 2147483647]. It represents the cost of
577+
deleting a pod compared to other pods belonging to the same ReplicaSet. Pods with lower deletion
578+
cost are preferred to be deleted before pods with higher deletion cost.
579+
-->
580+
此注解要设置到 Pod 上,取值范围为 [-2147483647, 2147483647]。
581+
所代表的的是删除同一 ReplicaSet 中其他 Pod 相比较而言的开销。
582+
删除开销较小的 Pods 比删除开销较高的 Pods 更容易被删除。
583+
584+
<!--
585+
The implicit value for this annotation for pods that don't set it is 0; negative values are permitted.
586+
Invalid values will be rejected by the API server.
587+
-->
588+
Pods 如果未设置此注解,则隐含的设置值为 0。负值也是可接受的。
589+
如果注解值非法,API 服务器会拒绝对应的 Pod。
590+
591+
<!--
592+
This feature is alpha and disabled by default. You can enable it by setting the
593+
[feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
594+
`PodDeletionCost` in both kube-apiserver and kube-controller-manager.
595+
-->
596+
此功能特性处于 Alpha 阶段,默认被禁用。你可以通过为 kube-apiserver 和
597+
kube-controller-manager 设置
598+
[特性门控](/zh/docs/reference/command-line-tools-reference/feature-gates/)
599+
`PodDeletionCost` 来启用此功能。
600+
601+
{{< note >}}
602+
<!--
603+
- This is honored on a best-effort basis, so it does not offer any guarantees on pod deletion order.
604+
- Users should avoid updating the annotation frequently, such as updating it based on a metric value,
605+
because doing so will generate a significant number of pod updates on the apiserver.
606+
-->
607+
- 此机制实施时仅是尽力而为,并不能对 Pod 的删除顺序作出任何保证;
608+
- 用户应避免频繁更新注解值,例如根据某观测度量值来更新此注解值是应该避免的。
609+
这样做会在 API 服务器上产生大量的 Pod 更新操作。
610+
{{< /note >}}
611+
612+
<!--
613+
#### Example Use Case
614+
615+
The different pods of an application could have different utilization levels. On scale down, the application
616+
may prefer to remove the pods with lower utilization. To avoid frequently updating the pods, the application
617+
should update `controller.kubernetes.io/pod-deletion-cost` once before issuing a scale down (setting the
618+
annotation to a value proportional to pod utilization level). This works if the application itself controls
619+
the down scaling; for example, the driver pod of a Spark deployment.
620+
-->
621+
#### 使用场景示例
622+
623+
同一应用的不同 Pods 可能其利用率是不同的。在对应用执行缩容操作时,可能
624+
希望移除利用率较低的 Pods。为了避免频繁更新 Pods,应用应该在执行缩容
625+
操作之前更新一次 `controller.kubernetes.io/pod-deletion-cost` 注解值
626+
(将注解值设置为一个与其 Pod 利用率对应的值)。
627+
如果应用自身控制器缩容操作时(例如 Spark 部署的驱动 Pod),这种机制
628+
是可以起作用的。
629+
534630
<!--
535631
### ReplicaSet as an Horizontal Pod Autoscaler Target
536632

0 commit comments

Comments
 (0)