Skip to content

Commit d517ba4

Browse files
authored
Merge branch 'kubernetes:main' into patch-1
2 parents 158573f + d8e7dbd commit d517ba4

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

content/zh-cn/docs/tasks/inject-data-application/downward-api-volume-expose-pod-information.md

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ title: 通过文件将 Pod 信息呈现给容器
33
content_type: task
44
weight: 40
55
---
6+
<!--
7+
title: Expose Pod Information to Containers Through Files
8+
content_type: task
9+
weight: 40
10+
-->
611

712
<!-- overview -->
813

@@ -15,7 +20,7 @@ A `downwardAPI` volume can expose Pod fields and container fields.
1520
此页面描述 Pod 如何使用
1621
[`downwardAPI`](/zh-cn/docs/concepts/storage/volumes/#downwardapi)
1722
把自己的信息呈现给 Pod 中运行的容器。
18-
`downwardAPI` 可以呈现 Pod 和容器的字段。
23+
`downwardAPI` 卷可以呈现 Pod 和容器的字段。
1924

2025
<!--
2126
In Kubernetes, there are two ways to expose Pod and container fields to a running container:
@@ -37,7 +42,6 @@ _downward API_.
3742

3843
{{< include "task-tutorial-prereqs.md" >}}
3944

40-
4145
<!-- steps -->
4246

4347
<!--
@@ -49,7 +53,7 @@ Here is the manifest for the Pod:
4953
-->
5054
## 存储 Pod 字段 {#store-pod-fields}
5155

52-
在这部分的练习中,你将创建一个包含一个容器的 Pod,并将 Pod 级别的字段作为文件映射到正在运行的容器中
56+
在这部分的练习中,你将创建一个包含一个容器的 Pod,并将 Pod 级别的字段作为文件投射到正在运行的容器中
5357
Pod 的清单如下:
5458

5559
{{< codenew file="pods/inject/dapi-volume.yaml" >}}
@@ -73,11 +77,11 @@ field should be stored in a file named `annotations`.
7377
第一个元素指示 Pod 的 `metadata.labels` 字段的值保存在名为 `labels` 的文件中。
7478
第二个元素指示 Pod 的 `annotations` 字段的值保存在名为 `annotations` 的文件中。
7579

80+
{{< note >}}
7681
<!--
7782
The fields in this example are Pod fields. They are not
7883
fields of the container in the Pod.
7984
-->
80-
{{< note >}}
8185
本示例中的字段是 Pod 字段,不是 Pod 中容器的字段。
8286
{{< /note >}}
8387

@@ -93,7 +97,7 @@ kubectl apply -f https://k8s.io/examples/pods/inject/dapi-volume.yaml
9397
<!--
9498
Verify that the container in the Pod is running:
9599
-->
96-
验证Pod中的容器运行正常
100+
验证 Pod 中的容器运行正常
97101

98102
```shell
99103
kubectl get pods
@@ -111,7 +115,7 @@ kubectl logs kubernetes-downwardapi-volume-example
111115
<!--
112116
The output shows the contents of the `labels` file and the `annotations` file:
113117
-->
114-
输出显示 `labels` `annotations` 文件的内容:
118+
输出显示 `labels` 文件和 `annotations` 文件的内容:
115119

116120
```
117121
cluster="test-cluster1"
@@ -178,9 +182,9 @@ a symbolic link to the temporary subdirectory. Also in the `/etc/podinfo` direct
178182
`labels` and `annotations` are symbolic links.
179183
-->
180184
在输出中可以看到,`labels``annotations` 文件都在一个临时子目录中。
181-
在这个例子,`..2982_06_02_21_47_53.299460680`
182-
`/etc/podinfo` 目录中,`..data` 是一个指向临时子目录
183-
的符号链接。`/etc/podinfo` 目录中,`labels``annotations` 也是符号链接。
185+
在这个例子中,这个临时子目录为 `..2982_06_02_21_47_53.299460680`
186+
`/etc/podinfo` 目录中,`..data` 是指向该临时子目录的符号链接。
187+
另外在 `/etc/podinfo` 目录中,`labels``annotations` 也是符号链接。
184188

185189
```
186190
drwxr-xr-x ... Feb 6 21:47 ..2982_06_02_21_47_53.299460680
@@ -203,14 +207,14 @@ atomically using [rename(2)](http://man7.org/linux/man-pages/man2/rename.2.html)
203207
然后通过使用 [rename(2)](http://man7.org/linux/man-pages/man2/rename.2.html)
204208
完成 `..data` 符号链接的原子性更新。
205209

210+
{{< note >}}
206211
<!--
207212
A container using Downward API as a
208213
[subPath](/docs/concepts/storage/volumes/#using-subpath) volume mount will not
209214
receive Downward API updates.
210215
-->
211-
{{< note >}}
212216
如果容器以
213-
[subPath](/zh-cn/docs/concepts/storage/volumes/#using-subpath)卷挂载方式来使用
217+
[subPath](/zh-cn/docs/concepts/storage/volumes/#using-subpath) 卷挂载方式来使用
214218
Downward API,则该容器无法收到更新事件。
215219
{{< /note >}}
216220

@@ -237,7 +241,8 @@ just one container:
237241
## 存储容器字段 {#store-container-fields}
238242

239243
前面的练习中,你使用 downward API 使 Pod 级别的字段可以被 Pod 内正在运行的容器访问。
240-
接下来这个练习,你将只传递由 Pod 定义的部分的字段到 Pod 内正在运行的容器中,但这些字段取自特定[容器](/zh-cn/docs/reference/kubernetes-api/workload-resources/pod-v1/#Container)而不是整个 Pod。
244+
接下来这个练习,你将只传递由 Pod 定义的部分的字段到 Pod 内正在运行的容器中,
245+
但这些字段取自特定[容器](/zh-cn/docs/reference/kubernetes-api/workload-resources/pod-v1/#Container)而不是整个 Pod。
241246
下面是一个同样只有一个容器的 Pod 的清单:
242247

243248
{{< codenew file="pods/inject/dapi-volume-resources.yaml" >}}
@@ -260,16 +265,16 @@ Create the Pod:
260265
-->
261266
在这个清单中,你可以看到 Pod 有一个
262267
[`downwardAPI`](/zh-cn/docs/concepts/storage/volumes/#downwardapi)
263-
并且这个会挂载到 Pod 内的单个容器的 `/etc/podinfo` 目录。
268+
并且这个卷会挂载到 Pod 内的单个容器的 `/etc/podinfo` 目录。
264269

265270
查看 `downwardAPI` 下面的 `items` 数组。
266271
数组的每个元素定义一个 `downwardAPI` 卷。
267272

268273
第一个元素指定在名为 `client-container` 的容器中,
269274
`1m` 所指定格式的 `limits.cpu` 字段的值应推送到名为 `cpu_limit` 的文件中。
270-
`divisor` 字段是可选的,默认值为 `1`1 的除数表示 CPU 资源的核心或内存资源的字节
275+
`divisor` 字段是可选的,默认值为 `1`1 的除数表示 CPU 资源的核数或内存资源的字节数
271276

272-
创建Pod
277+
创建 Pod
273278

274279
```shell
275280
kubectl apply -f https://k8s.io/examples/pods/inject/dapi-volume-resources.yaml
@@ -298,7 +303,7 @@ cat /etc/podinfo/cpu_limit
298303
You can use similar commands to view the `cpu_request`, `mem_limit` and
299304
`mem_request` files.
300305
-->
301-
你可以使用同样的命令查看 `cpu_request``mem_limit``mem_request` 文件.
306+
你可以使用同样的命令查看 `cpu_request``mem_limit``mem_request` 文件
302307

303308
<!-- discussion -->
304309

0 commit comments

Comments
 (0)