Skip to content

Commit 58484d9

Browse files
authored
Merge pull request #39799 from Zhuzhenghao/deployment
[zh] sync pages in concepts/workloads/controllers/
2 parents 1290b02 + 48c6be1 commit 58484d9

File tree

2 files changed

+54
-49
lines changed

2 files changed

+54
-49
lines changed

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

Lines changed: 50 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ content_type: concept
88
weight: 10
99
---
1010
<!--
11+
reviewers:
12+
- janetkuo
1113
title: Deployments
1214
feature:
1315
title: Automated rollouts and rollbacks
@@ -80,7 +82,7 @@ The following are typical use cases for Deployments:
8082
* [清理较旧的不再需要的 ReplicaSet](#clean-up-policy)
8183

8284
<!--
83-
## Creating a Deployment
85+
## Creating a Deployment
8486
8587
The following is an example of a Deployment. It creates a ReplicaSet to bring up three `nginx` Pods:
8688
-->
@@ -97,8 +99,8 @@ In this example:
9799

98100
<!--
99101
* A Deployment named `nginx-deployment` is created, indicated by the
100-
`.metadata.name` field. This name will become the basis for the ReplicaSets
101-
and Pods which are created later. See [Writing a Deployment Spec](#writing-a-deployment-spec)
102+
`.metadata.name` field. This name will become the basis for the ReplicaSets
103+
and Pods which are created later. See [Writing a Deployment Spec](#writing-a-deployment-spec)
102104
for more details.
103105
* The Deployment creates a ReplicaSet that creates three replicated Pods, indicated by the `.spec.replicas` field.
104106
* The `.spec.selector` field defines how the created ReplicaSet finds which Pods to manage.
@@ -116,12 +118,12 @@ In this example:
116118

117119
{{< note >}}
118120
<!--
119-
The `spec.selector.matchLabels` field is a map of {key,value} pairs.
121+
The `.spec.selector.matchLabels` field is a map of {key,value} pairs.
120122
A single {key,value} in the `matchLabels` map is equivalent to an element of `matchExpressions`,
121123
whose `key` field is "key", the `operator` is "In", and the `values` array contains only "value".
122124
All of the requirements, from both `matchLabels` and `matchExpressions`, must be satisfied in order to match.
123125
-->
124-
`spec.selector.matchLabels` 字段是 `{key,value}` 键值对映射。
126+
`.spec.selector.matchLabels` 字段是 `{key,value}` 键值对映射。
125127
`matchLabels` 映射中的每个 `{key,value}` 映射等效于 `matchExpressions` 中的一个元素,
126128
即其 `key` 字段是 “key”,`operator` 为 “In”,`values` 数组仅包含 “value”。
127129
`matchLabels``matchExpressions` 中给出的所有条件都必须满足才能匹配。
@@ -158,9 +160,9 @@ Follow the steps given below to create the above Deployment:
158160
```
159161

160162
<!--
161-
2. Run `kubectl get deployments` to check if the Deployment was created.
163+
2. Run `kubectl get deployments` to check if the Deployment was created.
162164
163-
If the Deployment is still being created, the output is similar to the following:
165+
If the Deployment is still being created, the output is similar to the following:
164166
-->
165167
2. 运行 `kubectl get deployments` 检查 Deployment 是否已创建。
166168
如果仍在创建 Deployment,则输出类似于:
@@ -208,7 +210,7 @@ Follow the steps given below to create the above Deployment:
208210
```
209211

210212
<!--
211-
4. Run the `kubectl get deployments` again a few seconds later.
213+
4. Run the `kubectl get deployments` again a few seconds later.
212214
The output is similar to this:
213215
-->
214216
4. 几秒钟后再次运行 `kubectl get deployments`。输出类似于:
@@ -255,7 +257,7 @@ Follow the steps given below to create the above Deployment:
255257

256258
<!--
257259
Notice that the name of the ReplicaSet is always formatted as
258-
`[DEPLOYMENT-NAME]-[HASH]`. This name will become the basis for the Pods
260+
`[DEPLOYMENT-NAME]-[HASH]`. This name will become the basis for the Pods
259261
which are created.
260262
The `HASH` string is the same as the `pod-template-hash` label on the ReplicaSet.
261263
-->
@@ -296,7 +298,7 @@ Kubernetes 不会阻止你这样做,但是如果多个控制器具有重叠的
296298
{{< /note >}}
297299

298300
<!--
299-
### Pod-template-hash label
301+
### Pod-template-hash label
300302
-->
301303
### Pod-template-hash 标签
302304

@@ -323,13 +325,13 @@ and in any existing Pods that the ReplicaSet might have.
323325
可能拥有的任何现有 Pod 中。
324326

325327
<!--
326-
## Updating a Deployment
328+
## Updating a Deployment
327329
-->
328330
## 更新 Deployment {#updating-a-deployment}
329331

330332
{{< note >}}
331333
<!--
332-
A Deployment's rollout is triggered if and only if the Deployment's Pod template (that is, `.spec.template`)
334+
A Deployment's rollout is triggered if and only if the Deployment's Pod template (that is, `.spec.template`)
333335
is changed, for example if the labels or container images of the template are updated. Other updates, such as scaling the Deployment, do not trigger a rollout.
334336
-->
335337
仅当 Deployment Pod 模板(即 `.spec.template`)发生改变时,例如模板的标签或容器镜像被更新,
@@ -353,7 +355,7 @@ Follow the steps given below to update your Deployment:
353355
or use the following command:
354356
-->
355357
或者使用下面的命令:
356-
358+
357359
```shell
358360
kubectl set image deployment/nginx-deployment nginx=nginx:1.16.1
359361
```
@@ -492,7 +494,7 @@ up to 3 replicas, as well as scaling down the old ReplicaSet to 0 replicas.
492494
then deletes an old Pod, and creates another new one. It does not kill old Pods until a sufficient number of
493495
new Pods have come up, and does not create new Pods until a sufficient number of old Pods have been killed.
494496
It makes sure that at least 3 Pods are available and that at max 4 Pods in total are available. In case of
495-
a Deployment with 4 replicas, the number of Pods would be between 3 and 5.
497+
a Deployment with 4 replicas, the number of Pods would be between 3 and 5.
496498
-->
497499
例如,如果仔细查看上述 Deployment ,将看到它首先创建了一个新的 Pod,然后删除旧的 Pod,
498500
并创建了新的 Pod。它不会杀死旧 Pod,直到有足够数量的新 Pod 已经出现。
@@ -559,8 +561,7 @@ up to 3 replicas, as well as scaling down the old ReplicaSet to 0 replicas.
559561
(nginx-deployment-1564180365) and scaled it up to 1 and waited for it to come up. Then it scaled down the old ReplicaSet
560562
to 2 and scaled up the new ReplicaSet to 2 so that at least 3 Pods were available and at most 4 Pods were created at all times.
561563
It then continued scaling up and down the new and the old ReplicaSet, with the same rolling update strategy.
562-
Finally, you'll have 3 available replicas
563-
in the new ReplicaSet, and the old ReplicaSet is scaled down to 0.
564+
Finally, you'll have 3 available replicas in the new ReplicaSet, and the old ReplicaSet is scaled down to 0.
564565
-->
565566
可以看到,当第一次创建 Deployment 时,它创建了一个 ReplicaSet(`nginx-deployment-2035384211`
566567
并将其直接扩容至 3 个副本。更新 Deployment 时,它创建了一个新的 ReplicaSet
@@ -624,7 +625,7 @@ before changing course.
624625
<!--
625626
### Label selector updates
626627
627-
It is generally discouraged to make label selector updates and it is suggested to plan your selectors up front.
628+
It is generally discouraged to make label selector updates and it is suggested to plan your selectors up front.
628629
In any case, if you need to perform a label selector update, exercise great caution and make sure you have grasped
629630
all of the implications.
630631
-->
@@ -665,7 +666,7 @@ removed label still exists in any existing Pods and ReplicaSets.
665666
## 回滚 Deployment {#rolling-back-a-deployment}
666667

667668
<!--
668-
Sometimes, you may want to rollback a Deployment; for example, when the Deployment is not stable, such as crash looping.
669+
Sometimes, you may want to rollback a Deployment; for example, when the Deployment is not stable, such as crash looping.
669670
By default, all of the Deployment's rollout history is kept in the system so that you can rollback anytime you want
670671
(you can change that by modifying revision history limit).
671672
-->
@@ -697,7 +698,7 @@ Deployment 被触发上线时,系统就会创建 Deployment 的新的修订版
697698
`nginx:1.161` 而不是 `nginx:1.16.1`
698699

699700
```shell
700-
kubectl set image deployment/nginx-deployment nginx=nginx:1.161
701+
kubectl set image deployment/nginx-deployment nginx=nginx:1.161
701702
```
702703

703704
<!--
@@ -734,7 +735,7 @@ Deployment 被触发上线时,系统就会创建 Deployment 的新的修订版
734735
* 按 Ctrl-C 停止上述上线状态观测。有关上线停滞的详细信息,[参考这里](#deployment-status)
735736

736737
<!--
737-
* You see that the number of old replicas (`nginx-deployment-1564180365` and `nginx-deployment-2035384211`) is 2, and new replicas (nginx-deployment-3066724191) is 1.
738+
* You see that the number of old replicas (`nginx-deployment-1564180365` and `nginx-deployment-2035384211`) is 2, and new replicas (nginx-deployment-3066724191) is 1.
738739
-->
739740
* 你可以看到旧的副本有两个(`nginx-deployment-1564180365``nginx-deployment-2035384211`),
740741
新的副本有 1 个(`nginx-deployment-3066724191`):
@@ -748,7 +749,7 @@ Deployment 被触发上线时,系统就会创建 Deployment 的新的修订版
748749
-->
749750
输出类似于:
750751

751-
```shell
752+
```
752753
NAME DESIRED CURRENT READY AGE
753754
nginx-deployment-1564180365 3 3 3 25s
754755
nginx-deployment-2035384211 0 0 0 36s
@@ -769,7 +770,7 @@ Deployment 被触发上线时,系统就会创建 Deployment 的新的修订版
769770
-->
770771
输出类似于:
771772

772-
```shell
773+
```
773774
NAME READY STATUS RESTARTS AGE
774775
nginx-deployment-1564180365-70iae 1/1 Running 0 25s
775776
nginx-deployment-1564180365-jbqqo 1/1 Running 0 25s
@@ -828,7 +829,7 @@ Deployment 被触发上线时,系统就会创建 Deployment 的新的修订版
828829
OldReplicaSets: nginx-deployment-1564180365 (3/3 replicas created)
829830
NewReplicaSet: nginx-deployment-3066724191 (1/1 replicas created)
830831
Events:
831-
FirstSeen LastSeen Count From SubobjectPath Type Reason Message
832+
FirstSeen LastSeen Count From SubObjectPath Type Reason Message
832833
--------- -------- ----- ---- ------------- -------- ------ -------
833834
1m 1m 1 {deployment-controller } Normal ScalingReplicaSet Scaled up replica set nginx-deployment-2035384211 to 3
834835
22s 22s 1 {deployment-controller } Normal ScalingReplicaSet Scaled up replica set nginx-deployment-1564180365 to 1
@@ -855,7 +856,7 @@ Follow the steps given below to check the rollout history:
855856
按照如下步骤检查回滚历史:
856857

857858
<!--
858-
1. First, check the revisions of this Deployment:
859+
1. First, check the revisions of this Deployment:
859860
-->
860861
1. 首先,检查 Deployment 修订历史:
861862

@@ -929,7 +930,7 @@ Follow the steps given below to rollback the Deployment from the current version
929930
按照下面给出的步骤将 Deployment 从当前版本回滚到以前的版本(即版本 2)。
930931

931932
<!--
932-
1. Now you've decided to undo the current rollout and rollback to the previous revision:
933+
1. Now you've decided to undo the current rollout and rollback to the previous revision:
933934
-->
934935
1. 假定现在你已决定撤消当前上线并回滚到以前的修订版本:
935936

@@ -1229,7 +1230,7 @@ The output is similar to this:
12291230
-->
12301231
输出类似于:
12311232

1232-
```shell
1233+
```
12331234
NAME DESIRED CURRENT READY AGE
12341235
nginx-deployment-1989198191 7 7 0 7m
12351236
nginx-deployment-618515232 11 11 11 7m
@@ -1307,7 +1308,7 @@ apply multiple fixes in between pausing and resuming without triggering unnecess
13071308
-->
13081309
输出类似于:
13091310

1310-
```shell
1311+
```
13111312
deployment.apps/nginx-deployment paused
13121313
```
13131314

@@ -1363,7 +1364,7 @@ apply multiple fixes in between pausing and resuming without triggering unnecess
13631364
-->
13641365
输出类似于:
13651366

1366-
```shell
1367+
```
13671368
NAME DESIRED CURRENT READY AGE
13681369
nginx-2142116321 3 3 3 2m
13691370
```
@@ -1388,7 +1389,8 @@ apply multiple fixes in between pausing and resuming without triggering unnecess
13881389

13891390
<!--
13901391
The initial state of the Deployment prior to pausing its rollout will continue its function, but new updates to
1391-
the Deployment will not have any effect as long as the Deployment is paused.
1392+
the Deployment will not have any effect as long as the Deployment rollout is paused.
1393+
13921394
-->
13931395
暂停 Deployment 上线之前的初始状态将继续发挥作用,但新的更新在 Deployment
13941396
上线被暂停期间不会产生任何效果。
@@ -1573,7 +1575,7 @@ The output is similar to this:
15731575
-->
15741576
输出类似于:
15751577

1576-
```shell
1578+
```
15771579
Waiting for rollout to finish: 2 of 3 updated replicas are available...
15781580
deployment "nginx-deployment" successfully rolled out
15791581
```
@@ -1584,7 +1586,7 @@ and the exit status from `kubectl rollout` is 0 (success):
15841586
`kubectl rollout` 命令获得的返回状态为 0(成功):
15851587

15861588
```shell
1587-
$ echo $?
1589+
echo $?
15881590
```
15891591
```
15901592
0
@@ -1603,7 +1605,7 @@ due to some of the following factors:
16031605
造成此情况一些可能因素如下:
16041606

16051607
<!--
1606-
* Insufficient quota
1608+
* Insufficient quota
16071609
* Readiness probe failures
16081610
* Image pull errors
16091611
* Insufficient permissions
@@ -1676,7 +1678,7 @@ See the [Kubernetes API conventions](https://git.k8s.io/community/contributors/d
16761678

16771679
{{< note >}}
16781680
<!--
1679-
Kubernetes takes no action on a stalled Deployment other than to report a status condition with
1681+
Kubernetes takes no action on a stalled Deployment other than to report a status condition with
16801682
`reason: ProgressDeadlineExceeded`. Higher level orchestrators can take advantage of it and act accordingly, for
16811683
example, rollback the Deployment to its previous version.
16821684
-->
@@ -1687,8 +1689,8 @@ Deployment 不执行任何操作。更高级别的编排器可以利用这一设
16871689

16881690
{{< note >}}
16891691
<!--
1690-
If you pause a Deployment rollout, Kubernetes does not check progress against your specified deadline.
1691-
You can safely pause a Deployment rollout in the middle of a rollout and resume without triggering
1692+
If you pause a Deployment rollout, Kubernetes does not check progress against your specified deadline.
1693+
You can safely pause a Deployment rollout in the middle of a rollout and resume without triggering
16921694
the condition for exceeding the deadline.
16931695
-->
16941696
如果你暂停了某个 Deployment 上线,Kubernetes 不再根据指定的截止时间检查 Deployment 上线的进展。
@@ -1831,7 +1833,7 @@ and the exit status from `kubectl rollout` is 1 (indicating an error):
18311833
`kubectl rollout` 命令的退出状态为 1(表明发生了错误):
18321834

18331835
```shell
1834-
$ echo $?
1836+
echo $?
18351837
```
18361838
```
18371839
1
@@ -1899,9 +1901,9 @@ configuring containers, and [using kubectl to manage resources](/docs/concepts/o
18991901

19001902
<!--
19011903
When the control plane creates new Pods for a Deployment, the `.metadata.name` of the
1902-
Deployment is part of the basis for naming those Pods. The name of a Deployment must be a valid
1904+
Deployment is part of the basis for naming those Pods. The name of a Deployment must be a valid
19031905
[DNS subdomain](/docs/concepts/overview/working-with-objects/names#dns-subdomain-names)
1904-
value, but this can produce unexpected results for the Pod hostnames. For best compatibility,
1906+
value, but this can produce unexpected results for the Pod hostnames. For best compatibility,
19051907
the name should follow the more restrictive rules for a
19061908
[DNS label](/docs/concepts/overview/working-with-objects/names#dns-label-names).
19071909
@@ -2056,11 +2058,11 @@ All existing Pods are killed before new ones are created when `.spec.strategy.ty
20562058

20572059
{{< note >}}
20582060
<!--
2059-
This will only guarantee Pod termination previous to creation for upgrades. If you upgrade a Deployment, all Pods
2060-
of the old revision will be terminated immediately. Successful removal is awaited before any Pod of the new
2061-
revision is created. If you manually delete a Pod, the lifecycle is controlled by the ReplicaSet and the
2062-
replacement will be created immediately (even if the old Pod is still in a Terminating state). If you need an
2063-
"at most" guarantee for your Pods, you should consider using a
2061+
This will only guarantee Pod termination previous to creation for upgrades. If you upgrade a Deployment, all Pods
2062+
of the old revision will be terminated immediately. Successful removal is awaited before any Pod of the new
2063+
revision is created. If you manually delete a Pod, the lifecycle is controlled by the ReplicaSet and the
2064+
replacement will be created immediately (even if the old Pod is still in a Terminating state). If you need an
2065+
"at most" guarantee for your Pods, you should consider using a
20642066
[StatefulSet](/docs/concepts/workloads/controllers/statefulset/).
20652067
-->
20662068
这只会确保为了升级而创建新 Pod 之前其他 Pod 都已终止。如果你升级一个 Deployment,
@@ -2114,7 +2116,7 @@ at all times during the update is at least 70% of the desired Pods.
21142116
<!--
21152117
##### Max Surge
21162118
2117-
`.spec.strategy.rollingUpdate.maxSurge` is an optional field that specifies the maximum number of Pods
2119+
`.spec.strategy.rollingUpdate.maxSurge` is an optional field that specifies the maximum number of Pods
21182120
that can be created over the desired number of Pods. The value can be an absolute number (for example, 5) or a
21192121
percentage of desired Pods (for example, 10%). The value cannot be 0 if `MaxUnavailable` is 0. The absolute number
21202122
is calculated from the percentage by rounding up. The default value is 25%.
@@ -2137,11 +2139,11 @@ total number of Pods running at any time during the update is at most 130% of de
21372139
同时确保更新期间的任何时候运行中的 Pod 总数最多为所需 Pod 总数的 130%。
21382140

21392141
<!--
2140-
### Progress Deadline Seconds
2142+
### Progress Deadline Seconds
21412143
2142-
`.spec.progressDeadlineSeconds` is an optional field that specifies the number of seconds you want
2144+
`.spec.progressDeadlineSeconds` is an optional field that specifies the number of seconds you want
21432145
to wait for your Deployment to progress before the system reports back that the Deployment has
2144-
[failed progressing](#failed-deployment) - surfaced as a condition with `type: Progressing`, `status: False`.
2146+
[failed progressing](#failed-deployment) - surfaced as a condition with `type: Progressing`, `status: "False"`.
21452147
and `reason: ProgressDeadlineExceeded` in the status of the resource. The Deployment controller will keep
21462148
retrying the Deployment. This defaults to 600. In the future, once automatic rollback will be implemented, the Deployment
21472149
controller will roll back a Deployment as soon as it observes such a condition.
@@ -2162,7 +2164,7 @@ If specified, this field needs to be greater than `.spec.minReadySeconds`.
21622164
<!--
21632165
### Min Ready Seconds
21642166
2165-
`.spec.minReadySeconds` is an optional field that specifies the minimum number of seconds for which a newly
2167+
`.spec.minReadySeconds` is an optional field that specifies the minimum number of seconds for which a newly
21662168
created Pod should be ready without any of its containers crashing, for it to be considered available.
21672169
This defaults to 0 (the Pod will be considered available as soon as it is ready). To learn more about when
21682170
a Pod is considered ready, see [Container Probes](/docs/concepts/workloads/pods/pod-lifecycle/#container-probes).

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,9 @@ prioritize scaling down pods based on the following general algorithm:
574574
(当 `LogarithmicScaleDown` 这一[特性门控](/zh-cn/docs/reference/command-line-tools-reference/feature-gates/)
575575
被启用时,创建时间是按整数幂级来分组的)。
576576

577+
<!--
578+
If all of the above match, then selection is random.
579+
-->
577580
如果以上比较结果都相同,则随机选择。
578581

579582
<!--
@@ -688,7 +691,7 @@ kubectl autoscale rs frontend --max=10 --min=3 --cpu-percent=50
688691

689692
[`Deployment`](/docs/concepts/workloads/controllers/deployment/) is an object which can own ReplicaSets and update
690693
them and their Pods via declarative, server-side rolling updates.
691-
While ReplicaSets can be used independently, today they're mainly used by Deployments as a mechanism to orchestrate Pod
694+
While ReplicaSets can be used independently, today they're mainly used by Deployments as a mechanism to orchestrate Pod
692695
creation, deletion and updates. When you use Deployments you don't have to worry about managing the ReplicaSets that
693696
they create. Deployments own and manage their ReplicaSets.
694697
As such, it is recommended to use Deployments when you want ReplicaSets.

0 commit comments

Comments
 (0)