Skip to content

Commit db776ac

Browse files
authored
Merge pull request #27761 from tengqm/zh-sync-concepts-7
[zh] Resync concepts section (7)
2 parents 51f154c + 210775f commit db776ac

File tree

5 files changed

+72
-89
lines changed

5 files changed

+72
-89
lines changed

content/zh/docs/concepts/workloads/pods/disruptions.md

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ weight: 60
55
---
66

77
<!--
8+
reviewers:
9+
- erictune
10+
- foxish
11+
- davidopp
812
title: Disruptions
913
content_type: concept
1014
weight: 60
@@ -136,18 +140,18 @@ Here are some ways to mitigate involuntary disruptions:
136140
[stateless](/docs/tasks/run-application/run-stateless-application-deployment/)
137141
and [stateful](/docs/tasks/run-application/run-replicated-stateful-application/) applications.)
138142
- For even higher availability when running replicated applications,
139-
spread applications across racks (using
140-
[anti-affinity](/docs/user-guide/node-selection/#inter-pod-affinity-and-anti-affinity-beta-feature))
141-
or across zones (if using a
142-
[multi-zone cluster](/docs/setup/multiple-zones).)
143+
spread applications across racks (using
144+
[anti-affinity](/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity))
145+
or across zones (if using a
146+
[multi-zone cluster](/docs/setup/multiple-zones).)
143147
-->
144148
- 确保 Pod 在请求中给出[所需资源](/zh/docs/tasks/configure-pod-container/assign-memory-resource/)
145149
- 如果需要更高的可用性,请复制应用程序。
146150
(了解有关运行多副本的[无状态](/zh/docs/tasks/run-application/run-stateless-application-deployment/)
147151
[有状态](/zh/docs/tasks/run-application/run-replicated-stateful-application/)应用程序的信息。)
148152
- 为了在运行复制应用程序时获得更高的可用性,请跨机架(使用
149-
[反亲和性](/zh/docs/concepts/scheduling-eviction/assign-pod-node/))或跨区域
150-
(如果使用[多区域集群](/zh/docs/setup/best-practices/multiple-zones/))扩展应用程序。
153+
[反亲和性](/zh/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity)
154+
或跨区域(如果使用[多区域集群](/zh/docs/setup/best-practices/multiple-zones/))扩展应用程序。
151155

152156
<!--
153157
The frequency of voluntary disruptions varies. On a basic Kubernetes cluster, there are
@@ -186,9 +190,9 @@ number needed for a quorum. A web front end might want to
186190
ensure that the number of replicas serving load never falls below a certain
187191
percentage of the total.
188192
-->
189-
## 干扰预算
193+
## 干扰预算 {#pod-disruption-budgets}
190194

191-
{{< feature-state for_k8s_version="v1.5" state="beta" >}}
195+
{{< feature-state for_k8s_version="v1.21" state="stable" >}}
192196

193197
即使你会经常引入自愿性干扰,Kubernetes 也能够支持你运行高度可用的应用。
194198

@@ -199,11 +203,11 @@ Web 前端可能希望确保提供负载的副本数量永远不会低于总数
199203

200204
<!--
201205
Cluster managers and hosting providers should use tools which
202-
respect Pod Disruption Budgets by calling the [Eviction API](/docs/tasks/administer-cluster/safely-drain-node/#the-eviction-api)
206+
respect PodDisruptionBudgets by calling the [Eviction API](/docs/tasks/administer-cluster/safely-drain-node/#eviction-api)
203207
instead of directly deleting pods or deployments. Examples are the `kubectl drain` command
204208
and the Kubernetes-on-GCE cluster upgrade script (`cluster/gce/upgrade.sh`).
205209
-->
206-
集群管理员和托管提供商应该使用遵循 Pod Disruption Budgets 的接口
210+
集群管理员和托管提供商应该使用遵循 PodDisruptionBudgets 的接口
207211
(通过调用[Eviction API](/zh/docs/tasks/administer-cluster/safely-drain-node/#the-eviction-api)),
208212
而不是直接删除 Pod 或 Deployment。
209213

@@ -264,7 +268,7 @@ during application updates is configured in spec for the specific workload resou
264268
When a pod is evicted using the eviction API, it is gracefully
265269
[terminated](/docs/concepts/workloads/pods/pod-lifecycle/#pod-termination),
266270
hornoring the
267-
`terminationGracePeriodSeconds` setting in its [PodSpec](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#podspec-v1-core).)
271+
`terminationGracePeriodSeconds` setting in its [PodSpec](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#podspec-v1-core).
268272
-->
269273
当使用驱逐 API 驱逐 Pod 时,Pod 会被体面地
270274
[终止](/zh/docs/concepts/workloads/pods/pod-lifecycle/#pod-termination),期间会

content/zh/docs/concepts/workloads/pods/ephemeral-containers.md

Lines changed: 24 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,23 @@ that runs temporarily in an existing {{< glossary_tooltip term_id="pod" >}} to
2020
accomplish user-initiated actions such as troubleshooting. You use ephemeral
2121
containers to inspect services rather than to build applications.
2222
-->
23-
本页面概述了临时容器:一种特殊的容器,该容器在现有 {{< glossary_tooltip text="Pod" term_id="pod" >}}
23+
本页面概述了临时容器:一种特殊的容器,该容器在现有
24+
{{< glossary_tooltip text="Pod" term_id="pod" >}}
2425
中临时运行,以便完成用户发起的操作,例如故障排查。
2526
你会使用临时容器来检查服务,而不是用它来构建应用程序。
2627

28+
{{< warning >}}
2729
<!--
2830
Ephemeral containers are in early alpha state and are not suitable for production
2931
clusters. You should expect the feature not to work in some situations, such as
3032
when targeting the namespaces of a container. In accordance with the [Kubernetes
3133
Deprecation Policy](/docs/reference/using-api/deprecation-policy/), this alpha
3234
feature could change significantly in the future or be removed entirely.
3335
-->
34-
{{< warning >}}
35-
临时容器处于早期的 alpha 阶段,不适用于生产环境集群。
36+
临时容器处于早期的 Alpha 阶段,不适用于生产环境集群。
3637
应该预料到临时容器在某些情况下不起作用,例如在定位容器的命名空间时。
3738
根据 [Kubernetes 弃用政策](/zh/docs/reference/using-api/deprecation-policy/)
38-
alpha 功能将来可能发生重大变化或被完全删除。
39+
Alpha 功能将来可能发生重大变化或被完全删除。
3940
{{< /warning >}}
4041

4142
<!-- body -->
@@ -49,7 +50,7 @@ replaceable, you cannot add a container to a Pod once it has been created.
4950
Instead, you usually delete and replace Pods in a controlled fashion using
5051
{{< glossary_tooltip text="deployments" term_id="deployment" >}}.
5152
-->
52-
## 了解临时容器
53+
## 了解临时容器 {#understanding-ephemeral-containers}
5354

5455
{{< glossary_tooltip text="Pod" term_id="pod" >}} 是 Kubernetes 应用程序的基本构建块。
5556
由于 Pod 是一次性且可替换的,因此一旦 Pod 创建,就无法将容器加入到 Pod 中。
@@ -74,7 +75,7 @@ they are not appropriate for building applications. Ephemeral containers are
7475
described using the same `ContainerSpec` as regular containers, but many fields
7576
are incompatible and disallowed for ephemeral containers.
7677
-->
77-
### 什么是临时容器?
78+
### 什么是临时容器? {#what-is-an-ephemeral-container}
7879

7980
临时容器与其他容器的不同之处在于,它们缺少对资源或执行的保证,并且永远不会自动重启,
8081
因此不适用于构建应用程序。
@@ -89,9 +90,7 @@ are incompatible and disallowed for ephemeral containers.
8990
-->
9091
- 临时容器没有端口配置,因此像 `ports``livenessProbe``readinessProbe`
9192
这样的字段是不允许的。
92-
9393
- Pod 资源分配是不可变的,因此 `resources` 配置是不允许的。
94-
9594
- 有关允许字段的完整列表,请参见
9695
[EphemeralContainer 参考文档](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#ephemeralcontainer-v1-core)。
9796

@@ -116,7 +115,7 @@ Ephemeral containers are useful for interactive troubleshooting when `kubectl
116115
exec` is insufficient because a container has crashed or a container image
117116
doesn't include debugging utilities.
118117
-->
119-
## 临时容器的用途
118+
## 临时容器的用途 {#uses-for-ephemeral-containers}
120119

121120
当由于容器崩溃或容器镜像不包含调试工具而导致 `kubectl exec` 无用时,
122121
临时容器对于交互式故障排查很有用。
@@ -128,7 +127,7 @@ and exposure to bugs and vulnerabilities. Since distroless images do not include
128127
shell or any debugging utilities, it's difficult to troubleshoot distroless
129128
images using `kubectl exec` alone.
130129
-->
131-
尤其是,[distroless 镜像](https://github.com/GoogleContainerTools/distroless)
130+
尤其是,[Distroless 镜像](https://github.com/GoogleContainerTools/distroless)
132131
允许用户部署最小的容器镜像,从而减少攻击面并减少故障和漏洞的暴露。
133132
由于 distroless 镜像不包含 Shell 或任何的调试工具,因此很难单独使用
134133
`kubectl exec` 命令进行故障排查。
@@ -138,19 +137,28 @@ When using ephemeral containers, it's helpful to enable [process namespace
138137
sharing](/docs/tasks/configure-pod-container/share-process-namespace/) so
139138
you can view processes in other containers.
140139
-->
141-
使用临时容器时,启用[进程名字空间共享](/zh/docs/tasks/configure-pod-container/share-process-namespace/)
140+
使用临时容器时,启用
141+
[进程名字空间共享](/zh/docs/tasks/configure-pod-container/share-process-namespace/)
142142
很有帮助,可以查看其他容器中的进程。
143143

144144
<!--
145-
### Examples
145+
See [Debugging with Ephemeral Debug Container](/docs/tasks/debug-application-cluster/debug-running-pod/#ephemeral-container)
146+
for examples of troubleshooting using ephemeral containers.
147+
-->
148+
关于如何使用临时容器来执行故障排查的例子,可参阅
149+
[使用临时调试容器来调试](/zh/docs/tasks/debug-application-cluster/debug-running-pod/#ephemeral-container)
146150

151+
<!--
152+
## Ephemeral containers API
153+
-->
154+
### 临时容器 API {#ephemeral-containers-api}」
155+
156+
{{< note >}}
157+
<!--
147158
The examples in this section require the `EphemeralContainers` [feature
148159
gate](/docs/reference/command-line-tools-reference/feature-gates/) to be
149160
enabled, and Kubernetes client and server version v1.16 or later.
150161
-->
151-
### 示例
152-
153-
{{< note >}}
154162
本节中的示例要求启用 `EphemeralContainers`
155163
[特性门控](/zh/docs/reference/command-line-tools-reference/feature-gates/)
156164
并且 kubernetes 客户端和服务端版本要求为 v1.16 或更高版本。
@@ -180,7 +188,7 @@ the ephemeral container to add as an `EphemeralContainers` list:
180188
"apiVersion": "v1",
181189
"kind": "EphemeralContainers",
182190
"metadata": {
183-
"name": "example-pod"
191+
"name": "example-pod"
184192
},
185193
"ephemeralContainers": [{
186194
"command": [
@@ -281,34 +289,3 @@ You can attach to the new ephemeral container using `kubectl attach`:
281289
kubectl attach -it example-pod -c debugger
282290
```
283291

284-
<!--
285-
If process namespace sharing is enabled, you can see processes from all the containers in that Pod.
286-
For example, after attaching, you run `ps` in the debugger container:
287-
-->
288-
如果启用了进程命名空间共享,则可以查看该 Pod 所有容器中的进程。
289-
例如,运行上述 `attach` 操作后,在调试器容器中运行 `ps` 操作:
290-
291-
```shell
292-
# 在 "debugger" 临时容器内中运行此 shell 命令
293-
ps auxww
294-
```
295-
296-
运行命令后,输出类似于:
297-
298-
```
299-
PID USER TIME COMMAND
300-
1 root 0:00 /pause
301-
6 root 0:00 nginx: master process nginx -g daemon off;
302-
11 101 0:00 nginx: worker process
303-
12 101 0:00 nginx: worker process
304-
13 101 0:00 nginx: worker process
305-
14 101 0:00 nginx: worker process
306-
15 101 0:00 nginx: worker process
307-
16 101 0:00 nginx: worker process
308-
17 101 0:00 nginx: worker process
309-
18 101 0:00 nginx: worker process
310-
19 root 0:00 /pause
311-
24 root 0:00 sh
312-
29 root 0:00 ps auxww
313-
```
314-

content/zh/docs/concepts/workloads/pods/init-containers.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
---
2-
approvers:
3-
- erictune
42
title: Init 容器
53
content_type: concept
64
weight: 40
@@ -514,9 +512,6 @@ Pod 级别的 cgroups 是基于有效 Pod 的请求和限制值,和调度器
514512
A Pod can restart, causing re-execution of init containers, for the following
515513
reasons:
516514
517-
* A user updates the Pod specification, causing the init container image to change.
518-
Any changes to the init container image restarts the Pod. App container image
519-
changes only restart the app container.
520515
* The Pod infrastructure container is restarted. This is uncommon and would
521516
have to be done by someone with root access to nodes.
522517
* All containers in a Pod are terminated while `restartPolicy` is set to Always,
@@ -527,15 +522,22 @@ reasons:
527522
528523
Pod 重启会导致 Init 容器重新执行,主要有如下几个原因:
529524
530-
* 用户更新 Pod 的规约导致 Init 容器镜像发生改变。Init 容器镜像的变更会引起 Pod 重启。
531-
应用容器镜像的变更仅会重启应用容器。
532-
533525
* Pod 的基础设施容器 (译者注:如 `pause` 容器) 被重启。这种情况不多见,
534526
必须由具备 root 权限访问节点的人员来完成。
535527
536528
* 当 `restartPolicy` 设置为 "`Always`",Pod 中所有容器会终止而强制重启。
537529
由于垃圾收集机制的原因,Init 容器的完成记录将会丢失。
538530
531+
<!--
532+
The Pod will not be restarted when the init container image is changed, or the
533+
init container completion record has been lost due to garbage collection. This
534+
applies for Kubernetes v1.20 and later. If you are using an earlier version of
535+
Kubernetes, consult the documentation for the version you are using.
536+
-->
537+
当 Init 容器的镜像发生改变或者 Init 容器的完成记录因为垃圾收集等原因被丢失时,
538+
Pod 不会被重启。这一行为适用于 Kubernetes v1.20 及更新版本。如果你在使用较早
539+
版本的 Kubernetes,可查阅你所使用的版本对应的文档。
540+
539541
## {{% heading "whatsnext" %}}
540542
541543
<!--

content/zh/docs/concepts/workloads/pods/pod-lifecycle.md

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,17 @@ ID([UID](/zh/docs/concepts/overview/working-with-objects/names/#uids)),
7474

7575
<!--
7676
Pods do not, by themselves, self-heal. If a Pod is scheduled to a
77-
{{< glossary_tooltip text="node" term_id="node" >}} that then fails,
78-
or if the scheduling operation itself fails, the Pod is deleted; likewise, a Pod won't
77+
{{< glossary_tooltip text="node" term_id="node" >}} that then fails, the Pod is deleted; likewise, a Pod won't
7978
survive an eviction due to a lack of resources or Node maintenance. Kubernetes uses a
8079
higher-level abstraction, called a
8180
{{< glossary_tooltip term_id="controller" text="controller" >}}, that handles the work of
8281
managing the relatively disposable Pod instances.
8382
-->
8483
Pod 自身不具有自愈能力。如果 Pod 被调度到某{{< glossary_tooltip text="节点" term_id="node" >}}
85-
而该节点之后失效,或者调度操作本身失效,Pod 会被删除;与此类似,Pod 无法在节点资源
86-
耗尽或者节点维护期间继续存活。Kubernetes 使用一种高级抽象,称作
87-
{{< glossary_tooltip term_id="controller" text="控制器" >}},来管理这些相对而言
88-
可随时丢弃的 Pod 实例
84+
而该节点之后失效,Pod 会被删除;类似地,Pod 无法在因节点资源
85+
耗尽或者节点维护而被驱逐期间继续存活。Kubernetes 使用一种高级抽象
86+
来管理这些相对而言可随时丢弃的 Pod 实例,称作
87+
{{< glossary_tooltip term_id="controller" text="控制器" >}}
8988

9089
<!--
9190
A given Pod (as defined by a UID) is never "rescheduled" to a different node; instead,
@@ -577,14 +576,14 @@ is different from the liveness probe.
577576
如果你希望容器能够自行进入维护状态,也可以指定一个就绪态探针,检查某个特定于
578577
就绪态的因此不同于存活态探测的端点。
579578

579+
{{< note >}}
580580
<!--
581-
If you just want to be able to drain requests when the Pod is deleted, you do not
581+
If you want to be able to drain requests when the Pod is deleted, you do not
582582
necessarily need a readiness probe; on deletion, the Pod automatically puts itself
583583
into an unready state regardless of whether the readiness probe exists.
584584
The Pod remains in the unready state while it waits for the containers in the Pod
585585
to stop.
586586
-->
587-
{{< note >}}
588587
请注意,如果你只是想在 Pod 被删除时能够排空请求,则不一定需要使用就绪态探针;
589588
在删除 Pod 时,Pod 会自动将自身置于未就绪状态,无论就绪态探针是否存在。
590589
等待 Pod 中的容器停止期间,Pod 会一直处于未就绪状态。
@@ -677,18 +676,6 @@ An example flow:
677676
On the node where the Pod is running: as soon as the kubelet sees that a Pod has been marked
678677
as terminating (a graceful shutdown duration has been set), the kubelet begins the local Pod
679678
shutdown process.
680-
681-
1. If one of the Pod's containers has defined a `preStop`
682-
[hook](/docs/concepts/containers/container-lifecycle-hooks/#hook-details), the kubelet
683-
runs that hook inside of the container. If the `preStop` hook is still running after the
684-
grace period expires, the kubelet requests a small, one-off grace period extension of 2
685-
seconds.
686-
If the `preStop` hook needs longer to complete than the default grace period allows,
687-
you must modify `terminationGracePeriodSeconds` to suit this.
688-
1. The kubelet triggers the container runtime to send a TERM signal to process 1 inside each
689-
container.
690-
The containers in the Pod receive the TERM signal at different times and in an arbitrary
691-
order. If the order of shutdowns matters, consider using a `preStop` hook to synchronize.
692679
-->
693680
下面是一个例子:
694681

@@ -701,6 +688,19 @@ An example flow:
701688
在 Pod 运行所在的节点上:`kubelet` 一旦看到 Pod
702689
被标记为正在终止(已经设置了体面终止限期),`kubelet` 即开始本地的 Pod 关闭过程。
703690

691+
<!--
692+
1. If one of the Pod's containers has defined a `preStop`
693+
[hook](/docs/concepts/containers/container-lifecycle-hooks/#hook-details), the kubelet
694+
runs that hook inside of the container. If the `preStop` hook is still running after the
695+
grace period expires, the kubelet requests a small, one-off grace period extension of 2
696+
seconds.
697+
If the `preStop` hook needs longer to complete than the default grace period allows,
698+
you must modify `terminationGracePeriodSeconds` to suit this.
699+
1. The kubelet triggers the container runtime to send a TERM signal to process 1 inside each
700+
container.
701+
The containers in the Pod receive the TERM signal at different times and in an arbitrary
702+
order. If the order of shutdowns matters, consider using a `preStop` hook to synchronize.
703+
-->
704704
1. 如果 Pod 中的容器之一定义了 `preStop`
705705
[回调](/zh/docs/concepts/containers/container-lifecycle-hooks/#hook-details)
706706
`kubelet` 开始在容器内运行该回调逻辑。如果超出体面终止限期时,`preStop` 回调逻辑
@@ -847,7 +847,6 @@ This avoids a resource leak as Pods are created and terminated over time.
847847
and
848848
[ContainerStatus](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#containerstatus-v1-core).
849849
-->
850-
851850
* 动手实践[为容器生命周期时间关联处理程序](/zh/docs/tasks/configure-pod-container/attach-handler-lifecycle-event/)
852851
* 动手实践[配置存活态、就绪态和启动探针](/zh/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/)
853852
* 进一步了解[容器生命周期回调](/zh/docs/concepts/containers/container-lifecycle-hooks/)

content/zh/docs/concepts/workloads/pods/pod-topology-spread-constraints.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,11 @@ graph TB
9595
{{< /mermaid >}}
9696

9797
<!--
98-
Instead of manually applying labels, you can also reuse the [well-known labels](/docs/reference/kubernetes-api/labels-annotations-taints/) that are created and populated automatically on most clusters.
98+
99+
Instead of manually applying labels, you can also reuse the [well-known labels](/docs/reference/labels-annotations-taints/) that are created and populated automatically on most clusters.
99100
-->
100101
你可以复用在大多数集群上自动创建和填充的
101-
[常用标签](/zh/docs/reference/kubernetes-api/labels-annotations-taints/)
102+
[常用标签](/zh/docs/reference/labels-annotations-taints/)
102103
而不是手动添加标签。
103104

104105
<!--

0 commit comments

Comments
 (0)