Skip to content

Commit 1c8f1b4

Browse files
committed
[zh-cn] Improve workloads/controllers/replicaset.md
1 parent 4d808c9 commit 1c8f1b4

File tree

1 file changed

+39
-43
lines changed

1 file changed

+39
-43
lines changed

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

Lines changed: 39 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ template.
3838
ReplicaSet 是通过一组字段来定义的,包括一个用来识别可获得的 Pod
3939
的集合的选择算符、一个用来标明应该维护的副本个数的数值、一个用来指定应该创建新 Pod
4040
以满足副本个数条件时要使用的 Pod 模板等等。
41-
每个 ReplicaSet 都通过根据需要创建和 删除 Pod 以使得副本个数达到期望值,
41+
每个 ReplicaSet 都通过根据需要创建和删除 Pod 以使得副本个数达到期望值,
4242
进而实现其存在价值。当 ReplicaSet 需要创建新的 Pod 时,会使用所提供的 Pod 模板。
4343

4444
<!--
@@ -60,9 +60,8 @@ OwnerReference is not a {{< glossary_tooltip term_id="controller" >}} and it mat
6060
ReplicaSet.
6161
-->
6262
ReplicaSet 使用其选择算符来辨识要获得的 Pod 集合。如果某个 Pod 没有
63-
OwnerReference 或者其 OwnerReference 不是一个
64-
{{< glossary_tooltip text="控制器" term_id="controller" >}},且其匹配到
65-
某 ReplicaSet 的选择算符,则该 Pod 立即被此 ReplicaSet 获得。
63+
OwnerReference 或者其 OwnerReference 不是一个{{< glossary_tooltip text="控制器" term_id="controller" >}},
64+
且其匹配到某 ReplicaSet 的选择算符,则该 Pod 立即被此 ReplicaSet 获得。
6665

6766
<!--
6867
## When to use a ReplicaSet
@@ -81,8 +80,8 @@ use a Deployment instead, and define your application in the spec section.
8180
ReplicaSet 确保任何时间都有指定数量的 Pod 副本在运行。
8281
然而,Deployment 是一个更高级的概念,它管理 ReplicaSet,并向 Pod
8382
提供声明式的更新以及许多其他有用的功能。
84-
因此,我们建议使用 Deployment 而不是直接使用 ReplicaSet,除非
85-
你需要自定义更新业务流程或根本不需要更新
83+
因此,我们建议使用 Deployment 而不是直接使用 ReplicaSet,
84+
除非你需要自定义更新业务流程或根本不需要更新
8685

8786
这实际上意味着,你可能永远不需要操作 ReplicaSet 对象:而是使用
8887
Deployment,并在 spec 部分定义你的应用。
@@ -169,7 +168,7 @@ Events:
169168
<!--
170169
And lastly you can check for the Pods brought up:
171170
-->
172-
最后可以查看启动了的 Pods
171+
最后可以查看启动了的 Pod 集合
173172

174173
```shell
175174
kubectl get pods
@@ -191,8 +190,8 @@ frontend-wtsmm 1/1 Running 0 6m36s
191190
You can also verify that the owner reference of these pods is set to the frontend ReplicaSet.
192191
To do this, get the yaml of one of the Pods running:
193192
-->
194-
你也可以查看 Pods 的属主引用被设置为前端的 ReplicaSet。
195-
要实现这点,可取回运行中的 Pods 之一的 YAML:
193+
你也可以查看 Pod 的属主引用被设置为前端的 ReplicaSet。
194+
要实现这点,可取回运行中的某个 Pod 的 YAML:
196195

197196
```shell
198197
kubectl get pods frontend-b2zdv -o yaml
@@ -268,7 +267,7 @@ Fetching the Pods:
268267
新的 Pod 会被该 ReplicaSet 获取,并立即被 ReplicaSet 终止,
269268
因为它们的存在会使得 ReplicaSet 中 Pod 个数超出其期望值。
270269

271-
取回 Pods
270+
取回 Pod
272271

273272

274273
```shell
@@ -292,7 +291,7 @@ pod2 0/1 Terminating 0 1s
292291
<!--
293292
If you create the Pods first:
294293
-->
295-
如果你先行创建 Pods
294+
如果你先行创建 Pod
296295

297296
```shell
298297
kubectl apply -f https://kubernetes.io/examples/pods/pod-rs.yaml
@@ -334,7 +333,7 @@ pod2 1/1 Running 0 36s
334333
<!--
335334
In this manner, a ReplicaSet can own a non-homogenous set of Pods
336335
-->
337-
采用这种方式,一个 ReplicaSet 中可以包含异质的 Pods 集合。
336+
采用这种方式,一个 ReplicaSet 中可以包含异质的 Pod 集合。
338337

339338
<!--
340339
## Writing a ReplicaSet manifest
@@ -350,7 +349,7 @@ A ReplicaSet also needs a [`.spec` section](https://git.k8s.io/community/contrib
350349
## 编写 ReplicaSet 的清单 {#writing-a-replicaset-manifest}
351350

352351
与所有其他 Kubernetes API 对象一样,ReplicaSet 也需要 `apiVersion``kind`、和 `metadata` 字段。
353-
对于 ReplicaSets 而言,其 `kind` 始终是 ReplicaSet。
352+
对于 ReplicaSet 而言,其 `kind` 始终是 ReplicaSet。
354353

355354
ReplicaSet 对象的名称必须是合法的
356355
[DNS 子域名](/zh-cn/docs/concepts/overview/working-with-objects/names#dns-subdomain-names)
@@ -369,9 +368,9 @@ Be careful not to overlap with the selectors of other controllers, lest they try
369368
For the template's [restart policy](/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy) field,
370369
`.spec.template.spec.restartPolicy`, the only allowed value is `Always`, which is the default.
371370
-->
372-
### Pod 模版 {#pod-template}
371+
### Pod 模板 {#pod-template}
373372

374-
`.spec.template` 是一个 [Pod 模版](/zh-cn/docs/concepts/workloads/pods/#pod-templates)
373+
`.spec.template` 是一个 [Pod 模板](/zh-cn/docs/concepts/workloads/pods/#pod-templates)
375374
要求设置标签。在 `frontend.yaml` 示例中,我们指定了标签 `tier: frontend`
376375
注意不要将标签与其他控制器的选择算符重叠,否则那些控制器会尝试收养此 Pod。
377376

@@ -396,7 +395,7 @@ be rejected by the API.
396395
### Pod 选择算符 {#pod-selector}
397396

398397
`.spec.selector` 字段是一个[标签选择算符](/zh-cn/docs/concepts/overview/working-with-objects/labels/)
399-
如前文中[所讨论的](#how-a-replicaset-works),这些是用来标识要被获取的 Pods
398+
如前文中[所讨论的](#how-a-replicaset-works),这些是用来标识要被获取的 Pod
400399
的标签。在签名的 `frontend.yaml` 示例中,选择算符为:
401400

402401
```yaml
@@ -413,7 +412,7 @@ For 2 ReplicaSets specifying the same `.spec.selector` but different `.spec.temp
413412
-->
414413
对于设置了相同的 `.spec.selector`,但
415414
`.spec.template.metadata.labels` 和 `.spec.template.spec` 字段不同的两个
416-
ReplicaSet 而言,每个 ReplicaSet 都会忽略被另一个 ReplicaSet 所创建的 Pods
415+
ReplicaSet 而言,每个 ReplicaSet 都会忽略被另一个 ReplicaSet 所创建的 Pod
417416
{{< /note >}}
418417

419418
<!--
@@ -427,7 +426,7 @@ If you do not specify `.spec.replicas`, then it defaults to 1.
427426
### Replicas
428427

429428
你可以通过设置 `.spec.replicas` 来指定要同时运行的 Pod 个数。
430-
ReplicaSet 创建、删除 Pods 以与此值匹配。
429+
ReplicaSet 创建、删除 Pod 以与此值匹配。
431430

432431
如果你没有指定 `.spec.replicas`,那么默认值为 1。
433432

@@ -442,7 +441,7 @@ When using the REST API or the `client-go` library, you must set `propagationPol
442441
the -d option.
443442
For example:
444443
-->
445-
## 使用 ReplicaSets {#working-with-replicasets}
444+
## 使用 ReplicaSet {#working-with-replicasets}
446445

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

@@ -470,7 +469,7 @@ For example:
470469
-->
471470
### 只删除 ReplicaSet {#deleting-just-a-replicaset}
472471

473-
你可以只删除 ReplicaSet 而不影响它的 Pods,方法是使用
472+
你可以只删除 ReplicaSet 而不影响它的各个 Pod,方法是使用
474473
[`kubectl delete`](/docs/reference/generated/kubectl/kubectl-commands#delete)
475474
命令并设置 `--cascade=orphan` 选项。
476475

@@ -517,17 +516,17 @@ assuming that the number of replicas is not also changed).
517516
A ReplicaSet can be easily scaled up or down by simply updating the `.spec.replicas` field. The ReplicaSet controller
518517
ensures that a desired number of Pods with a matching label selector are available and operational.
519518
-->
520-
### 缩放 RepliaSet {#scaling-a-replicaset}
519+
### 扩缩 RepliaSet {#scaling-a-replicaset}
521520

522-
通过更新 `.spec.replicas` 字段,ReplicaSet 可以被轻松的进行缩放。ReplicaSet
521+
通过更新 `.spec.replicas` 字段,ReplicaSet 可以被轻松地进行扩缩。ReplicaSet
523522
控制器能确保匹配标签选择器的数量的 Pod 是可用的和可操作的。
524523

525524
<!--
526525
When scaling down, the ReplicaSet controller chooses which pods to delete by sorting the available pods to
527526
prioritize scaling down pods based on the following general algorithm:
528527
-->
529-
在降低集合规模时,ReplicaSet 控制器通过对可用的 Pods 进行排序来优先选择
530-
要被删除的 Pods。其一般性算法如下:
528+
在降低集合规模时,ReplicaSet 控制器通过对可用的所有 Pod 进行排序来优先选择要被删除的那些 Pod。
529+
其一般性算法如下:
531530

532531
<!--
533532
1. Pending (and unschedulable) pods are scaled down first
@@ -538,9 +537,8 @@ prioritize scaling down pods based on the following general algorithm:
538537
comes before the older pod (the creation times are bucketed on an integer log scale
539538
when the `LogarithmicScaleDown` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/) is enabled)
540539
-->
541-
1. 首先选择剔除悬决(Pending,且不可调度)的 Pods
542-
2. 如果设置了 `controller.kubernetes.io/pod-deletion-cost` 注解,则注解值
543-
较小的优先被裁减掉
540+
1. 首先选择剔除悬决(Pending,且不可调度)的各个 Pod
541+
2. 如果设置了 `controller.kubernetes.io/pod-deletion-cost` 注解,则注解值较小的优先被裁减掉
544542
3. 所处节点上副本个数较多的 Pod 优先于所处节点上副本较少者
545543
4. 如果 Pod 的创建时间不同,最近创建的 Pod 优先于早前创建的 Pod 被裁减。
546544
(当 `LogarithmicScaleDown` 这一[特性门控](/zh-cn/docs/reference/command-line-tools-reference/feature-gates/)
@@ -560,22 +558,22 @@ Using the [`controller.kubernetes.io/pod-deletion-cost`](/docs/reference/labels-
560558
annotation, users can set a preference regarding which pods to remove first when downscaling a ReplicaSet.
561559
-->
562560
通过使用 [`controller.kubernetes.io/pod-deletion-cost`](/zh-cn/docs/reference/labels-annotations-taints/#pod-deletion-cost)
563-
注解,用户可以对 ReplicaSet 缩容时要先删除哪些 Pods 设置偏好。
561+
注解,用户可以对 ReplicaSet 缩容时要先删除哪些 Pod 设置偏好。
564562

565563
<!--
566564
The annotation should be set on the pod, the range is [-2147483647, 2147483647]. It represents the cost of
567565
deleting a pod compared to other pods belonging to the same ReplicaSet. Pods with lower deletion
568566
cost are preferred to be deleted before pods with higher deletion cost.
569567
-->
570568
此注解要设置到 Pod 上,取值范围为 [-2147483647, 2147483647]。
571-
所代表的的是删除同一 ReplicaSet 中其他 Pod 相比较而言的开销。
572-
删除开销较小的 Pods 比删除开销较高的 Pods 更容易被删除。
569+
所代表的是删除同一 ReplicaSet 中其他 Pod 相比较而言的开销。
570+
删除开销较小的 Pod 比删除开销较高的 Pod 更容易被删除。
573571

574572
<!--
575573
The implicit value for this annotation for pods that don't set it is 0; negative values are permitted.
576574
Invalid values will be rejected by the API server.
577575
-->
578-
Pods 如果未设置此注解,则隐含的设置值为 0。负值也是可接受的。
576+
Pod 如果未设置此注解,则隐含的设置值为 0。负值也是可接受的。
579577
如果注解值非法,API 服务器会拒绝对应的 Pod。
580578

581579
<!--
@@ -609,12 +607,11 @@ the down scaling; for example, the driver pod of a Spark deployment.
609607
-->
610608
#### 使用场景示例 {#example-use-case}
611609

612-
同一应用的不同 Pods 可能其利用率是不同的。在对应用执行缩容操作时,可能
613-
希望移除利用率较低的 Pods。为了避免频繁更新 Pods,应用应该在执行缩容
614-
操作之前更新一次 `controller.kubernetes.io/pod-deletion-cost` 注解值
610+
同一应用的不同 Pod 可能其利用率是不同的。在对应用执行缩容操作时,
611+
可能希望移除利用率较低的 Pod。为了避免频繁更新 Pod,应用应该在执行缩容操作之前更新一次
612+
`controller.kubernetes.io/pod-deletion-cost` 注解值
615613
(将注解值设置为一个与其 Pod 利用率对应的值)。
616-
如果应用自身控制器缩容操作时(例如 Spark 部署的驱动 Pod),这种机制
617-
是可以起作用的。
614+
如果应用自身控制器缩容操作时(例如 Spark 部署的驱动 Pod),这种机制是可以起作用的。
618615

619616
<!--
620617
### ReplicaSet as a Horizontal Pod Autoscaler Target
@@ -624,10 +621,10 @@ A ReplicaSet can also be a target for
624621
a ReplicaSet can be auto-scaled by an HPA. Here is an example HPA targeting
625622
the ReplicaSet we created in the previous example.
626623
-->
627-
### ReplicaSet 作为水平的 Pod 自动缩放器目标 {#replicaset-as-a-horizontal-pod-autoscaler-target}
624+
### ReplicaSet 作为水平的 Pod 自动扩缩器目标 {#replicaset-as-a-horizontal-pod-autoscaler-target}
628625

629-
ReplicaSet 也可以作为[水平的 Pod 缩放器 (HPA)](/zh-cn/docs/tasks/run-application/horizontal-pod-autoscale/)
630-
的目标。也就是说,ReplicaSet 可以被 HPA 自动缩放
626+
ReplicaSet 也可以作为[水平的 Pod 扩缩器 (HPA)](/zh-cn/docs/tasks/run-application/horizontal-pod-autoscale/)
627+
的目标。也就是说,ReplicaSet 可以被 HPA 自动扩缩
631628
以下是 HPA 以我们在前一个示例中创建的副本集为目标的示例。
632629

633630
{{< codenew file="controllers/hpa-rs.yaml" >}}
@@ -638,7 +635,7 @@ create the defined HPA that autoscales the target ReplicaSet depending on the CP
638635
of the replicated Pods.
639636
-->
640637
将这个列表保存到 `hpa-rs.yaml` 并提交到 Kubernetes 集群,就能创建它所定义的
641-
HPA,进而就能根据复制的 Pod 的 CPU 利用率对目标 ReplicaSet进行自动缩放
638+
HPA,进而就能根据复制的 Pod 的 CPU 利用率对目标 ReplicaSet 进行自动扩缩
642639

643640
```shell
644641
kubectl apply -f https://k8s.io/examples/controllers/hpa-rs.yaml
@@ -648,7 +645,7 @@ kubectl apply -f https://k8s.io/examples/controllers/hpa-rs.yaml
648645
Alternatively, you can use the `kubectl autoscale` command to accomplish the same
649646
(and it's easier!)
650647
-->
651-
或者,可以使用 `kubectl autoscale` 命令完成相同的操作(而且它更简单!)
648+
或者,可以使用 `kubectl autoscale` 命令完成相同的操作(而且它更简单!)
652649

653650
```shell
654651
kubectl autoscale rs frontend --max=10 --min=3 --cpu-percent=50
@@ -671,7 +668,7 @@ As such, it is recommended to use Deployments when you want ReplicaSets.
671668
### Deployment(推荐) {#deployment-recommended}
672669

673670
[`Deployment`](/zh-cn/docs/concepts/workloads/controllers/deployment/) 是一个可以拥有
674-
ReplicaSet 并使用声明式方式在服务器端完成对 Pods 滚动更新的对象。
671+
ReplicaSet 并使用声明式方式在服务器端完成对 Pod 滚动更新的对象。
675672
尽管 ReplicaSet 可以独立使用,目前它们的主要用途是提供给 Deployment 作为编排
676673
Pod 创建、删除和更新的一种机制。当使用 Deployment 时,你不必关心如何管理它所创建的
677674
ReplicaSet,Deployment 拥有并管理其 ReplicaSet。
@@ -754,4 +751,3 @@ ReplicaSet 是 [ReplicationController](/zh-cn/docs/concepts/workloads/controller
754751
对象定义理解关于该资源的 API。
755752
* 阅读 [Pod 干扰预算(Disruption Budget)](/zh-cn/docs/concepts/workloads/pods/disruptions/),
756753
了解如何在干扰下运行高度可用的应用。
757-

0 commit comments

Comments
 (0)