Skip to content

Commit b4866b2

Browse files
authored
Merge pull request #49683 from my-git9/np-28508
[zh-cn]sync addons basic-stateful-set
2 parents 76f3618 + 2142e2e commit b4866b2

File tree

2 files changed

+93
-10
lines changed

2 files changed

+93
-10
lines changed

content/zh-cn/docs/concepts/cluster-administration/addons.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,13 @@ Add-on 扩展了 Kubernetes 的功能。
168168
## Service Discovery
169169
170170
* [CoreDNS](https://coredns.io) is a flexible, extensible DNS server which can
171-
be [installed](https://github.com/coredns/deployment/tree/master/kubernetes)
171+
be [installed](https://github.com/coredns/helm)
172172
as the in-cluster DNS for pods.
173173
-->
174174
## 服务发现 {#service-discovery}
175175

176176
* [CoreDNS](https://coredns.io) 是一种灵活的,可扩展的 DNS 服务器,可以
177-
[安装](https://github.com/coredns/deployment/tree/master/kubernetes)为集群内的 Pod 提供 DNS 服务。
177+
[安装](https://github.com/coredns/helm)为集群内的 Pod 提供 DNS 服务。
178178

179179
<!--
180180
## Visualization &amp; Control

content/zh-cn/docs/tutorials/stateful-application/basic-stateful-set.md

Lines changed: 91 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,11 @@ of the StatefulSet's Pods.
146146
来{{< glossary_tooltip text="监视" term_id="watch" >}} StatefulSet 的 Pod 的创建情况。
147147

148148
<!--
149+
```shell
149150
# use this terminal to run commands that specify --watch
150151
# end this watch when you are asked to start a new watch
152+
kubectl get pods --watch -l app=nginx
153+
```
151154
-->
152155
```shell
153156
# 使用此终端运行指定 --watch 的命令
@@ -175,7 +178,7 @@ statefulset.apps/web created
175178
The command above creates two Pods, each running an
176179
[NGINX](https://www.nginx.com) webserver. Get the `nginx` Service...
177180
-->
178-
上面的命令创建了两个 Pod,每个都运行了一个 [NginX](https://www.nginx.com) Web 服务器。
181+
上面的命令创建了两个 Pod,每个都运行了一个 [NGINX](https://www.nginx.com) Web 服务器。
179182
获取 `nginx` Service:
180183

181184
```shell
@@ -219,8 +222,11 @@ look like the example below.
219222
在第一个终端中使用 `kubectl get` 检查输出。这个输出最终将看起来像下面的样子。
220223

221224
<!--
225+
```shell
222226
# Do not start a new watch;
223227
# this should already be running
228+
kubectl get pods --watch -l app=nginx
229+
```
224230
-->
225231
```shell
226232
# 不要开始一个新的 watch
@@ -392,8 +398,11 @@ In one terminal, watch the StatefulSet's Pods:
392398
在一个终端中监视 StatefulSet 的 Pod:
393399

394400
<!--
401+
```shell
395402
# Start a new watch
396403
# End this watch when you've seen that the delete is finished
404+
kubectl get pod --watch -l app=nginx
405+
```
397406
-->
398407
```shell
399408
# 启动一个新的 watch
@@ -425,7 +434,10 @@ Running and Ready:
425434
等待 StatefulSet 重启它们,并且两个 Pod 都变成 Running 和 Ready 状态:
426435

427436
<!--
437+
```shell
428438
# This should already be running
439+
kubectl get pod --watch -l app=nginx
440+
```
429441
-->
430442
```shell
431443
# 这应该已经处于 Running 状态
@@ -472,6 +484,12 @@ In that new shell, run:
472484
-->
473485
这将启动一个新的 Shell。在新 Shell 中,运行:
474486

487+
<!--
488+
```shell
489+
# Run this in the dns-test container shell
490+
nslookup web-0.nginx
491+
```
492+
-->
475493
```shell
476494
# 在 dns-test 容器 Shell 中运行以下命令
477495
nslookup web-0.nginx
@@ -659,8 +677,12 @@ In a second terminal, delete all of the StatefulSet's Pods:
659677
在另一个终端删除 StatefulSet 所有的 Pod:
660678

661679
<!--
680+
```shell
662681
# End this watch when you've reached the end of the section.
663682
# At the start of "Scaling a StatefulSet" you'll start a new watch.
683+
kubectl get pod --watch -l app=nginx
684+
```
685+
-->
664686
-->
665687
```shell
666688
# 当你到达该部分的末尾时结束此 watch
@@ -679,7 +701,10 @@ for all of the Pods to transition to Running and Ready.
679701
在第一个终端里检查 `kubectl get` 命令的输出,等待所有 Pod 变成 Running 和 Ready 状态。
680702

681703
<!--
704+
```shell
682705
# This should already be running
706+
kubectl get pod --watch -l app=nginx
707+
```
683708
-->
684709
```shell
685710
# 这应该已经处于 Running 状态
@@ -734,7 +759,8 @@ This is accomplished by updating the `replicas` field. You can use either
734759
-->
735760
扩容/缩容 StatefulSet 指增加或减少它的副本数。这通过更新 `replicas` 字段完成(水平缩放)。
736761
你可以使用 [`kubectl scale`](/docs/reference/generated/kubectl/kubectl-commands/#scale)
737-
或者 [`kubectl patch`](/docs/reference/generated/kubectl/kubectl-commands/#patch) 来扩容/缩容一个 StatefulSet。
762+
或者 [`kubectl patch`](/docs/reference/generated/kubectl/kubectl-commands/#patch)
763+
来扩容/缩容一个 StatefulSet。
738764

739765
<!--
740766
### Scaling up
@@ -755,9 +781,12 @@ In one terminal window, watch the Pods in the StatefulSet:
755781
在一个终端窗口监视 StatefulSet 的 Pod:
756782

757783
<!--
784+
```shell
758785
# If you already have a watch running, you can continue using that.
759786
# Otherwise, start one.
760787
# End this watch when there are 5 healthy Pods for the StatefulSet
788+
kubectl get pods --watch -l app=nginx
789+
```
761790
-->
762791
```shell
763792
# 如果你已经有一个正在运行的 wach,你可以继续使用它。
@@ -786,7 +815,10 @@ for the three additional Pods to transition to Running and Ready.
786815
在第一个 终端中检查 `kubectl get` 命令的输出,等待增加的 3 个 Pod 的状态变为 Running 和 Ready。
787816

788817
<!--
818+
```shell
789819
# This should already be running
820+
kubectl get pod --watch -l app=nginx
821+
```
790822
-->
791823
```shell
792824
# 这应该已经处于 Running 状态
@@ -841,7 +873,11 @@ In one terminal, watch the StatefulSet's Pods:
841873
在一个终端监视 StatefulSet 的 Pod:
842874

843875
<!--
876+
```shell
877+
kubectl get pods -w -l app=nginx
844878
# End this watch when there are only 3 Pods for the StatefulSet
879+
kubectl get pod --watch -l app=nginx
880+
```
845881
-->
846882
```shell
847883
kubectl get pods -w -l app=nginx
@@ -868,7 +904,11 @@ Wait for `web-4` and `web-3` to transition to Terminating.
868904
等待 `web-4``web-3` 状态变为 Terminating。
869905

870906
<!--
907+
```shell
908+
kubectl get pods -w -l app=nginx
871909
# This should already be running
910+
kubectl get pods --watch -l app=nginx
911+
```
872912
-->
873913
```shell
874914
kubectl get pods -w -l app=nginx
@@ -973,7 +1013,7 @@ You'll practice that later in this tutorial.
9731013
First, try a simple rolling update.
9741014
-->
9751015
你可以通过指定 `.spec.updateStrategy.rollingUpdate.partition` 将使用 `RollingUpdate`
976-
策略的 StatefulSet 的更新拆分为多个**分区** 。你将在本教程中稍后练习此操作。
1016+
策略的 StatefulSet 的更新拆分为多个**分区**。你将在本教程中稍后练习此操作。
9771017

9781018
首先,尝试一个简单的滚动更新。
9791019

@@ -996,9 +1036,12 @@ In another terminal, watch the Pods in the StatefulSet:
9961036
在另一个终端监控 StatefulSet 中的 Pod:
9971037

9981038
<!--
1039+
```shell
9991040
# End this watch when the rollout is complete
10001041
#
10011042
# If you're not sure, leave it running one more minute
1043+
kubectl get pod -l app=nginx --watch
1044+
```
10021045
-->
10031046
```shell
10041047
# 滚动完成后结束此 watch
@@ -1107,7 +1150,7 @@ You can split updates to a StatefulSet that uses the `RollingUpdate` strategy
11071150
into _partitions_, by specifying `.spec.updateStrategy.rollingUpdate.partition`.
11081151
-->
11091152
你可以通过指定 `.spec.updateStrategy.rollingUpdate.partition` 将使用 `RollingUpdate` 策略的
1110-
StatefulSet 的更新拆分为多个**分区**
1153+
StatefulSet 的更新拆分为多个**分区**
11111154

11121155
<!--
11131156
For more context, you can read [Partitioned rolling updates](/docs/concepts/workloads/controllers/statefulset/#partitions)
@@ -1134,14 +1177,17 @@ First, patch the `web` StatefulSet to add a partition to the `updateStrategy` fi
11341177
`web` StatefulSet 执行 Patch 操作,为 `updateStrategy` 字段添加一个分区:
11351178

11361179
<!--
1180+
```shell
11371181
# The value of "partition" determines which ordinals a change applies to
11381182
# Make sure to use a number bigger than the last ordinal for the
11391183
# StatefulSet
1184+
kubectl patch statefulset web -p '{"spec":{"updateStrategy":{"type":"OnDelete", "rollingUpdate": null}}}'
1185+
```
11401186
-->
11411187
```shell
11421188
# "partition" 的值决定更改适用于哪些序号
11431189
# 确保使用比 StatefulSet 的最后一个序号更大的数字
1144-
kubectl patch statefulset web -p '{"spec":{"updateStrategy":{"type":"RollingUpdate","rollingUpdate":{"partition":3}}}}'
1190+
kubectl patch statefulset web -p '{"spec":{"updateStrategy":{"type":"OnDelete", "rollingUpdate": null}}}'
11451191
```
11461192
```
11471193
statefulset.apps/web patched
@@ -1178,7 +1224,10 @@ Wait for the replacement `web-2` Pod to be Running and Ready:
11781224
等待替代的 Pod 变成 Running 和 Ready。
11791225

11801226
<!--
1227+
```shell
11811228
# End the watch when you see that web-2 is healthy
1229+
kubectl get pod -l app=nginx --watch
1230+
```
11821231
-->
11831232
```shell
11841233
# 当你看到 web-2 运行正常时结束 watch
@@ -1236,8 +1285,11 @@ Patch the StatefulSet to decrement the partition:
12361285
通过 patch 命令修改 StatefulSet 来减少分区:
12371286

12381287
<!--
1288+
```shell
12391289
# The value of "partition" should match the highest existing ordinal for
12401290
# the StatefulSet
1291+
kubectl patch statefulset web -p '{"spec":{"updateStrategy":{"type":"RollingUpdate","rollingUpdate":{"partition":2}}}}'
1292+
```
12411293
-->
12421294
```shell
12431295
# “partition” 的值应与 StatefulSet 现有的最高序号相匹配
@@ -1253,11 +1305,12 @@ a graceful **delete** followed by creating a new Pod once the deletion
12531305
is complete).
12541306
Wait for the new `web-2` Pod to be Running and Ready.
12551307
-->
1256-
控制平面会触发 `web-2` 的替换(先优雅地 **删除** 现有 Pod,然后在删除完成后创建一个新的 Pod)。
1308+
控制平面会触发 `web-2` 的替换(先优雅地**删除**现有 Pod,然后在删除完成后创建一个新的 Pod)。
12571309
等待新的 `web-2` Pod 变成 Running 和 Ready。
12581310

12591311
<!--
12601312
# This should already be running
1313+
kubectl get pod -l app=nginx --watch
12611314
-->
12621315
```shell
12631316
# 这应该已经处于 Running 状态
@@ -1309,7 +1362,10 @@ Wait for the `web-1` Pod to be Running and Ready.
13091362
等待 `web-1` 变成 Running 和 Ready。
13101363

13111364
<!--
1365+
```shell
13121366
# This should already be running
1367+
kubectl get pod -l app=nginx --watch
1368+
```
13131369
-->
13141370
```shell
13151371
# 这应该已经处于 Running 状态
@@ -1393,7 +1449,10 @@ Wait for all of the Pods in the StatefulSet to become Running and Ready.
13931449
等待 StatefulSet 中的所有 Pod 变成 Running 和 Ready。
13941450

13951451
<!--
1452+
```shell
13961453
# This should already be running
1454+
kubectl get pod -l app=nginx --watch
1455+
```
13971456
-->
13981457
```shell
13991458
# 这应该已经处于 Running 状态
@@ -1506,9 +1565,12 @@ In one terminal window, watch the Pods in the StatefulSet.
15061565
在一个终端窗口监视 StatefulSet 中的 Pod。
15071566

15081567
<!--
1568+
```
15091569
# End this watch when there are no Pods for the StatefulSet
1510-
-->
1570+
kubectl get pods --watch -l app=nginx
15111571
```
1572+
-->
1573+
```shell
15121574
# 当 StatefulSet 没有 Pod 时结束此 watch
15131575
kubectl get pods --watch -l app=nginx
15141576
```
@@ -1549,7 +1611,7 @@ web-2 1/1 Running 0 5m
15491611
Even though `web` has been deleted, all of the Pods are still Running and Ready.
15501612
Delete `web-0`:
15511613
-->
1552-
虽然 `web` 已经被删除了,但所有 Pod 仍然处于 Running 和 Ready 状态。
1614+
虽然 `web` 已经被删除了,但所有 Pod 仍然处于 Running 和 Ready 状态。
15531615
删除 `web-0`
15541616

15551617
```shell
@@ -1584,7 +1646,10 @@ In one terminal, watch the StatefulSet's Pods.
15841646
在一个终端监控 StatefulSet 的 Pod。
15851647

15861648
<!--
1649+
```shell
15871650
# Leave this watch running until the next time you start a watch
1651+
kubectl get pods --watch -l app=nginx
1652+
```
15881653
-->
15891654
```shell
15901655
# 让 watch 一直运行到你下次启动 watch 为止
@@ -1620,7 +1685,10 @@ Examine the output of the `kubectl get` command running in the first terminal.
16201685
在第一个终端中运行并检查 `kubectl get` 命令的输出。
16211686

16221687
<!--
1688+
```shell
16231689
# This should already be running
1690+
kubectl get pods --watch -l app=nginx
1691+
```
16241692
-->
16251693
```shell
16261694
# 这应该已经处于 Running 状态
@@ -1719,7 +1787,10 @@ and wait for all of the Pods to transition to Terminating.
17191787
在第一个终端检查 `kubectl get` 命令的输出,并等待所有的 Pod 变成 Terminating 状态。
17201788

17211789
<!--
1790+
```shell
17221791
# This should already be running
1792+
kubectl get pods --watch -l app=nginx
1793+
```
17231794
-->
17241795
```shell
17251796
# 这应该已经处于 Running 状态
@@ -1925,7 +1996,10 @@ In one terminal, watch the Pods in the StatefulSet.
19251996
在一个终端窗口监视 StatefulSet 中的 Pod。
19261997

19271998
<!--
1999+
```shell
19282000
# Leave this watch running until the end of the section
2001+
kubectl get pod -l app=nginx --watch
2002+
```
19292003
-->
19302004
```shell
19312005
# 让 watch 一直运行直到本节结束
@@ -2003,18 +2077,27 @@ part of cleanup.
20032077
-->
20042078
你应该打开两个终端,准备在清理过程中运行 `kubectl` 命令。
20052079

2080+
<!--
20062081
```shell
20072082
kubectl delete sts web
20082083
# sts is an abbreviation for statefulset
20092084
```
2085+
-->
2086+
```shell
2087+
kubectl delete sts web
2088+
# sts 是 statefulset 的缩写
2089+
```
20102090

20112091
<!--
20122092
You can watch `kubectl get` to see those Pods being deleted.
20132093
-->
20142094
你可以监视 `kubectl get` 来查看那些 Pod 被删除:
20152095

20162096
<!--
2097+
```shell
20172098
# end the watch when you've seen what you need to
2099+
kubectl get pod -l app=nginx --watch
2100+
```
20182101
-->
20192102
```shell
20202103
# 当你看到需要的内容后结束 watch

0 commit comments

Comments
 (0)