@@ -38,7 +38,7 @@ template.
38
38
ReplicaSet 是通过一组字段来定义的,包括一个用来识别可获得的 Pod
39
39
的集合的选择算符、一个用来标明应该维护的副本个数的数值、一个用来指定应该创建新 Pod
40
40
以满足副本个数条件时要使用的 Pod 模板等等。
41
- 每个 ReplicaSet 都通过根据需要创建和 删除 Pod 以使得副本个数达到期望值,
41
+ 每个 ReplicaSet 都通过根据需要创建和删除 Pod 以使得副本个数达到期望值,
42
42
进而实现其存在价值。当 ReplicaSet 需要创建新的 Pod 时,会使用所提供的 Pod 模板。
43
43
44
44
<!--
@@ -60,9 +60,8 @@ OwnerReference is not a {{< glossary_tooltip term_id="controller" >}} and it mat
60
60
ReplicaSet.
61
61
-->
62
62
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 获得。
66
65
67
66
<!--
68
67
## When to use a ReplicaSet
@@ -81,8 +80,8 @@ use a Deployment instead, and define your application in the spec section.
81
80
ReplicaSet 确保任何时间都有指定数量的 Pod 副本在运行。
82
81
然而,Deployment 是一个更高级的概念,它管理 ReplicaSet,并向 Pod
83
82
提供声明式的更新以及许多其他有用的功能。
84
- 因此,我们建议使用 Deployment 而不是直接使用 ReplicaSet,除非
85
- 你需要自定义更新业务流程或根本不需要更新 。
83
+ 因此,我们建议使用 Deployment 而不是直接使用 ReplicaSet,
84
+ 除非你需要自定义更新业务流程或根本不需要更新 。
86
85
87
86
这实际上意味着,你可能永远不需要操作 ReplicaSet 对象:而是使用
88
87
Deployment,并在 spec 部分定义你的应用。
@@ -169,7 +168,7 @@ Events:
169
168
<!--
170
169
And lastly you can check for the Pods brought up:
171
170
-->
172
- 最后可以查看启动了的 Pods :
171
+ 最后可以查看启动了的 Pod 集合 :
173
172
174
173
``` shell
175
174
kubectl get pods
@@ -191,8 +190,8 @@ frontend-wtsmm 1/1 Running 0 6m36s
191
190
You can also verify that the owner reference of these pods is set to the frontend ReplicaSet.
192
191
To do this, get the yaml of one of the Pods running:
193
192
-->
194
- 你也可以查看 Pods 的属主引用被设置为前端的 ReplicaSet。
195
- 要实现这点,可取回运行中的 Pods 之一的 YAML:
193
+ 你也可以查看 Pod 的属主引用被设置为前端的 ReplicaSet。
194
+ 要实现这点,可取回运行中的某个 Pod 的 YAML:
196
195
197
196
``` shell
198
197
kubectl get pods frontend-b2zdv -o yaml
@@ -268,7 +267,7 @@ Fetching the Pods:
268
267
新的 Pod 会被该 ReplicaSet 获取,并立即被 ReplicaSet 终止,
269
268
因为它们的存在会使得 ReplicaSet 中 Pod 个数超出其期望值。
270
269
271
- 取回 Pods :
270
+ 取回 Pod :
272
271
273
272
274
273
``` shell
@@ -292,7 +291,7 @@ pod2 0/1 Terminating 0 1s
292
291
<!--
293
292
If you create the Pods first:
294
293
-->
295
- 如果你先行创建 Pods :
294
+ 如果你先行创建 Pod :
296
295
297
296
``` shell
298
297
kubectl apply -f https://kubernetes.io/examples/pods/pod-rs.yaml
@@ -334,7 +333,7 @@ pod2 1/1 Running 0 36s
334
333
<!--
335
334
In this manner, a ReplicaSet can own a non-homogenous set of Pods
336
335
-->
337
- 采用这种方式,一个 ReplicaSet 中可以包含异质的 Pods 集合。
336
+ 采用这种方式,一个 ReplicaSet 中可以包含异质的 Pod 集合。
338
337
339
338
<!--
340
339
## Writing a ReplicaSet manifest
@@ -350,7 +349,7 @@ A ReplicaSet also needs a [`.spec` section](https://git.k8s.io/community/contrib
350
349
## 编写 ReplicaSet 的清单 {#writing-a-replicaset-manifest}
351
350
352
351
与所有其他 Kubernetes API 对象一样,ReplicaSet 也需要 ` apiVersion ` 、` kind ` 、和 ` metadata ` 字段。
353
- 对于 ReplicaSets 而言,其 ` kind ` 始终是 ReplicaSet。
352
+ 对于 ReplicaSet 而言,其 ` kind ` 始终是 ReplicaSet。
354
353
355
354
ReplicaSet 对象的名称必须是合法的
356
355
[ 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
369
368
For the template's [restart policy](/docs/concepts/workloads/pods/pod-lifecycle/#restart-policy) field,
370
369
`.spec.template.spec.restartPolicy`, the only allowed value is `Always`, which is the default.
371
370
-->
372
- ### Pod 模版 {#pod-template}
371
+ ### Pod 模板 {#pod-template}
373
372
374
- ` .spec.template ` 是一个 [ Pod 模版 ] ( /zh-cn/docs/concepts/workloads/pods/#pod-templates ) ,
373
+ ` .spec.template ` 是一个 [ Pod 模板 ] ( /zh-cn/docs/concepts/workloads/pods/#pod-templates ) ,
375
374
要求设置标签。在 ` frontend.yaml ` 示例中,我们指定了标签 ` tier: frontend ` 。
376
375
注意不要将标签与其他控制器的选择算符重叠,否则那些控制器会尝试收养此 Pod。
377
376
@@ -396,7 +395,7 @@ be rejected by the API.
396
395
### Pod 选择算符 {#pod-selector}
397
396
398
397
` .spec.selector ` 字段是一个[ 标签选择算符] ( /zh-cn/docs/concepts/overview/working-with-objects/labels/ ) 。
399
- 如前文中[ 所讨论的] ( #how-a-replicaset-works ) ,这些是用来标识要被获取的 Pods
398
+ 如前文中[ 所讨论的] ( #how-a-replicaset-works ) ,这些是用来标识要被获取的 Pod
400
399
的标签。在签名的 ` frontend.yaml ` 示例中,选择算符为:
401
400
402
401
``` yaml
@@ -413,7 +412,7 @@ For 2 ReplicaSets specifying the same `.spec.selector` but different `.spec.temp
413
412
-->
414
413
对于设置了相同的 `.spec.selector`,但
415
414
` .spec.template.metadata.labels` 和 `.spec.template.spec` 字段不同的两个
416
- ReplicaSet 而言,每个 ReplicaSet 都会忽略被另一个 ReplicaSet 所创建的 Pods 。
415
+ ReplicaSet 而言,每个 ReplicaSet 都会忽略被另一个 ReplicaSet 所创建的 Pod 。
417
416
{{< /note >}}
418
417
419
418
<!--
@@ -427,7 +426,7 @@ If you do not specify `.spec.replicas`, then it defaults to 1.
427
426
# ## Replicas
428
427
429
428
你可以通过设置 `.spec.replicas` 来指定要同时运行的 Pod 个数。
430
- ReplicaSet 创建、删除 Pods 以与此值匹配。
429
+ ReplicaSet 创建、删除 Pod 以与此值匹配。
431
430
432
431
如果你没有指定 `.spec.replicas`,那么默认值为 1。
433
432
@@ -442,7 +441,7 @@ When using the REST API or the `client-go` library, you must set `propagationPol
442
441
the -d option.
443
442
For example :
444
443
-->
445
- # # 使用 ReplicaSets {#working-with-replicasets}
444
+ # # 使用 ReplicaSet {#working-with-replicasets}
446
445
447
446
# ## 删除 ReplicaSet 和它的 Pod {#deleting-a-replicaset-and-its-pods}
448
447
@@ -470,7 +469,7 @@ For example:
470
469
-->
471
470
# ## 只删除 ReplicaSet {#deleting-just-a-replicaset}
472
471
473
- 你可以只删除 ReplicaSet 而不影响它的 Pods ,方法是使用
472
+ 你可以只删除 ReplicaSet 而不影响它的各个 Pod ,方法是使用
474
473
[`kubectl delete`](/docs/reference/generated/kubectl/kubectl-commands#delete)
475
474
命令并设置 `--cascade=orphan` 选项。
476
475
@@ -517,17 +516,17 @@ assuming that the number of replicas is not also changed).
517
516
A ReplicaSet can be easily scaled up or down by simply updating the `.spec.replicas` field. The ReplicaSet controller
518
517
ensures that a desired number of Pods with a matching label selector are available and operational.
519
518
-->
520
- # ## 缩放 RepliaSet {#scaling-a-replicaset}
519
+ # ## 扩缩 RepliaSet {#scaling-a-replicaset}
521
520
522
- 通过更新 `.spec.replicas` 字段,ReplicaSet 可以被轻松的进行缩放 。ReplicaSet
521
+ 通过更新 `.spec.replicas` 字段,ReplicaSet 可以被轻松地进行扩缩 。ReplicaSet
523
522
控制器能确保匹配标签选择器的数量的 Pod 是可用的和可操作的。
524
523
525
524
<!--
526
525
When scaling down, the ReplicaSet controller chooses which pods to delete by sorting the available pods to
527
526
prioritize scaling down pods based on the following general algorithm :
528
527
-->
529
- 在降低集合规模时,ReplicaSet 控制器通过对可用的 Pods 进行排序来优先选择
530
- 要被删除的 Pods。 其一般性算法如下:
528
+ 在降低集合规模时,ReplicaSet 控制器通过对可用的所有 Pod 进行排序来优先选择要被删除的那些 Pod。
529
+ 其一般性算法如下:
531
530
532
531
<!--
533
532
1. Pending (and unschedulable) pods are scaled down first
@@ -538,9 +537,8 @@ prioritize scaling down pods based on the following general algorithm:
538
537
comes before the older pod (the creation times are bucketed on an integer log scale
539
538
when the `LogarithmicScaleDown` [feature gate](/docs/reference/command-line-tools-reference/feature-gates/) is enabled)
540
539
-->
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` 注解,则注解值较小的优先被裁减掉
544
542
3. 所处节点上副本个数较多的 Pod 优先于所处节点上副本较少者
545
543
4. 如果 Pod 的创建时间不同,最近创建的 Pod 优先于早前创建的 Pod 被裁减。
546
544
(当 `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-
560
558
annotation, users can set a preference regarding which pods to remove first when downscaling a ReplicaSet.
561
559
-->
562
560
通过使用 [`controller.kubernetes.io/pod-deletion-cost`](/zh-cn/docs/reference/labels-annotations-taints/#pod-deletion-cost)
563
- 注解,用户可以对 ReplicaSet 缩容时要先删除哪些 Pods 设置偏好。
561
+ 注解,用户可以对 ReplicaSet 缩容时要先删除哪些 Pod 设置偏好。
564
562
565
563
<!--
566
564
The annotation should be set on the pod, the range is [-2147483647, 2147483647]. It represents the cost of
567
565
deleting a pod compared to other pods belonging to the same ReplicaSet. Pods with lower deletion
568
566
cost are preferred to be deleted before pods with higher deletion cost.
569
567
-->
570
568
此注解要设置到 Pod 上,取值范围为 [-2147483647, 2147483647]。
571
- 所代表的的是删除同一 ReplicaSet 中其他 Pod 相比较而言的开销。
572
- 删除开销较小的 Pods 比删除开销较高的 Pods 更容易被删除。
569
+ 所代表的是删除同一 ReplicaSet 中其他 Pod 相比较而言的开销。
570
+ 删除开销较小的 Pod 比删除开销较高的 Pod 更容易被删除。
573
571
574
572
<!--
575
573
The implicit value for this annotation for pods that don't set it is 0; negative values are permitted.
576
574
Invalid values will be rejected by the API server.
577
575
-->
578
- Pods 如果未设置此注解,则隐含的设置值为 0。负值也是可接受的。
576
+ Pod 如果未设置此注解,则隐含的设置值为 0。负值也是可接受的。
579
577
如果注解值非法,API 服务器会拒绝对应的 Pod。
580
578
581
579
<!--
@@ -609,12 +607,11 @@ the down scaling; for example, the driver pod of a Spark deployment.
609
607
-->
610
608
# ### 使用场景示例 {#example-use-case}
611
609
612
- 同一应用的不同 Pods 可能其利用率是不同的。在对应用执行缩容操作时,可能
613
- 希望移除利用率较低的 Pods 。为了避免频繁更新 Pods,应用应该在执行缩容
614
- 操作之前更新一次 `controller.kubernetes.io/pod-deletion-cost` 注解值
610
+ 同一应用的不同 Pod 可能其利用率是不同的。在对应用执行缩容操作时,
611
+ 可能希望移除利用率较低的 Pod 。为了避免频繁更新 Pod,应用应该在执行缩容操作之前更新一次
612
+ ` controller.kubernetes.io/pod-deletion-cost` 注解值
615
613
(将注解值设置为一个与其 Pod 利用率对应的值)。
616
- 如果应用自身控制器缩容操作时(例如 Spark 部署的驱动 Pod),这种机制
617
- 是可以起作用的。
614
+ 如果应用自身控制器缩容操作时(例如 Spark 部署的驱动 Pod),这种机制是可以起作用的。
618
615
619
616
<!--
620
617
# ## ReplicaSet as a Horizontal Pod Autoscaler Target
@@ -624,10 +621,10 @@ A ReplicaSet can also be a target for
624
621
a ReplicaSet can be auto-scaled by an HPA. Here is an example HPA targeting
625
622
the ReplicaSet we created in the previous example.
626
623
-->
627
- # ## ReplicaSet 作为水平的 Pod 自动缩放器目标 {#replicaset-as-a-horizontal-pod-autoscaler-target}
624
+ # ## ReplicaSet 作为水平的 Pod 自动扩缩器目标 {#replicaset-as-a-horizontal-pod-autoscaler-target}
628
625
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 自动扩缩 。
631
628
以下是 HPA 以我们在前一个示例中创建的副本集为目标的示例。
632
629
633
630
{{< codenew file="controllers/hpa-rs.yaml" >}}
@@ -638,7 +635,7 @@ create the defined HPA that autoscales the target ReplicaSet depending on the CP
638
635
of the replicated Pods.
639
636
-->
640
637
将这个列表保存到 `hpa-rs.yaml` 并提交到 Kubernetes 集群,就能创建它所定义的
641
- HPA,进而就能根据复制的 Pod 的 CPU 利用率对目标 ReplicaSet进行自动缩放 。
638
+ HPA,进而就能根据复制的 Pod 的 CPU 利用率对目标 ReplicaSet 进行自动扩缩 。
642
639
643
640
` ` ` shell
644
641
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
648
645
Alternatively, you can use the `kubectl autoscale` command to accomplish the same
649
646
(and it's easier!)
650
647
-->
651
- 或者,可以使用 `kubectl autoscale` 命令完成相同的操作。 (而且它更简单!)
648
+ 或者,可以使用 `kubectl autoscale` 命令完成相同的操作(而且它更简单!)
652
649
653
650
` ` ` shell
654
651
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.
671
668
# ## Deployment(推荐) {#deployment-recommended}
672
669
673
670
[`Deployment`](/zh-cn/docs/concepts/workloads/controllers/deployment/) 是一个可以拥有
674
- ReplicaSet 并使用声明式方式在服务器端完成对 Pods 滚动更新的对象。
671
+ ReplicaSet 并使用声明式方式在服务器端完成对 Pod 滚动更新的对象。
675
672
尽管 ReplicaSet 可以独立使用,目前它们的主要用途是提供给 Deployment 作为编排
676
673
Pod 创建、删除和更新的一种机制。当使用 Deployment 时,你不必关心如何管理它所创建的
677
674
ReplicaSet,Deployment 拥有并管理其 ReplicaSet。
@@ -754,4 +751,3 @@ ReplicaSet 是 [ReplicationController](/zh-cn/docs/concepts/workloads/controller
754
751
对象定义理解关于该资源的 API。
755
752
* 阅读 [Pod 干扰预算(Disruption Budget)](/zh-cn/docs/concepts/workloads/pods/disruptions/),
756
753
了解如何在干扰下运行高度可用的应用。
757
-
0 commit comments