Skip to content

Commit 8136093

Browse files
authored
Merge pull request #27794 from tengqm/zh-sync-concepts-12
[zh] Resync concepts section (12)
2 parents d29693f + 8b7b499 commit 8136093

File tree

4 files changed

+85
-29
lines changed

4 files changed

+85
-29
lines changed

content/zh/docs/concepts/containers/container-environment.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,17 @@ Pod 定义中的用户所定义的环境变量也可在容器中使用,就像
6868
### Cluster information
6969
7070
A list of all services that were running when a Container was created is available to that Container as environment variables.
71+
This list is limited to services within the same namespace as the new Container's Pod and Kubernetes control plane services.
7172
Those environment variables match the syntax of Docker links.
7273
7374
For a service named *foo* that maps to a Container named *bar*,
7475
the following variables are defined:
7576
-->
7677
### 集群信息
7778

78-
创建容器时正在运行的所有服务的列表都可用作该容器的环境变量。这些环境变量与 Docker 链接的语法匹配。
79+
创建容器时正在运行的所有服务都可用作该容器的环境变量。
80+
这里的服务仅限于新容器的 Pod 所在的名字空间中的服务,以及 Kubernetes 控制面的服务。
81+
这些环境变量与 Docker 链接的语法相同。
7982

8083
对于名为 *foo* 的服务,当映射到名为 *bar* 的容器时,以下变量是被定义了的:
8184

content/zh/docs/concepts/containers/container-lifecycle-hooks.md

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,21 @@ No parameters are passed to the handler.
5959
`PreStop`
6060

6161
<!--
62-
This hook is called immediately before a container is terminated due to an API request or management event such as liveness probe failure, preemption, resource contention and others. A call to the preStop hook fails if the container is already in terminated or completed state.
63-
It is blocking, meaning it is synchronous,
64-
so it must complete before the signal to stop the container can be sent.
65-
No parameters are passed to the handler.
66-
-->
67-
在容器因 API 请求或者管理事件(诸如存活态探针失败、资源抢占、资源竞争等)而被终止之前,
68-
此回调会被调用。
69-
如果容器已经处于终止或者完成状态,则对 preStop 回调的调用将失败。
70-
此调用是阻塞的,也是同步调用,因此必须在发出删除容器的信号之前完成。
71-
没有参数传递给处理程序。
62+
This hook is called immediately before a container is terminated due to an API request or management
63+
event such as a liveness/startup probe failure, preemption, resource contention and others. A call
64+
to the `PreStop` hook fails if the container is already in a terminated or completed state and the
65+
hook must complete before the TERM signal to stop the container can be sent. The Pod's termination
66+
grace period countdown begins before the `PreStop` hook is executed, so regardless of the outcome of
67+
the handler, the container will eventually terminate within the Pod's termination grace period. No
68+
parameters are passed to the handler.
69+
-->
70+
在容器因 API 请求或者管理事件(诸如存活态探针、启动探针失败、资源抢占、资源竞争等)
71+
而被终止之前,此回调会被调用。
72+
如果容器已经处于已终止或者已完成状态,则对 preStop 回调的调用将失败。
73+
在用来停止容器的 TERM 信号被发出之前,回调必须执行结束。
74+
Pod 的终止宽限周期在 `PreStop` 回调被执行之前即开始计数,所以无论
75+
回调函数的执行结果如何,容器最终都会在 Pod 的终止宽限期内被终止。
76+
没有参数会被传递给处理程序。
7277

7378
<!--
7479
A more detailed description of the termination behavior can be found in
@@ -122,6 +127,20 @@ the Container cannot reach a `running` state.
122127
但是,如果回调运行或挂起的时间太长,则容器无法达到 `running` 状态。
123128

124129
<!--
130+
`PreStop` hooks are not executed asynchronously from the signal
131+
to stop the Container; the hook must complete its execution before
132+
the TERM signal can be sent.
133+
If a `PreStop` hook hangs during execution,
134+
the Pod's phase will be `Terminating` and remain there until the Pod is
135+
killed after its `terminationGracePeriodSeconds` expires.
136+
This grace period applies to the total time it takes for both
137+
the `PreStop` hook to execute and for the Container to stop normally.
138+
If, for example, `terminationGracePeriodSeconds` is 60, and the hook
139+
takes 55 seconds to complete, and the Container takes 10 seconds to stop
140+
normally after receiving the signal, then the Container will be killed
141+
before it can stop normally, since `terminationGracePeriodSeconds` is
142+
less than the total time (55+10) it takes for these two things to happen.
143+
125144
`PreStop` hooks are not executed asynchronously from the signal
126145
to stop the Container; the hook must complete its execution before
127146
the signal can be sent.
@@ -145,7 +164,7 @@ less than the total time (55+10) it takes for these two things to happen.
145164
例如,如果 `terminationGracePeriodSeconds` 是 60,回调函数花了 55 秒钟
146165
完成执行,而容器在收到信号之后花了 10 秒钟来正常结束,那么容器会在其
147166
能够正常结束之前即被杀死,因为 `terminationGracePeriodSeconds` 的值
148-
小于后面两件事情所花费的总时间(55 + 10)。
167+
小于后面两件事情所花费的总时间(55+10)。
149168

150169
<!--
151170
If either a `PostStart` or `PreStop` hook fails,

content/zh/docs/concepts/containers/images.md

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -89,30 +89,62 @@ Instead, specify a meaningful tag such as `v1.42.0`.
8989
<!--
9090
## Updating images
9191
92-
The default pull policy is `IfNotPresent` which causes the
93-
{{< glossary_tooltip text="kubelet" term_id="kubelet" >}} to skip
94-
pulling an image if it already exists. If you would like to always force a pull,
95-
you can do one of the following:
92+
When you first create a {{< glossary_tooltip text="Deployment" term_id="deployment" >}},
93+
{{< glossary_tooltip text="StatefulSet" term_id="statefulset" >}}, Pod, or other
94+
object that includes a Pod template, then by default the pull policy of all
95+
containers in that pod will be set to `IfNotPresent` if it is not explicitly
96+
specified. This policy causes the
97+
{{< glossary_tooltip text="kubelet" term_id="kubelet" >}} to skip pulling an
98+
image if it already exists.
99+
-->
100+
## 更新镜像 {#updating-images}
101+
102+
当你最初创建一个 {{< glossary_tooltip text="Deployment" term_id="deployment" >}}、
103+
{{< glossary_tooltip text="StatefulSet" term_id="statefulset" >}}、Pod
104+
或者其他包含 Pod 模板的对象时,如果没有显式设定的话,Pod 中所有容器的默认镜像
105+
拉取策略是 `IfNotPresent`。这一策略会使得
106+
{{< glossary_tooltip text="kubelet" term_id="kubelet" >}}
107+
在镜像已经存在的情况下直接略过拉取镜像的操作。
108+
109+
<!--
110+
If you would like to always force a pull, you can do one of the following:
96111
97112
- set the `imagePullPolicy` of the container to `Always`.
98-
- omit the `imagePullPolicy` and use `:latest` as the tag for the image to use.
113+
- omit the `imagePullPolicy` and use `:latest` as the tag for the image to use;
114+
Kubernetes will set the policy to `Always`.
99115
- omit the `imagePullPolicy` and the tag for the image to use.
100116
- enable the [AlwaysPullImages](/docs/reference/access-authn-authz/admission-controllers/#alwayspullimages) admission controller.
101-
102-
When `imagePullPolicy` is defined without a specific value, it is also set to `Always`.
103117
-->
104-
## 更新镜像 {#updating-images}
105-
106-
默认的镜像拉取策略是 `IfNotPresent`:在镜像已经存在的情况下,
107-
{{< glossary_tooltip text="kubelet" term_id="kubelet" >}} 将不再去拉取镜像。
108-
如果希望强制总是拉取镜像,你可以执行以下操作之一:
118+
如果你希望强制总是拉取镜像,你可以执行以下操作之一:
109119

110120
- 设置容器的 `imagePullPolicy``Always`
111-
- 省略 `imagePullPolicy`,并使用 `:latest` 作为要使用的镜像的标签。
121+
- 省略 `imagePullPolicy`,并使用 `:latest` 作为要使用的镜像的标签;
122+
Kubernetes 会将策略设置为 `Always`
112123
- 省略 `imagePullPolicy` 和要使用的镜像标签。
113124
- 启用 [AlwaysPullImages](/zh/docs/reference/access-authn-authz/admission-controllers/#alwayspullimages)
114125
准入控制器(Admission Controller)。
115126

127+
{{< note >}}
128+
<!--
129+
The value of `imagePullPolicy` of the container is always set when the object is
130+
first _created_, and is not updated if the image's tag later changes.
131+
132+
For example, if you create a Deployment with an image whose tag is _not_
133+
`:latest`, and later update that Deployment's image to a `:latest` tag, the
134+
`imagePullPolicy` field will _not_ change to `Always`. You must manually change
135+
the pull policy of any object after its initial creation.
136+
-->
137+
对象被 *创建* 时,容器的 `imagePullPolicy` 总是被设置为某值,如果镜像的标签
138+
后来发生改变,镜像拉取策略也不会被改变。
139+
140+
例如,如果你创建了一个 Deployment 对象,其中的镜像标签不是 `:latest`
141+
后来 Deployment 的镜像被改为 `:latest`,则 `imagePullPolicy` 不会被改变为
142+
`Always`。你必须在对象被初始创建之后手动改变拉取策略。
143+
{{< /note >}}
144+
145+
<!--
146+
When `imagePullPolicy` is defined without a specific value, it is also set to `Always`.
147+
-->
116148
如果 `imagePullPolicy` 未被定义为特定的值,也会被设置为 `Always`
117149

118150
<!--
@@ -245,7 +277,7 @@ example, run these on your desktop/laptop:
245277

246278
<!--
247279
1. Run `docker login [server]` for each set of credentials you want to use. This updates `$HOME/.docker/config.json` on your PC.
248-
1. View `$HOME/.docker/config.json` in an editor to ensure it contains just the credentials you want to use.
280+
1. View `$HOME/.docker/config.json` in an editor to ensure it contains only the credentials you want to use.
249281
1. Get a list of your nodes; for example:
250282
- if you want the names: `nodes=$( kubectl get nodes -o jsonpath='{range.items[*].metadata}{.name} {end}' )`
251283
- if you want to get the IP addresses: `nodes=$( kubectl get nodes -o jsonpath='{range .items[*].status.addresses[?(@.type=="ExternalIP")]}{.address} {end}' )`

content/zh/docs/concepts/containers/runtime-class.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: 容器运行时类(Runtime Class)
2+
title: 容器运行时类Runtime Class
33
content_type: concept
44
weight: 20
55
---
@@ -184,9 +184,11 @@ For more details on setting up CRI runtimes, see [CRI installation](/docs/setup/
184184
#### dockershim
185185

186186
<!--
187-
Kubernetes built-in dockershim CRI does not support runtime handlers.
187+
RuntimeClasses with dockershim must set the runtime handler to `docker`. Dockershim does not support
188+
custom configurable runtime handlers.
188189
-->
189-
Kubernetes 内置的 dockershim CRI 不支持配置运行时 handler。
190+
为 dockershim 设置 RuntimeClass 时,必须将运行时处理程序设置为 `docker`。
191+
Dockershim 不支持自定义的可配置的运行时处理程序。
190192

191193
#### [containerd](https://containerd.io/)
192194

0 commit comments

Comments
 (0)