@@ -19,18 +19,24 @@ weight: 10
19
19
20
20
<!--
21
21
On-disk files in a container are ephemeral, which presents some problems for
22
- non-trivial applications when running in containers. One problem
23
- is the loss of files when a container crashes. The kubelet restarts the container
24
- but with a clean state. A second problem occurs when sharing files
25
- between containers running together in a `Pod`.
22
+ non-trivial applications when running in containers. One problem occurs when
23
+ a container crashes or is stopped. Container state is not saved so all of the
24
+ files that were created or modified during the lifetime of the container are lost.
25
+ During a crash, kubelet restarts the container with a clean state.
26
+ Another problem occurs when multiple containers are running in a `Pod` and
27
+ need to share files. It can be challenging to setup
28
+ and access a shared filesystem across all of the containers.
26
29
The Kubernetes {{< glossary_tooltip text="volume" term_id="volume" >}} abstraction
27
30
solves both of these problems.
28
31
Familiarity with [Pods](/docs/concepts/workloads/pods/) is suggested.
29
32
-->
30
- Container 中的文件在磁盘上是临时存放的,这给 Container 中运行的较重要的应用程序带来一些问题。
31
- 问题之一是当容器崩溃时文件丢失。
32
- kubelet 会重新启动容器,但容器会以干净的状态重启。
33
- 第二个问题会在同一 ` Pod ` 中运行多个容器并共享文件时出现。
33
+ 容器中的文件在磁盘上是临时存放的,这给在容器中运行较重要的应用带来一些问题。
34
+ 当容器崩溃或停止时会出现一个问题。此时容器状态未保存,
35
+ 因此在容器生命周期内创建或修改的所有文件都将丢失。
36
+ 在崩溃期间,kubelet 会以干净的状态重新启动容器。
37
+ 当多个容器在一个 Pod 中运行并且需要共享文件时,会出现另一个问题。
38
+ 跨所有容器设置和访问共享文件系统具有一定的挑战性。
39
+
34
40
Kubernetes {{< glossary_tooltip text="卷(Volume)" term_id="volume" >}}
35
41
这一抽象概念能够解决这两个问题。
36
42
@@ -56,14 +62,16 @@ Docker 提供卷驱动程序,但是其功能非常有限。
56
62
<!--
57
63
Kubernetes supports many types of volumes. A {{< glossary_tooltip term_id="pod" text="Pod" >}}
58
64
can use any number of volume types simultaneously.
59
- Ephemeral volume types have a lifetime of a pod, but persistent volumes exist beyond
65
+ [Ephemeral volume](/docs/concepts/storage/ephemeral-volumes/) types have a lifetime of a pod,
66
+ but [persistent volumes](/docs/concepts/storage/persistent-volumes/) exist beyond
60
67
the lifetime of a pod. When a pod ceases to exist, Kubernetes destroys ephemeral volumes;
61
68
however, Kubernetes does not destroy persistent volumes.
62
69
For any kind of volume in a given pod, data is preserved across container restarts.
63
70
-->
64
71
Kubernetes 支持很多类型的卷。
65
72
{{< glossary_tooltip term_id="pod" text="Pod" >}} 可以同时使用任意数目的卷类型。
66
- 临时卷类型的生命周期与 Pod 相同,但持久卷可以比 Pod 的存活期长。
73
+ [ 临时卷] ( /zh-cn/docs/concepts/storage/ephemeral-volumes/ ) 类型的生命周期与 Pod 相同,
74
+ 但[ 持久卷] ( /zh-cn/docs/concepts/storage/persistent-volumes/ ) 可以比 Pod 的存活期长。
67
75
当 Pod 不再存在时,Kubernetes 也会销毁临时卷;不过 Kubernetes 不会销毁持久卷。
68
76
对于给定 Pod 中任何类型的卷,在容器重启期间数据都不会丢失。
69
77
@@ -1943,20 +1951,26 @@ persistent volume:
1943
1951
secrets are passed. When you have configured secret data for node-initiated
1944
1952
volume expansion, the kubelet passes that data via the `NodeExpandVolume()`
1945
1953
call to the CSI driver. In order to use the `nodeExpandSecretRef` field, your
1946
- cluster should be running Kubernetes version 1.25 or later and you must enable
1954
+ cluster should be running Kubernetes version 1.25 or later.
1955
+ If you are running Kubernetes Version 1.25 or 1.26, you must enable
1947
1956
the [feature gate](/docs/reference/command-line-tools-reference/feature-gates/)
1948
1957
named `CSINodeExpandSecret` for each kube-apiserver and for the kubelet on every
1949
- node. You must also be using a CSI driver that supports or requires secret data during
1958
+ node. In Kubernetes version 1.27 this feature has been enabled by default
1959
+ and no explicit enablement of the feature gate is required.
1960
+ You must also be using a CSI driver that supports or requires secret data during
1950
1961
node-initiated storage resize operations.
1951
1962
-->
1952
1963
* `nodeExpandSecretRef`:对包含敏感信息的 Secret 对象的引用,
1953
1964
该信息会传递给 CSI 驱动以完成 CSI `NodeExpandVolume` 调用。
1954
1965
此字段是可选的,如果不需要 Secret,则可能是空的。
1955
1966
如果 Secret 包含多个 Secret 条目,则传递所有 Secret 条目。
1956
- 当你为节点初始化的卷扩展配置 Secret 数据时,kubelet 会通过 `NodeExpandVolume()` 调用将该数据传递给 CSI 驱动。
1957
- 为了使用 `nodeExpandSecretRef` 字段,你的集群应运行 Kubernetes 1.25 或更高版本,
1958
- 并且你必须为每个 kube-apiserver 和每个节点上的 kubelet 启用名为 `CSINodeExpandSecret`
1967
+ 当你为节点初始化的卷扩展配置 Secret 数据时,kubelet 会通过 `NodeExpandVolume()`
1968
+ 调用将该数据传递给 CSI 驱动。为了使用 `nodeExpandSecretRef` 字段,
1969
+ 你的集群应运行 Kubernetes 1.25 或更高版本,
1970
+ 如果你所运行的 Kubernetes 是 1.25 或 1.26,你必须为每个 kube-apiserver
1971
+ 和每个节点上的 kubelet 启用名为 `CSINodeExpandSecret`
1959
1972
的[特性门控](/zh-cn/docs/reference/command-line-tools-reference/feature-gates/)。
1973
+ 在 Kubernetes 1.27 版本中,此特性已默认启用,无需显式启用特性门控。
1960
1974
在节点初始化的存储大小调整操作期间,你还必须使用支持或需要 Secret 数据的 CSI 驱动。
1961
1975
1962
1976
<!--
@@ -2115,7 +2129,8 @@ FlexVolume 是一个使用基于 exec 的模型来与驱动程序对接的树外
2115
2129
驱动程序可执行文件,在某些情况下,控制平面节点中也要安装。
2116
2130
2117
2131
Pod 通过 `flexvolume` 树内插件与 FlexVolume 驱动程序交互。
2118
- 更多详情请参考 FlexVolume [README](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-storage/flexvolume.md#readme) 文档。
2132
+ 更多详情请参考 FlexVolume
2133
+ [README](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-storage/flexvolume.md#readme) 文档。
2119
2134
2120
2135
<!--
2121
2136
The following FlexVolume [plugins](https://github.com/Microsoft/K8s-Storage-Plugins/tree/master/flexvolume/windows),
@@ -2273,4 +2288,3 @@ sudo systemctl restart docker
2273
2288
Follow an example of [deploying WordPress and MySQL with Persistent Volumes](/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/).
2274
2289
-->
2275
2290
参考[使用持久卷部署 WordPress 和 MySQL](/zh-cn/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/) 示例。
2276
-
0 commit comments