Skip to content

Commit d53c934

Browse files
committed
[zh-cn] resync: docs/concepts/workloads/controllers/replicaset.md
Signed-off-by: Hu Shuai <[email protected]>
1 parent ccf5bce commit d53c934

File tree

1 file changed

+36
-24
lines changed

1 file changed

+36
-24
lines changed

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

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,22 @@ ReplicaSet 是通过一组字段来定义的,包括一个用来识别可获得
4242
进而实现其存在价值。当 ReplicaSet 需要创建新的 Pod 时,会使用所提供的 Pod 模板。
4343

4444
<!--
45-
A ReplicaSet is linked to its Pods via the Pods' [metadata.ownerReferences](/docs/concepts/workloads/controllers/garbage-collection/#owners-and-dependents)
45+
A ReplicaSet is linked to its Pods via the Pods' [metadata.ownerReferences](/docs/concepts/architecture/garbage-collection/#owners-and-dependents)
4646
field, which specifies what resource the current object is owned by. All Pods acquired by a ReplicaSet have their owning
4747
ReplicaSet's identifying information within their ownerReferences field. It's through this link that the ReplicaSet
4848
knows of the state of the Pods it is maintaining and plans accordingly.
4949
-->
5050
ReplicaSet 通过 Pod 上的
51-
[metadata.ownerReferences](/zh-cn/docs/concepts/workloads/controllers/garbage-collection/#owners-and-dependents)
51+
[metadata.ownerReferences](/zh-cn/docs/concepts/architecture/garbage-collection/#owners-and-dependents)
5252
字段连接到附属 Pod,该字段给出当前对象的属主资源。
5353
ReplicaSet 所获得的 Pod 都在其 ownerReferences 字段中包含了属主 ReplicaSet
5454
的标识信息。正是通过这一连接,ReplicaSet 知道它所维护的 Pod 集合的状态,
5555
并据此计划其操作行为。
5656

5757
<!--
58-
A ReplicaSet identifies new Pods to acquire by using its selector. If there is a Pod that has no OwnerReference or the
59-
OwnerReference is not a {{< glossary_tooltip term_id="controller" >}} and it matches a ReplicaSet's selector, it will be immediately acquired by said
60-
ReplicaSet.
58+
A ReplicaSet identifies new Pods to acquire by using its selector. If there is a Pod that has no
59+
OwnerReference or the OwnerReference is not a {{< glossary_tooltip term_id="controller" >}} and it
60+
matches a ReplicaSet's selector, it will be immediately acquired by said ReplicaSet.
6161
-->
6262
ReplicaSet 使用其选择算符来辨识要获得的 Pod 集合。如果某个 Pod 没有
6363
OwnerReference 或者其 OwnerReference 不是一个{{< glossary_tooltip text="控制器" term_id="controller" >}},
@@ -408,7 +408,9 @@ matchLabels:
408408

409409
{{< note >}}
410410
<!--
411-
For 2 ReplicaSets specifying the same `.spec.selector` but different `.spec.template.metadata.labels` and `.spec.template.spec` fields, each ReplicaSet ignores the Pods created by the other ReplicaSet.
411+
For 2 ReplicaSets specifying the same `.spec.selector` but different
412+
`.spec.template.metadata.labels` and `.spec.template.spec` fields, each ReplicaSet ignores the
413+
Pods created by the other ReplicaSet.
412414
-->
413415
对于设置了相同的 `.spec.selector`,但
414416
`.spec.template.metadata.labels` 和 `.spec.template.spec` 字段不同的两个
@@ -435,19 +437,21 @@ ReplicaSet 创建、删除 Pod 以与此值匹配。
435437

436438
### Deleting a ReplicaSet and its Pods
437439

438-
To delete a ReplicaSet and all of its Pods, use [`kubectl delete`](/docs/reference/generated/kubectl/kubectl-commands#delete). The [Garbage collector](/docs/concepts/workloads/controllers/garbage-collection/) automatically deletes all of the dependent Pods by default.
440+
To delete a ReplicaSet and all of its Pods, use
441+
[`kubectl delete`](/docs/reference/generated/kubectl/kubectl-commands#delete). The
442+
[Garbage collector](/docs/concepts/architecture/garbage-collection/) automatically deletes all of
443+
the dependent Pods by default.
439444

440-
When using the REST API or the `client-go` library, you must set `propagationPolicy` to `Background` or `Foreground` in
441-
the -d option.
442-
For example:
445+
When using the REST API or the `client-go` library, you must set `propagationPolicy` to
446+
`Background` or `Foreground` in the `-d` option. For example:
443447
-->
444448
## 使用 ReplicaSet {#working-with-replicasets}
445449

446450
### 删除 ReplicaSet 和它的 Pod {#deleting-a-replicaset-and-its-pods}
447451

448452
要删除 ReplicaSet 和它的所有 Pod,使用
449453
[`kubectl delete`](/docs/reference/generated/kubectl/kubectl-commands#delete) 命令。
450-
默认情况下,[垃圾收集器](/zh-cn/docs/concepts/workloads/controllers/garbage-collection/)
454+
默认情况下,[垃圾收集器](/zh-cn/docs/concepts/architecture/garbage-collection/)
451455
自动删除所有依赖的 Pod。
452456

453457
当使用 REST API 或 `client-go` 库时,你必须在 `-d` 选项中将 `propagationPolicy`
@@ -463,7 +467,9 @@ curl -X DELETE 'localhost:8080/apis/apps/v1/namespaces/default/replicasets/fron
463467
<!--
464468
### Deleting just a ReplicaSet
465469

466-
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.
470+
You can delete a ReplicaSet without affecting any of its Pods using
471+
[`kubectl delete`](/docs/reference/generated/kubectl/kubectl-commands#delete)
472+
with the `--cascade=orphan` option.
467473
When using the REST API or the `client-go` library, you must set `propagationPolicy` to `Orphan`.
468474
For example:
469475
-->
@@ -488,7 +494,8 @@ Once the original is deleted, you can create a new ReplicaSet to replace it. As
488494
as the old and new `.spec.selector` are the same, then the new one will adopt the old Pods.
489495
However, it will not make any effort to make existing Pods match a new, different pod template.
490496
To update Pods to a new spec in a controlled way, use a
491-
[Deployment](/docs/concepts/workloads/controllers/deployment/#creating-a-deployment), as ReplicaSets do not support a rolling update directly.
497+
[Deployment](/docs/concepts/workloads/controllers/deployment/#creating-a-deployment), as
498+
ReplicaSets do not support a rolling update directly.
492499
-->
493500
一旦删除了原来的 ReplicaSet,就可以创建一个新的来替换它。
494501
由于新旧 ReplicaSet 的 `.spec.selector` 是相同的,新的 ReplicaSet 将接管老的 Pod。
@@ -529,13 +536,13 @@ prioritize scaling down pods based on the following general algorithm:
529536
其一般性算法如下:
530537

531538
<!--
532-
1. Pending (and unschedulable) pods are scaled down first
533-
2. If `controller.kubernetes.io/pod-deletion-cost` annotation is set, then
534-
the pod with the lower value will come first.
535-
3. Pods on nodes with more replicas come before pods on nodes with fewer replicas.
536-
4. If the pods' creation times differ, the pod that was created more recently
537-
comes before the older pod (the creation times are bucketed on an integer log scale
538-
when the `LogarithmicScaleDown` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/) is enabled)
539+
1. Pending (and unschedulable) pods are scaled down first
540+
1. If `controller.kubernetes.io/pod-deletion-cost` annotation is set, then
541+
the pod with the lower value will come first.
542+
1. Pods on nodes with more replicas come before pods on nodes with fewer replicas.
543+
1. If the pods' creation times differ, the pod that was created more recently
544+
comes before the older pod (the creation times are bucketed on an integer log scale
545+
when the `LogarithmicScaleDown` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/) is enabled)
539546
-->
540547
1. 首先选择剔除悬决(Pending,且不可调度)的各个 Pod
541548
2. 如果设置了 `controller.kubernetes.io/pod-deletion-cost` 注解,则注解值较小的优先被裁减掉
@@ -677,7 +684,12 @@ ReplicaSet,Deployment 拥有并管理其 ReplicaSet。
677684
<!--
678685
### Bare Pods
679686

680-
Unlike the case where a user directly created Pods, a ReplicaSet replaces Pods that are deleted or terminated for any reason, such as in the case of node failure or disruptive node maintenance, such as a kernel upgrade. For this reason, we recommend that you use a ReplicaSet even if your application requires only a single Pod. Think of it similarly to a process supervisor, only it supervises multiple Pods across multiple nodes instead of individual processes on a single node. A ReplicaSet delegates local container restarts to some agent on the node such as kubelet.
687+
Unlike the case where a user directly created Pods, a ReplicaSet replaces Pods that are deleted or
688+
terminated for any reason, such as in the case of node failure or disruptive node maintenance,
689+
such as a kernel upgrade. For this reason, we recommend that you use a ReplicaSet even if your
690+
application requires only a single Pod. Think of it similarly to a process supervisor, only it
691+
supervises multiple Pods across multiple nodes instead of individual processes on a single node. A
692+
ReplicaSet delegates local container restarts to some agent on the node such as Kubelet.
681693
-->
682694
### 裸 Pod {#bare-pods}
683695

@@ -691,8 +703,8 @@ ReplicaSet 将本地容器重启的任务委托给了节点上的某个代理(
691703
<!--
692704
### Job
693705

694-
Use a [`Job`](/docs/concepts/workloads/controllers/job/) instead of a ReplicaSet for Pods that are expected to terminate on their own
695-
(that is, batch jobs).
706+
Use a [`Job`](/docs/concepts/workloads/controllers/job/) instead of a ReplicaSet for Pods that are
707+
expected to terminate on their own (that is, batch jobs).
696708
-->
697709
### Job
698710

@@ -718,7 +730,7 @@ safe to terminate when the machine is otherwise ready to be rebooted/shutdown.
718730
### ReplicationController
719731

720732
<!--
721-
ReplicaSets are the successors to [_ReplicationControllers_](/docs/concepts/workloads/controllers/replicationcontroller/).
733+
ReplicaSets are the successors to [ReplicationControllers](/docs/concepts/workloads/controllers/replicationcontroller/).
722734
The two serve the same purpose, and behave similarly, except that a ReplicationController does not support set-based
723735
selector requirements as described in the [labels user guide](/docs/concepts/overview/working-with-objects/labels/#label-selectors).
724736
As such, ReplicaSets are preferred over ReplicationControllers

0 commit comments

Comments
 (0)