Skip to content

Commit 6cbbcfc

Browse files
authored
Merge pull request #53245 from my-git9/npe-1056
[zh-cn]sync deployment statefulset
2 parents e76991d + ba118d3 commit 6cbbcfc

File tree

2 files changed

+55
-45
lines changed

2 files changed

+55
-45
lines changed

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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ Kubernetes 在计算 `availableReplicas` 数值时不考虑终止过程中的 Po
610610
611611
Each time a new Deployment is observed by the Deployment controller, a ReplicaSet is created to bring up
612612
the desired Pods. If the Deployment is updated, the existing ReplicaSet that controls Pods whose labels
613-
match `.spec.selector` but whose template does not match `.spec.template` are scaled down. Eventually, the new
613+
match `.spec.selector` but whose template does not match `.spec.template` is scaled down. Eventually, the new
614614
ReplicaSet is scaled to `.spec.replicas` and all old ReplicaSets is scaled to 0.
615615
-->
616616
### 翻转(多 Deployment 动态更新) {#rollover-aka-multiple-updates-in-flight}
@@ -894,9 +894,9 @@ Follow the steps given below to check the rollout history:
894894
```
895895
deployments "nginx-deployment"
896896
REVISION CHANGE-CAUSE
897-
1 kubectl apply --filename=https://k8s.io/examples/controllers/nginx-deployment.yaml
898-
2 kubectl set image deployment/nginx-deployment nginx=nginx:1.16.1
899-
3 kubectl set image deployment/nginx-deployment nginx=nginx:1.161
897+
1 <none>
898+
2 <none>
899+
3 <none>
900900
```
901901

902902
<!--
@@ -908,10 +908,20 @@ Follow the steps given below to check the rollout history:
908908
<!--
909909
* Annotating the Deployment with `kubectl annotate deployment/nginx-deployment kubernetes.io/change-cause="image updated to 1.16.1"`
910910
* Manually editing the manifest of the resource.
911+
* Using tooling that sets the annotation automatically.
911912
-->
912913
* 使用 `kubectl annotate deployment/nginx-deployment kubernetes.io/change-cause="image updated to 1.16.1"`
913914
为 Deployment 添加注解。
914915
* 手动编辑资源的清单。
916+
* 使用可自动设置注解的工具。
917+
918+
{{< note >}}
919+
<!--
920+
In older versions of Kubernetes, you could use the `--record` flag with kubectl commands to automatically populate the `CHANGE-CAUSE` field. This flag is deprecated and will be removed in a future release.
921+
-->
922+
在 Kubernetes 旧版本中,可以使用 kubectl 命令的 `--record` 标志自动填充 `CHANGE-CAUSE` 字段。
923+
此标志已弃用,并将在未来的版本中移除。
924+
{{< /note >}}
915925

916926
<!--
917927
2. To see the details of each revision, run:
@@ -931,7 +941,6 @@ Follow the steps given below to check the rollout history:
931941
deployments "nginx-deployment" revision 2
932942
Labels: app=nginx
933943
pod-template-hash=1159050644
934-
Annotations: kubernetes.io/change-cause=kubectl set image deployment/nginx-deployment nginx=nginx:1.16.1
935944
Containers:
936945
nginx:
937946
Image: nginx:1.16.1
@@ -1039,7 +1048,6 @@ Follow the steps given below to rollback the Deployment from the current version
10391048
CreationTimestamp: Sun, 02 Sep 2018 18:17:55 -0500
10401049
Labels: app=nginx
10411050
Annotations: deployment.kubernetes.io/revision=4
1042-
kubernetes.io/change-cause=kubectl set image deployment/nginx-deployment nginx=nginx:1.16.1
10431051
Selector: app=nginx
10441052
Replicas: 3 desired | 3 updated | 3 total | 3 available | 0 unavailable
10451053
StrategyType: RollingUpdate

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

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ StatefulSet 是用来管理有状态应用的工作负载 API 对象。
4545
## Using StatefulSets
4646
4747
StatefulSets are valuable for applications that require one or more of the
48-
following.
48+
following:
4949
-->
5050
## 使用 StatefulSet {#using-statefulsets}
5151

52-
StatefulSet 对于需要满足以下一个或多个需求的应用程序很有价值
52+
StatefulSet 对于需要满足以下一个或多个需求的应用程序很有价值
5353

5454
<!--
5555
* Stable, unique network identifiers.
@@ -84,7 +84,7 @@ that provides a set of stateless replicas.
8484

8585
<!--
8686
* The storage for a given Pod must either be provisioned by a
87-
[PersistentVolume Provisioner](/docs/concepts/storage/dynamic-provisioning/) ([examples here](https://github.com/kubernetes/examples/tree/master/staging/persistent-volume-provisioning/README.md))
87+
[PersistentVolume Provisioner](/docs/concepts/storage/dynamic-provisioning/)
8888
based on the requested _storage class_, or pre-provisioned by an admin.
8989
* Deleting and/or scaling a StatefulSet down will *not* delete the volumes associated with the
9090
StatefulSet. This is done to ensure data safety, which is generally more valuable than an
@@ -102,7 +102,6 @@ that provides a set of stateless replicas.
102102
-->
103103
* 给定 Pod 的存储必须由
104104
[PersistentVolume Provisioner](/zh-cn/docs/concepts/storage/dynamic-provisioning/)
105-
[例子在这里](https://github.com/kubernetes/examples/tree/master/staging/persistent-volume-provisioning/README.md)
106105
基于所请求的 **storage class** 来制备,或者由管理员预先制备。
107106
* 删除或者扩缩 StatefulSet 并**不会**删除它关联的存储卷。
108107
这样做是为了保证数据安全,它通常比自动清除 StatefulSet 所有相关的资源更有价值。
@@ -277,22 +276,22 @@ validation error during StatefulSet creation.
277276
### Volume Claim Templates
278277

279278
You can set the `.spec.volumeClaimTemplates` field to create a
280-
[PersistentVolumeClaim](/docs/concepts/storage/persistent-volumes/).
279+
[PersistentVolumeClaim](/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims)).
281280
This will provide stable storage to the StatefulSet if either
282281
-->
283282
### 卷申领模板 {#volume-claim-templates}
284283

285284
你可以设置 `.spec.volumeClaimTemplates` 字段来创建
286-
[PersistentVolumeClaim](/zh-cn/docs/concepts/storage/persistent-volumes/)。
285+
[PersistentVolumeClaim](/zh-cn/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims)。
287286
这将为 StatefulSet 提供稳定的存储,如果:
288287

289288
<!--
290289
* The StorageClass specified for the volume claim is set up to use [dynamic
291-
provisioning](/docs/concepts/storage/dynamic-provisioning/), or
290+
provisioning](/docs/concepts/storage/dynamic-provisioning/)
292291
* The cluster already contains a PersistentVolume with the correct StorageClass
293292
and sufficient available storage space.
294293
-->
295-
* 为卷申领指定的 StorageClass 配置使用[动态制备](/zh-cn/docs/concepts/storage/dynamic-provisioning/),或
294+
* 为卷申领指定的 StorageClass 配置使用[动态制备](/zh-cn/docs/concepts/storage/dynamic-provisioning/)
296295
* 集群已包含具有正确 StorageClass 和足够可用存储空间的 PersistentVolume。
297296

298297
<!--
@@ -516,7 +515,7 @@ feature, in order to disable it, users will have to use server emulated version
516515

517516
* 对于包含 N 个 副本的 StatefulSet,当部署 Pod 时,它们是依次创建的,顺序为 {0..N-1}。
518517
* 当删除 Pod 时,它们是逆序终止的,顺序为 {N-1..0}。
519-
* 在将扩缩操作应用到 Pod 之前,它前面的所有 Pod 必须是 Running 和 Ready 状态。
518+
* 在将扩缩操作应用到 Pod 之前,它前面的所有 Pod 必须是 `Running``Ready` 状态。
520519
* 在一个 Pod 终止之前,所有的继任者必须完全关闭。
521520

522521
<!--
@@ -537,11 +536,11 @@ web-2 is launched, web-2 will not be launched until web-0 is successfully relaun
537536
becomes Running and Ready.
538537
-->
539538
在上面的 nginx 示例被创建后,会按照 web-0、web-1、web-2 的顺序部署三个 Pod。
540-
在 web-0 进入 [Running 和 Ready](/zh-cn/docs/concepts/workloads/pods/pod-lifecycle/)
541-
状态前不会部署 web-1。在 web-1 进入 Running 和 Ready 状态前不会部署 web-2。
542-
如果 web-1 已经处于 Running 和 Ready 状态,而 web-2 尚未部署,在此期间发生了
543-
web-0 运行失败,那么 web-2 将不会被部署,要等到 web-0 部署完成并进入 Running 和
544-
Ready 状态后,才会部署 web-2。
539+
在 web-0 进入 [`Running``Ready`](/zh-cn/docs/concepts/workloads/pods/pod-lifecycle/)
540+
状态前不会部署 web-1。在 web-1 进入 `Running``Ready` 状态前不会部署 web-2。
541+
如果 web-1 已经处于 `Running``Ready` 状态,而 web-2 尚未部署,在此期间发生了
542+
web-0 运行失败,那么 web-2 将不会被部署,要等到 web-0 部署完成并进入 `Running`
543+
`Ready` 状态后,才会部署 web-2。
545544

546545
<!--
547546
If a user were to scale the deployed example by patching the StatefulSet such that
@@ -553,7 +552,7 @@ until web-0 is Running and Ready.
553552
如果用户想将示例中的 StatefulSet 扩缩为 `replicas=1`,首先被终止的是 web-2。
554553
在 web-2 没有被完全停止和删除前,web-1 不会被终止。
555554
当 web-2 已被终止和删除、web-1 尚未被终止,如果在此期间发生 web-0 运行失败,
556-
那么就不会终止 web-1,必须等到 web-0 进入 Running 和 Ready 状态后才会终止 web-1。
555+
那么就不会终止 web-1,必须等到 web-0 进入 `Running``Ready` 状态后才会终止 web-1。
557556

558557
<!--
559558
### Pod Management Policies
@@ -570,12 +569,12 @@ StatefulSet 允许你放宽其排序保证,
570569
#### OrderedReady Pod Management
571570

572571
`OrderedReady` pod management is the default for StatefulSets. It implements the behavior
573-
described [above](#deployment-and-scaling-guarantees).
572+
described in [Deployment and Scaling Guarantees](#deployment-and-scaling-guarantees).
574573
-->
575574
#### OrderedReady Pod 管理 {#orderedready-pod-management}
576575

577576
`OrderedReady` Pod 管理是 StatefulSet 的默认设置。
578-
它实现了[上面](#deployment-and-scaling-guarantees)描述的功能
577+
它实现了[部署和扩缩保证](#deployment-and-scaling-guarantees)。
579578

580579
<!--
581580
#### Parallel Pod Management
@@ -643,7 +642,7 @@ amount of time after the Pod turns ready, before moving on.
643642
StatefulSet 控制器会删除和重建 StatefulSet 中的每个 Pod。
644643
它将按照与 Pod 终止相同的顺序(从最大序号到最小序号)进行,每次更新一个 Pod。
645644

646-
Kubernetes 控制平面会等到被更新的 Pod 进入 Running 和 Ready 状态,然后再更新其前身。
645+
Kubernetes 控制平面会等到被更新的 Pod 进入 `Running``Ready` 状态,然后再更新其前身。
647646
如果你设置了 `.spec.minReadySeconds`(查看[最短就绪秒数](#minimum-ready-seconds)),
648647
控制平面在 Pod 就绪后会额外等待一定的时间再执行下一步。
649648

@@ -723,7 +722,7 @@ StatefulSet will stop the rollout and wait.
723722
-->
724723
### 强制回滚 {#forced-rollback}
725724

726-
在默认 [Pod 管理策略](#pod-management-policies)(`OrderedReady`) 下使用[滚动更新](#rolling-updates),
725+
在默认 [Pod 管理策略](#pod-management-policies)`OrderedReady`下使用[滚动更新](#rolling-updates),
727726
可能进入需要人工干预才能修复的损坏状态。
728727

729728
如果更新后 Pod 模板配置进入无法运行或就绪的状态(例如,
@@ -756,7 +755,8 @@ StatefulSets use ControllerRevisions to maintain a revision history, enabling ro
756755
-->
757756
## 修订版本历史 {#revision-history}
758757

759-
ControllerRevision 是 Kubernetes 的一种 API 资源,由控制器(例如 StatefulSet 控制器)使用,用于跟踪配置变更历史。
758+
ControllerRevision 是 Kubernetes 的一种 API 资源,由控制器(例如 StatefulSet 控制器)使用,
759+
用于跟踪配置变更历史。
760760

761761
StatefulSet 使用 ControllerRevision 来维护修订版本历史,从而支持回滚和版本跟踪。
762762

@@ -771,7 +771,7 @@ When you update a StatefulSet's Pod template (`spec.template`), the StatefulSet
771771
-->
772772
### StatefulSet 如何通过 ControllerRevision 跟踪变更
773773

774-
当你更新 StatefulSet 的 Pod 模板 (`spec.template`) 时,StatefulSet 控制器:
774+
当你更新 StatefulSet 的 Pod 模板`spec.template`时,StatefulSet 控制器:
775775

776776
1. 准备新的 ControllerRevision 对象
777777
2. 存储 Pod 模板和元数据的快照
@@ -780,12 +780,12 @@ When you update a StatefulSet's Pod template (`spec.template`), the StatefulSet
780780
<!--
781781
#### Key Properties
782782

783-
ControllerRevision key properties and other details can be checked [here](/docs/reference/kubernetes-api/workload-resources/controller-revision-v1/)
783+
See [ControllerRevision](/docs/reference/kubernetes-api/workload-resources/controller-revision-v1/) to learn more about key properties and other details.
784784
-->
785785
#### 关键属性
786786

787-
ControllerRevision 的关键属性和其他细节,
788-
请查阅[这里](/zh-cn/docs/reference/kubernetes-api/workload-resources/controller-revision-v1/)。
787+
有关关键属性和其他细节,请参阅
788+
[ControllerRevision](/zh-cn/docs/reference/kubernetes-api/workload-resources/controller-revision-v1/)。
789789

790790
---
791791

@@ -892,16 +892,16 @@ kubectl get controllerrevision/webapp-3 -o yaml
892892

893893
##### Retention Policy
894894

895-
- Set `revisionHistoryLimit` between **5–10** for most workloads
896-
- Increase only if **deep rollback history** is required
895+
- Set `revisionHistoryLimit` between **5–10** for most workloads.
896+
- Increase only if **deep rollback history** is required.
897897
-->
898898
#### 最佳实践
899899

900900
##### 保留策略
901901

902-
- 对大多数工作负载,将 `revisionHistoryLimit` 设置为 **5–10**
902+
- 对大多数工作负载,将 `revisionHistoryLimit` 设置为 **5–10**
903903

904-
- 仅在需要**深度回滚历史**时才增加
904+
- 仅在需要**深度回滚历史**时才增加
905905

906906
<!--
907907
##### Monitoring
@@ -917,21 +917,21 @@ kubectl get controllerrevision/webapp-3 -o yaml
917917
```
918918

919919
<!--
920-
- Alert on **rapid revision count growth**
920+
- Alert on **rapid revision count growth**.
921921

922922
##### Avoid
923923

924924
- Manual edits to ControllerRevision objects.
925925
- Using revisions as a backup mechanism (use actual backup tools).
926926
- Setting `revisionHistoryLimit: 0` (disables rollback capability).
927927
-->
928-
- 针对**修订版本数量快速增长**发出告警
928+
- 针对**修订版本数量快速增长**发出告警
929929

930930
##### 避免
931931

932932
- 手动编辑 ControllerRevision 对象。
933933
- 将修订版本用作备份机制(使用实际的备份工具)。
934-
- 设置 revisionHistoryLimit: 0(禁用回滚功能)。
934+
- 设置 `revisionHistoryLimit: 0`(禁用回滚功能)。
935935

936936
<!--
937937
## PersistentVolumeClaim retention
@@ -955,10 +955,10 @@ Once enabled, there are two policies you can configure for each StatefulSet:
955955

956956
<!--
957957
`whenDeleted`
958-
: configures the volume retention behavior that applies when the StatefulSet is deleted
958+
: Configures the volume retention behavior that applies when the StatefulSet is deleted.
959959

960960
`whenScaled`
961-
: configures the volume retention behavior that applies when the replica count of
961+
: Configures the volume retention behavior that applies when the replica count of
962962
the StatefulSet is reduced; for example, when scaling down the set.
963963

964964
For each policy that you can configure, you can set the value to either `Delete` or `Retain`.
@@ -1001,7 +1001,7 @@ the node where the new Pod is about to launch.
10011001

10021002
The default for policies is `Retain`, matching the StatefulSet behavior before this new feature.
10031003

1004-
Here is an example policy.
1004+
Here is an example policy:
10051005
-->
10061006
请记住,这些策略**仅**适用于由于 StatefulSet 被删除或被缩小而被删除的 Pod。
10071007
例如,如果与 StatefulSet 关联的 Pod 由于节点故障而失败,
@@ -1010,7 +1010,7 @@ Here is an example policy.
10101010

10111011
策略的默认值为 `Retain`,与此新功能之前的 StatefulSet 行为相匹配。
10121012

1013-
这是一个示例策略
1013+
这是一个示例策略
10141014

10151015
```yaml
10161016
apiVersion: apps/v1
@@ -1101,7 +1101,8 @@ the `.spec.replicas` field automatically.
11011101
如果 [HorizontalPodAutoscaler](/zh-cn/docs/tasks/run-application/horizontal-pod-autoscale/)
11021102
(或任何类似的水平扩缩 API)正在管理 StatefulSet 的扩缩,
11031103
请不要设置 `.spec.replicas`。
1104-
相反,允许 Kubernetes {{<glossary_tooltip text="控制平面" term_id="control-plane" >}}自动管理 `.spec.replicas` 字段。
1104+
相反,允许 Kubernetes {{<glossary_tooltip text="控制平面" term_id="control-plane" >}}自动管理
1105+
`.spec.replicas` 字段。
11051106

11061107
## {{% heading "whatsnext" %}}
11071108

@@ -1127,10 +1128,11 @@ the `.spec.replicas` field automatically.
11271128
* 跟随示例[使用 StatefulSet 部署 Cassandra](/zh-cn/docs/tutorials/stateful-application/cassandra/)。
11281129
* 跟随示例[运行多副本的有状态应用程序](/zh-cn/docs/tasks/run-application/run-replicated-stateful-application/)。
11291130
* 了解如何[扩缩 StatefulSet](/zh-cn/docs/tasks/run-application/scale-stateful-set/)。
1130-
* 了解[删除 StatefulSet](/zh-cn/docs/tasks/run-application/delete-stateful-set/)涉及到的操作。
1131+
* 了解[删除 StatefulSet](/zh-cn/docs/tasks/run-application/delete-stateful-set/) 涉及到的操作。
11311132
* 了解如何[配置 Pod 以使用卷进行存储](/zh-cn/docs/tasks/configure-pod-container/configure-volume-storage/)。
11321133
* 了解如何[配置 Pod 以使用 PersistentVolume 作为存储](/zh-cn/docs/tasks/configure-pod-container/configure-persistent-volume-storage/)。
11331134
* `StatefulSet` 是 Kubernetes REST API 中的顶级资源。阅读 {{< api-reference page="workload-resources/stateful-set-v1" >}}
1134-
对象定义理解关于该资源的 API。
1135-
* 阅读 [Pod 干扰预算(Disruption Budget)](/zh-cn/docs/concepts/workloads/pods/disruptions/),了解如何在干扰下运行高度可用的应用。
1135+
对象定义理解关于该资源的 API。
1136+
* 阅读 [Pod 干扰预算(Disruption Budget)](/zh-cn/docs/concepts/workloads/pods/disruptions/),
1137+
了解如何在干扰下运行高度可用的应用。
11361138

0 commit comments

Comments
 (0)