Skip to content

Commit 2b6dadd

Browse files
authored
Merge pull request #49458 from windsonsea/voluyy
[zh] Sync storage/volumes.md
2 parents d8891e7 + 66fbeb6 commit 2b6dadd

File tree

1 file changed

+78
-23
lines changed

1 file changed

+78
-23
lines changed

content/zh-cn/docs/concepts/storage/volumes.md

Lines changed: 78 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,41 +23,93 @@ weight: 10
2323
<!-- overview -->
2424

2525
<!--
26-
On-disk files in a container are ephemeral, which presents some problems for
26+
Kubernetes _volumes_ provide a way for containers in a {{< glossary_tooltip text="pods" term_id="pod" >}}
27+
to access and share data via the filesystem. There are different kinds of volume that you can use for different purposes,
28+
such as:
29+
-->
30+
Kubernetes ****为 {{< glossary_tooltip text="Pod" term_id="pod" >}}
31+
中的容器提供了一种通过文件系统访问和共享数据的方式。存在不同类别的卷,你可以将其用于各种用途,例如:
32+
33+
<!--
34+
- populating a configuration file based on a {{< glossary_tooltip text="ConfigMap" term_id="configmap" >}}
35+
or a {{< glossary_tooltip text="Secret" term_id="secret" >}}
36+
- providing some temporary scratch space for a pod
37+
- sharing a filesystem between two different containers in the same pod
38+
- sharing a filesystem between two different pods (even if those Pods run on different nodes)
39+
- durably storing data so that it stays available even if the Pod restarts or is replaced
40+
-->
41+
- 基于 {{< glossary_tooltip text="ConfigMap" term_id="configmap" >}} 或
42+
{{< glossary_tooltip text="Secret" term_id="secret" >}} 填充配置文件
43+
- 为 Pod 提供一些临时的涂销空间
44+
- 在同一个 Pod 中的两个不同容器之间共享文件系统
45+
- 在两个不同的 Pod 之间共享文件系统(即使这些 Pod 运行在不同的节点上)
46+
- 持久化存储数据,这样即使 Pod 重启或被替换,存储的数据仍然可用
47+
<!--
48+
- passing configuration information to an app running in a container, based on details of the Pod
49+
the container is in
50+
(for example: telling a {{< glossary_tooltip text="sidecar container" term_id="sidecar-container" >}}
51+
what namespace the Pod is running in)
52+
- providing read-only access to data in a different container image
53+
-->
54+
- 基于容器所在 Pod 的详细信息,将配置信息传递给运行在容器中的应用
55+
(例如告诉{{< glossary_tooltip text="边车容器" term_id="sidecar-container" >}}:Pod 运行在哪个命名空间)
56+
- 以只读权限访问另一个容器镜像中的数据
57+
58+
<!--
59+
Data sharing can be between different local processes within a container, or between different containers,
60+
or between Pods.
61+
-->
62+
数据共享可以发生在容器内不同本地进程之间,或在不同容器之间,或在多个 Pod 之间。
63+
64+
<!--
65+
## Why volumes are important
66+
67+
- **Data persistence:** On-disk files in a container are ephemeral, which presents some problems for
2768
non-trivial applications when running in containers. One problem occurs when
28-
a container crashes or is stopped. Container state is not saved so all of the
69+
a container crashes or is stopped, the container state is not saved so all of the
2970
files that were created or modified during the lifetime of the container are lost.
30-
During a crash, kubelet restarts the container with a clean state.
31-
Another problem occurs when multiple containers are running in a `Pod` and
71+
During a crash, kubelet restarts the container with a clean state.
72+
-->
73+
## 为什么卷很重要 {#why-volumes-are-important}
74+
75+
- **数据持久性:** 容器中的文件在磁盘上是临时存放的,这给在容器中运行较重要的应用带来一些问题。
76+
当容器崩溃或被停止时,容器的状态不会被保存,因此在容器生命期内创建或修改的所有文件都将丢失。
77+
在崩溃期间,kubelet 会以干净的状态重启容器。
78+
79+
<!--
80+
- **Shared storage:** Another problem occurs when multiple containers are running in a `Pod` and
3281
need to share files. It can be challenging to setup
3382
and access a shared filesystem across all of the containers.
83+
3484
The Kubernetes {{< glossary_tooltip text="volume" term_id="volume" >}} abstraction
35-
solves both of these problems.
36-
Familiarity with [Pods](/docs/concepts/workloads/pods/) is suggested.
85+
can help you to solve both of these problems.
3786
-->
38-
容器中的文件在磁盘上是临时存放的,这给在容器中运行较重要的应用带来一些问题。
39-
当容器崩溃或停止时会出现一个问题。此时容器状态未保存,
40-
因此在容器生命周期内创建或修改的所有文件都将丢失。
41-
在崩溃期间,kubelet 会以干净的状态重新启动容器。
42-
当多个容器在一个 Pod 中运行并且需要共享文件时,会出现另一个问题。
43-
跨所有容器设置和访问共享文件系统具有一定的挑战性。
87+
- **共享存储:** 当多个容器在一个 Pod 中运行并需要共享文件时,会出现另一个问题。
88+
那就是在所有容器之间设置和访问共享文件系统可能会很有难度。
4489

4590
Kubernetes {{< glossary_tooltip text="卷(Volume)" term_id="volume" >}}
4691
这一抽象概念能够解决这两个问题。
4792

48-
阅读本文前建议你熟悉一下 [Pod](/zh-cn/docs/concepts/workloads/pods)
93+
<!--
94+
Before you learn about volumes, PersistentVolumes and PersistentVolumeClaims, you should read up
95+
about {{< glossary_tooltip term_id="Pod" text="Pods" >}} and make sure that you understand how
96+
Kubernetes uses Pods to run containers.
97+
-->
98+
在你学习卷、持久卷(PersistentVolume)和持久卷申领(PersistentVolumeClaim)之前,
99+
你应该先了解 {{< glossary_tooltip term_id="Pod" text="Pods" >}},
100+
确保你理解 Kubernetes 如何使用 Pod 来运行容器。
49101

50102
<!-- body -->
51103

52104
<!--
53-
## Background
105+
## How volumes work
54106
-->
55-
## 背景 {#background}
107+
## 卷是如何工作的 {#how-volumes-work}
56108

57109
<!--
58110
Kubernetes supports many types of volumes. A {{< glossary_tooltip term_id="pod" text="Pod" >}}
59111
can use any number of volume types simultaneously.
60-
[Ephemeral volume](/docs/concepts/storage/ephemeral-volumes/) types have a lifetime of a pod,
112+
[Ephemeral volume](/docs/concepts/storage/ephemeral-volumes/) types have a lifetime of a pod,
61113
but [persistent volumes](/docs/concepts/storage/persistent-volumes/) exist beyond
62114
the lifetime of a pod. When a pod ceases to exist, Kubernetes destroys ephemeral volumes;
63115
however, Kubernetes does not destroy persistent volumes.
@@ -82,23 +134,26 @@ volume type used.
82134
<!--
83135
To use a volume, specify the volumes to provide for the Pod in `.spec.volumes`
84136
and declare where to mount those volumes into containers in `.spec.containers[*].volumeMounts`.
85-
A process in a container sees a filesystem view composed from the initial contents of
137+
-->
138+
使用卷时, 在 `.spec.volumes` 字段中设置为 Pod 提供的卷,并在
139+
`.spec.containers[*].volumeMounts` 字段中声明卷在容器中的挂载位置。
140+
141+
<!--
142+
When a pod is launched, a process in the container sees a filesystem view composed from the initial contents of
86143
the {{< glossary_tooltip text="container image" term_id="image" >}}, plus volumes
87144
(if defined) mounted inside the container.
88145
The process sees a root filesystem that initially matches the contents of the container
89146
image.
90147
Any writes to within that filesystem hierarchy, if allowed, affect what that process views
91148
when it performs a subsequent filesystem access.
92149
-->
93-
使用卷时, 在 `.spec.volumes` 字段中设置为 Pod 提供的卷,并在
94-
`.spec.containers[*].volumeMounts` 字段中声明卷在容器中的挂载位置。
95-
容器中的进程看到的文件系统视图是由它们的{{< glossary_tooltip text="容器镜像" term_id="image" >}}
150+
当 Pod 被启动时,容器中的进程看到的文件系统视图是由它们的{{< glossary_tooltip text="容器镜像" term_id="image" >}}
96151
的初始内容以及挂载在容器中的卷(如果定义了的话)所组成的。
97152
其中根文件系统同容器镜像的内容相吻合。
98153
任何在该文件系统下的写入操作,如果被允许的话,都会影响接下来容器中进程访问文件系统时所看到的内容。
99154

100155
<!--
101-
Volumes mount at the [specified paths](#using-subpath) within
156+
Volumes are mounted at [specified paths](#using-subpath) within
102157
the image.
103158
For each container defined within a Pod, you must independently specify where
104159
to mount each volume that the container uses.
@@ -107,7 +162,7 @@ Volumes cannot mount within other volumes (but see [Using subPath](#using-subpat
107162
for a related mechanism). Also, a volume cannot contain a hard link to anything in
108163
a different volume.
109164
-->
110-
卷挂载在镜像中的[指定路径](#using-subpath)下。
165+
卷被挂载在镜像中的[指定路径](#using-subpath)下。
111166
Pod 配置中的每个容器必须独立指定各个卷的挂载位置。
112167

113168
卷不能挂载到其他卷之上(不过存在一种[使用 subPath](#using-subpath) 的相关机制),也不能与其他卷有硬链接。
@@ -365,11 +420,11 @@ data as read-only files in plain text format.
365420
`downwardAPI` 卷用于为应用提供 {{< glossary_tooltip term_id="downward-api" text="downward API" >}} 数据。
366421
在这类卷中,所公开的数据以纯文本格式的只读文件形式存在。
367422

423+
{{< note >}}
368424
<!--
369425
A container using the downward API as a [`subPath`](#using-subpath) volume mount does not
370426
receive updates when field values change.
371427
-->
372-
{{< note >}}
373428
容器以 [subPath](#using-subpath) 卷挂载方式使用 downward API 时,在字段值更改时将不能接收到它的更新。
374429
{{< /note >}}
375430

0 commit comments

Comments
 (0)