Merge pull request #35081 from windsonsea/pvyhf
[zh-cn] resync /concepts/storage/persistent-volumes.md
This commit is contained in:
@@ -31,7 +31,7 @@ weight: 20
|
||||
<!--
|
||||
This document describes _persistent volumes_ in Kubernetes. Familiarity with [volumes](/docs/concepts/storage/volumes/) is suggested.
|
||||
-->
|
||||
本文描述 Kubernetes 中的 _持久卷(Persistent Volume)_ 。
|
||||
本文描述 Kubernetes 中的**持久卷(Persistent Volume)** 。
|
||||
建议先熟悉[卷(Volume)](/zh-cn/docs/concepts/storage/volumes/)的概念。
|
||||
|
||||
<!-- body -->
|
||||
@@ -43,24 +43,25 @@ Managing storage is a distinct problem from managing compute instances. The Pers
|
||||
-->
|
||||
## 介绍 {#introduction}
|
||||
|
||||
存储的管理是一个与计算实例的管理完全不同的问题。PersistentVolume 子系统为用户
|
||||
和管理员提供了一组 API,将存储如何供应的细节从其如何被使用中抽象出来。
|
||||
存储的管理是一个与计算实例的管理完全不同的问题。
|
||||
PersistentVolume 子系统为用户和管理员提供了一组 API,
|
||||
将存储如何制备的细节从其如何被使用中抽象出来。
|
||||
为了实现这点,我们引入了两个新的 API 资源:PersistentVolume 和
|
||||
PersistentVolumeClaim。
|
||||
|
||||
<!--
|
||||
A _PersistentVolume_ (PV) is a piece of storage in the cluster that has been provisioned by an administrator or dynamically provisioned using [Storage Classes](/docs/concepts/storage/storage-classes/). It is a resource in the cluster just like a node is a cluster resource. PVs are volume plugins like Volumes, but have a lifecycle independent of any individual Pod that uses the PV. This API object captures the details of the implementation of the storage, be that NFS, iSCSI, or a cloud-provider-specific storage system.
|
||||
-->
|
||||
持久卷(PersistentVolume,PV)是集群中的一块存储,可以由管理员事先供应,或者
|
||||
使用[存储类(Storage Class)](/zh-cn/docs/concepts/storage/storage-classes/)来动态供应。
|
||||
持久卷是集群资源,就像节点也是集群资源一样。PV 持久卷和普通的 Volume 一样,也是使用
|
||||
卷插件来实现的,只是它们拥有独立于任何使用 PV 的 Pod 的生命周期。
|
||||
**持久卷(PersistentVolume,PV)** 是集群中的一块存储,可以由管理员事先制备,
|
||||
或者使用[存储类(Storage Class)](/zh-cn/docs/concepts/storage/storage-classes/)来动态制备。
|
||||
持久卷是集群资源,就像节点也是集群资源一样。PV 持久卷和普通的 Volume 一样,
|
||||
也是使用卷插件来实现的,只是它们拥有独立于任何使用 PV 的 Pod 的生命周期。
|
||||
此 API 对象中记述了存储的实现细节,无论其背后是 NFS、iSCSI 还是特定于云平台的存储系统。
|
||||
|
||||
<!--
|
||||
A _PersistentVolumeClaim_ (PVC) is a request for storage by a user. It is similar to a Pod. Pods consume node resources and PVCs consume PV resources. Pods can request specific levels of resources (CPU and Memory). Claims can request specific size and access modes (e.g., they can be mounted ReadWriteOnce, ReadOnlyMany or ReadWriteMany, see [AccessModes](#access-modes)).
|
||||
-->
|
||||
持久卷申领(PersistentVolumeClaim,PVC)表达的是用户对存储的请求。概念上与 Pod 类似。
|
||||
**持久卷申领(PersistentVolumeClaim,PVC)** 表达的是用户对存储的请求。概念上与 Pod 类似。
|
||||
Pod 会耗用节点资源,而 PVC 申领会耗用 PV 资源。Pod 可以请求特定数量的资源(CPU
|
||||
和内存);同样 PVC 申领也可以请求特定的大小和访问模式
|
||||
(例如,可以要求 PV 卷能够以 ReadWriteOnce、ReadOnlyMany 或 ReadWriteMany
|
||||
@@ -71,11 +72,11 @@ While PersistentVolumeClaims allow a user to consume abstract storage resources,
|
||||
|
||||
See the [detailed walkthrough with working examples](/docs/tasks/configure-pod-container/configure-persistent-volume-storage/).
|
||||
-->
|
||||
尽管 PersistentVolumeClaim 允许用户消耗抽象的存储资源,常见的情况是针对不同的
|
||||
问题用户需要的是具有不同属性(如,性能)的 PersistentVolume 卷。
|
||||
集群管理员需要能够提供不同性质的 PersistentVolume,并且这些 PV 卷之间的差别不
|
||||
仅限于卷大小和访问模式,同时又不能将卷是如何实现的这些细节暴露给用户。
|
||||
为了满足这类需求,就有了 _存储类(StorageClass)_ 资源。
|
||||
尽管 PersistentVolumeClaim 允许用户消耗抽象的存储资源,
|
||||
常见的情况是针对不同的问题用户需要的是具有不同属性(如,性能)的 PersistentVolume 卷。
|
||||
集群管理员需要能够提供不同性质的 PersistentVolume,
|
||||
并且这些 PV 卷之间的差别不仅限于卷大小和访问模式,同时又不能将卷是如何实现的这些细节暴露给用户。
|
||||
为了满足这类需求,就有了 **存储类(StorageClass)** 资源。
|
||||
|
||||
参见[基于运行示例的详细演练](/zh-cn/docs/tasks/configure-pod-container/configure-persistent-volume-storage/)。
|
||||
|
||||
@@ -93,19 +94,19 @@ There are two ways PVs may be provisioned: statically or dynamically.
|
||||
PV 卷是集群中的资源。PVC 申领是对这些资源的请求,也被用来执行对资源的申领检查。
|
||||
PV 卷和 PVC 申领之间的互动遵循如下生命周期:
|
||||
|
||||
### 供应 {#provisioning}
|
||||
### 制备 {#provisioning}
|
||||
|
||||
PV 卷的供应有两种方式:静态供应或动态供应。
|
||||
PV 卷的制备有两种方式:静态制备或动态制备。
|
||||
|
||||
<!--
|
||||
#### Static
|
||||
|
||||
A cluster administrator creates a number of PVs. They carry the details of the real storage, which is available for use by cluster users. They exist in the Kubernetes API and are available for consumption.
|
||||
-->
|
||||
#### 静态供应 {#static}
|
||||
#### 静态制备 {#static}
|
||||
|
||||
集群管理员创建若干 PV 卷。这些卷对象带有真实存储的细节信息,并且对集群
|
||||
用户可用(可见)。PV 卷对象存在于 Kubernetes API 中,可供用户消费(使用)。
|
||||
集群管理员创建若干 PV 卷。这些卷对象带有真实存储的细节信息,
|
||||
并且对集群用户可用(可见)。PV 卷对象存在于 Kubernetes API 中,可供用户消费(使用)。
|
||||
|
||||
<!--
|
||||
#### Dynamic
|
||||
@@ -118,28 +119,28 @@ the administrator must have created and configured that class for dynamic
|
||||
provisioning to occur. Claims that request the class `""` effectively disable
|
||||
dynamic provisioning for themselves.
|
||||
-->
|
||||
#### 动态供应 {#dynamic}
|
||||
#### 动态制备 {#dynamic}
|
||||
|
||||
如果管理员所创建的所有静态 PV 卷都无法与用户的 PersistentVolumeClaim 匹配,
|
||||
集群可以尝试为该 PVC 申领动态供应一个存储卷。
|
||||
这一供应操作是基于 StorageClass 来实现的:PVC 申领必须请求某个
|
||||
[存储类](/zh-cn/docs/concepts/storage/storage-classes/),同时集群管理员必须
|
||||
已经创建并配置了该类,这样动态供应卷的动作才会发生。
|
||||
如果 PVC 申领指定存储类为 `""`,则相当于为自身禁止使用动态供应的卷。
|
||||
集群可以尝试为该 PVC 申领动态制备一个存储卷。
|
||||
这一制备操作是基于 StorageClass 来实现的:PVC 申领必须请求某个
|
||||
[存储类](/zh-cn/docs/concepts/storage/storage-classes/),
|
||||
同时集群管理员必须已经创建并配置了该类,这样动态制备卷的动作才会发生。
|
||||
如果 PVC 申领指定存储类为 `""`,则相当于为自身禁止使用动态制备的卷。
|
||||
|
||||
<!--
|
||||
To enable dynamic storage provisioning based on storage class, the cluster administrator
|
||||
needs to enable the `DefaultStorageClass` [admission controller](/docs/reference/access-authn-authz/admission-controllers/#defaultstorageclass)
|
||||
on the API server. This can be done, for example, by ensuring that `DefaultStorageClass` is
|
||||
among the comma-delimited, ordered list of values for the `-enable-admission-plugins` flag of
|
||||
among the comma-delimited, ordered list of values for the `--enable-admission-plugins` flag of
|
||||
the API server component. For more information on API server command-line flags,
|
||||
check [kube-apiserver](/docs/admin/kube-apiserver/) documentation.
|
||||
-->
|
||||
为了基于存储类完成动态的存储供应,集群管理员需要在 API 服务器上启用
|
||||
为了基于存储类完成动态的存储制备,集群管理员需要在 API 服务器上启用
|
||||
`DefaultStorageClass` [准入控制器](/zh-cn/docs/reference/access-authn-authz/admission-controllers/#defaultstorageclass)。
|
||||
举例而言,可以通过保证 `DefaultStorageClass` 出现在 API 服务器组件的
|
||||
`--enable-admission-plugins` 标志值中实现这点;该标志的值可以是逗号
|
||||
分隔的有序列表。关于 API 服务器标志的更多信息,可以参考
|
||||
`--enable-admission-plugins` 标志值中实现这点;该标志的值可以是逗号分隔的有序列表。
|
||||
关于 API 服务器标志的更多信息,可以参考
|
||||
[kube-apiserver](/zh-cn/docs/reference/command-line-tools-reference/kube-apiserver/)
|
||||
文档。
|
||||
|
||||
@@ -147,30 +148,28 @@ check [kube-apiserver](/docs/admin/kube-apiserver/) documentation.
|
||||
### Binding
|
||||
|
||||
A user creates, or in the case of dynamic provisioning, has already created, a PersistentVolumeClaim with a specific amount of storage requested and with certain access modes. A control loop in the master watches for new PVCs, finds a matching PV (if possible), and binds them together. If a PV was dynamically provisioned for a new PVC, the loop will always bind that PV to the PVC. Otherwise, the user will always get at least what they asked for, but the volume may be in excess of what was requested. Once bound, PersistentVolumeClaim binds are exclusive, regardless of how they were bound. A PVC to PV binding is a one-to-one mapping, using a ClaimRef which is a bi-directional binding between the PersistentVolume and the PersistentVolumeClaim.
|
||||
|
||||
Claims will remain unbound indefinitely if a matching volume does not exist. Claims will be bound as matching volumes become available. For example, a cluster provisioned with many 50Gi PVs would not match a PVC requesting 100Gi. The PVC can be bound when a 100Gi PV is added to the cluster.
|
||||
-->
|
||||
### 绑定 {#binding}
|
||||
|
||||
用户创建一个带有特定存储容量和特定访问模式需求的 PersistentVolumeClaim 对象;
|
||||
在动态供应场景下,这个 PVC 对象可能已经创建完毕。
|
||||
在动态制备场景下,这个 PVC 对象可能已经创建完毕。
|
||||
主控节点中的控制回路监测新的 PVC 对象,寻找与之匹配的 PV 卷(如果可能的话),
|
||||
并将二者绑定到一起。
|
||||
如果为了新的 PVC 申领动态供应了 PV 卷,则控制回路总是将该 PV 卷绑定到这一 PVC 申领。
|
||||
如果为了新的 PVC 申领动态制备了 PV 卷,则控制回路总是将该 PV 卷绑定到这一 PVC 申领。
|
||||
否则,用户总是能够获得他们所请求的资源,只是所获得的 PV 卷可能会超出所请求的配置。
|
||||
一旦绑定关系建立,则 PersistentVolumeClaim 绑定就是排他性的,无论该 PVC 申领是
|
||||
如何与 PV 卷建立的绑定关系。
|
||||
PVC 申领与 PV 卷之间的绑定是一种一对一的映射,实现上使用 ClaimRef 来记述 PV 卷
|
||||
与 PVC 申领间的双向绑定关系。
|
||||
一旦绑定关系建立,则 PersistentVolumeClaim 绑定就是排他性的,
|
||||
无论该 PVC 申领是如何与 PV 卷建立的绑定关系。
|
||||
PVC 申领与 PV 卷之间的绑定是一种一对一的映射,实现上使用 ClaimRef 来记述
|
||||
PV 卷与 PVC 申领间的双向绑定关系。
|
||||
|
||||
<!--
|
||||
Claims will remain unbound indefinitely if a matching volume does not exist. Claims will be bound as matching volumes become available. For example, a cluster provisioned with many 50Gi PVs would not match a PVC requesting 100Gi. The PVC can be bound when a 100Gi PV is added to the cluster.
|
||||
-->
|
||||
如果找不到匹配的 PV 卷,PVC 申领会无限期地处于未绑定状态。
|
||||
当与之匹配的 PV 卷可用时,PVC 申领会被绑定。
|
||||
例如,即使某集群上供应了很多 50 Gi 大小的 PV 卷,也无法与请求
|
||||
100 Gi 大小的存储的 PVC 匹配。当新的 100 Gi PV 卷被加入到集群时,该
|
||||
PVC 才有可能被绑定。
|
||||
例如,即使某集群上制备了很多 50 Gi 大小的 PV 卷,也无法与请求
|
||||
100 Gi 大小的存储的 PVC 匹配。当新的 100 Gi PV 卷被加入到集群时,
|
||||
该 PVC 才有可能被绑定。
|
||||
|
||||
<!--
|
||||
### Using
|
||||
@@ -179,15 +178,16 @@ Pods use claims as volumes. The cluster inspects the claim to find the bound vol
|
||||
-->
|
||||
### 使用 {#using}
|
||||
|
||||
Pod 将 PVC 申领当做存储卷来使用。集群会检视 PVC 申领,找到所绑定的卷,并
|
||||
为 Pod 挂载该卷。对于支持多种访问模式的卷,用户要在 Pod 中以卷的形式使用申领
|
||||
时指定期望的访问模式。
|
||||
Pod 将 PVC 申领当做存储卷来使用。集群会检视 PVC 申领,找到所绑定的卷,
|
||||
并为 Pod 挂载该卷。对于支持多种访问模式的卷,
|
||||
用户要在 Pod 中以卷的形式使用申领时指定期望的访问模式。
|
||||
|
||||
<!--
|
||||
Once a user has a claim and that claim is bound, the bound PV belongs to the user for as long as they need it. Users schedule Pods and access their claimed PVs by including a `persistentVolumeClaim` section in a Pod's `volumes` block. See [Claims As Volumes](#claims-as-volumes) for more details on this.
|
||||
-->
|
||||
一旦用户有了申领对象并且该申领已经被绑定,则所绑定的 PV 卷在用户仍然需要它期间
|
||||
一直属于该用户。用户通过在 Pod 的 `volumes` 块中包含 `persistentVolumeClaim`
|
||||
一旦用户有了申领对象并且该申领已经被绑定,
|
||||
则所绑定的 PV 卷在用户仍然需要它期间一直属于该用户。
|
||||
用户通过在 Pod 的 `volumes` 块中包含 `persistentVolumeClaim`
|
||||
节区来调度 Pod,访问所申领的 PV 卷。
|
||||
相关细节可参阅[使用申领作为卷](#claims-as-volumes)。
|
||||
|
||||
@@ -198,9 +198,9 @@ The purpose of the Storage Object in Use Protection feature is to ensure that Pe
|
||||
-->
|
||||
### 保护使用中的存储对象 {#storage-object-in-use-protection}
|
||||
|
||||
保护使用中的存储对象(Storage Object in Use Protection)这一功能特性的目的
|
||||
是确保仍被 Pod 使用的 PersistentVolumeClaim(PVC)对象及其所绑定的
|
||||
PersistentVolume(PV)对象在系统中不会被删除,因为这样做可能会引起数据丢失。
|
||||
保护使用中的存储对象(Storage Object in Use Protection)
|
||||
这一功能特性的目的是确保仍被 Pod 使用的 PersistentVolumeClaim(PVC)
|
||||
对象及其所绑定的 PersistentVolume(PV)对象在系统中不会被删除,因为这样做可能会引起数据丢失。
|
||||
|
||||
<!--
|
||||
PVC is in active use by a Pod when a Pod object exists that is using the PVC.
|
||||
@@ -271,11 +271,11 @@ Events: <none>
|
||||
|
||||
When a user is done with their volume, they can delete the PVC objects from the API that allows reclamation of the resource. The reclaim policy for a PersistentVolume tells the cluster what to do with the volume after it has been released of its claim. Currently, volumes can either be Retained, Recycled, or Deleted.
|
||||
-->
|
||||
### 回收 {#reclaiming}
|
||||
### 回收(Reclaiming) {#reclaiming}
|
||||
|
||||
当用户不再使用其存储卷时,他们可以从 API 中将 PVC 对象删除,从而允许
|
||||
该资源被回收再利用。PersistentVolume 对象的回收策略告诉集群,当其被
|
||||
从申领中释放时如何处理该数据卷。
|
||||
当用户不再使用其存储卷时,他们可以从 API 中将 PVC 对象删除,
|
||||
从而允许该资源被回收再利用。PersistentVolume 对象的回收策略告诉集群,
|
||||
当其被从申领中释放时如何处理该数据卷。
|
||||
目前,数据卷可以被 Retained(保留)、Recycled(回收)或 Deleted(删除)。
|
||||
|
||||
<!--
|
||||
@@ -285,8 +285,8 @@ The `Retain` reclaim policy allows for manual reclamation of the resource. When
|
||||
-->
|
||||
#### 保留(Retain) {#retain}
|
||||
|
||||
回收策略 `Retain` 使得用户可以手动回收资源。当 PersistentVolumeClaim 对象
|
||||
被删除时,PersistentVolume 卷仍然存在,对应的数据卷被视为"已释放(released)"。
|
||||
回收策略 `Retain` 使得用户可以手动回收资源。当 PersistentVolumeClaim
|
||||
对象被删除时,PersistentVolume 卷仍然存在,对应的数据卷被视为"已释放(released)"。
|
||||
由于卷上仍然存在这前一申领人的数据,该卷还不能用于其他申领。
|
||||
管理员可以通过下面的步骤来手动回收该卷:
|
||||
|
||||
@@ -314,10 +314,10 @@ For volume plugins that support the `Delete` reclaim policy, deletion removes bo
|
||||
对于支持 `Delete` 回收策略的卷插件,删除动作会将 PersistentVolume 对象从
|
||||
Kubernetes 中移除,同时也会从外部基础设施(如 AWS EBS、GCE PD、Azure Disk 或
|
||||
Cinder 卷)中移除所关联的存储资产。
|
||||
动态供应的卷会继承[其 StorageClass 中设置的回收策略](#reclaim-policy),该策略默认
|
||||
为 `Delete`。
|
||||
管理员需要根据用户的期望来配置 StorageClass;否则 PV 卷被创建之后必须要被
|
||||
编辑或者修补。参阅[更改 PV 卷的回收策略](/zh-cn/docs/tasks/administer-cluster/change-pv-reclaim-policy/).
|
||||
动态制备的卷会继承[其 StorageClass 中设置的回收策略](#reclaim-policy),
|
||||
该策略默认为 `Delete`。管理员需要根据用户的期望来配置 StorageClass;
|
||||
否则 PV 卷被创建之后必须要被编辑或者修补。
|
||||
参阅[更改 PV 卷的回收策略](/zh-cn/docs/tasks/administer-cluster/change-pv-reclaim-policy/).
|
||||
|
||||
<!--
|
||||
#### Recycle
|
||||
@@ -329,11 +329,11 @@ If supported by the underlying volume plugin, the `Recycle` reclaim policy perfo
|
||||
#### 回收(Recycle) {#recycle}
|
||||
|
||||
{{< warning >}}
|
||||
回收策略 `Recycle` 已被废弃。取而代之的建议方案是使用动态供应。
|
||||
回收策略 `Recycle` 已被废弃。取而代之的建议方案是使用动态制备。
|
||||
{{< /warning >}}
|
||||
|
||||
如果下层的卷插件支持,回收策略 `Recycle` 会在卷上执行一些基本的
|
||||
擦除(`rm -rf /thevolume/*`)操作,之后允许该卷用于新的 PVC 申领。
|
||||
如果下层的卷插件支持,回收策略 `Recycle` 会在卷上执行一些基本的擦除
|
||||
(`rm -rf /thevolume/*`)操作,之后允许该卷用于新的 PVC 申领。
|
||||
|
||||
<!--
|
||||
However, an administrator can configure a custom recycler Pod template using
|
||||
@@ -371,8 +371,7 @@ spec:
|
||||
<!--
|
||||
However, the particular path specified in the custom recycler Pod template in the `volumes` part is replaced with the particular path of the volume that is being recycled.
|
||||
-->
|
||||
定制回收器 Pod 模板中在 `volumes` 部分所指定的特定路径要替换为
|
||||
正被回收的卷的路径。
|
||||
定制回收器 Pod 模板中在 `volumes` 部分所指定的特定路径要替换为正被回收的卷的路径。
|
||||
|
||||
<!--
|
||||
### PersistentVolume deletion protection finalizer
|
||||
@@ -383,8 +382,8 @@ having `Delete` reclaim policy are deleted only after the backing storage are de
|
||||
### PersistentVolume 删除保护 finalizer {#persistentvolume-deletion-protection-finalizer}
|
||||
{{< feature-state for_k8s_version="v1.23" state="alpha" >}}
|
||||
|
||||
可以在 PersistentVolume 上添加终结器(Finalizers),以确保只有在删除对应的存储后才删除具有
|
||||
`Delete` 回收策略的 PersistentVolume。
|
||||
可以在 PersistentVolume 上添加终结器(Finalizer),
|
||||
以确保只有在删除对应的存储后才删除具有 `Delete` 回收策略的 PersistentVolume。
|
||||
|
||||
<!--
|
||||
The newly introduced finalizers `kubernetes.io/pv-controller` and `external-provisioner.volume.kubernetes.io/finalizer`
|
||||
@@ -483,9 +482,8 @@ The binding happens regardless of some volume matching criteria, including node
|
||||
The control plane still checks that [storage class](/docs/concepts/storage/storage-classes/), access modes, and requested storage size are valid.
|
||||
-->
|
||||
绑定操作不会考虑某些卷匹配条件是否满足,包括节点亲和性等等。
|
||||
控制面仍然会检查
|
||||
[存储类](/zh-cn/docs/concepts/storage/storage-classes/)、访问模式和所请求的
|
||||
存储尺寸都是合法的。
|
||||
控制面仍然会检查[存储类](/zh-cn/docs/concepts/storage/storage-classes/)、
|
||||
访问模式和所请求的存储尺寸都是合法的。
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
@@ -503,9 +501,9 @@ spec:
|
||||
This method does not guarantee any binding privileges to the PersistentVolume. If other PersistentVolumeClaims could use the PV that you specify, you first need to reserve that storage volume. Specify the relevant PersistentVolumeClaim in the `claimRef` field of the PV so that other PVCs can not bind to it.
|
||||
-->
|
||||
此方法无法对 PersistentVolume 的绑定特权做出任何形式的保证。
|
||||
如果有其他 PersistentVolumeClaim 可以使用你所指定的 PV,则你应该首先预留
|
||||
该存储卷。你可以将 PV 的 `claimRef` 字段设置为相关的 PersistentVolumeClaim
|
||||
以确保其他 PVC 不会绑定到该 PV 卷。
|
||||
如果有其他 PersistentVolumeClaim 可以使用你所指定的 PV,
|
||||
则你应该首先预留该存储卷。你可以将 PV 的 `claimRef` 字段设置为相关的
|
||||
PersistentVolumeClaim 以确保其他 PVC 不会绑定到该 PV 卷。
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
@@ -524,8 +522,8 @@ spec:
|
||||
This is useful if you want to consume PersistentVolumes that have their `claimPolicy` set
|
||||
to `Retain`, including cases where you are reusing an existing PV.
|
||||
-->
|
||||
如果你想要使用 `claimPolicy` 属性设置为 `Retain` 的 PersistentVolume 卷
|
||||
时,包括你希望复用现有的 PV 卷时,这点是很有用的
|
||||
如果你想要使用 `claimPolicy` 属性设置为 `Retain` 的 PersistentVolume 卷时,
|
||||
包括你希望复用现有的 PV 卷时,这点是很有用的
|
||||
|
||||
<!--
|
||||
### Expanding Persistent Volumes Claims
|
||||
@@ -594,8 +592,8 @@ increased and that no resize is necessary.
|
||||
如果对 PersistentVolume 的容量进行编辑,然后又将其所对应的
|
||||
PersistentVolumeClaim 的 `.spec` 进行编辑,使该 PersistentVolumeClaim
|
||||
的大小匹配 PersistentVolume 的话,则不会发生存储大小的调整。
|
||||
Kubernetes 控制平面将看到两个资源的所需状态匹配,并认为其后备卷的大小
|
||||
已被手动增加,无需调整。
|
||||
Kubernetes 控制平面将看到两个资源的所需状态匹配,
|
||||
并认为其后备卷的大小已被手动增加,无需调整。
|
||||
{{< /warning >}}
|
||||
|
||||
<!--
|
||||
@@ -608,8 +606,8 @@ Kubernetes 控制平面将看到两个资源的所需状态匹配,并认为其
|
||||
<!--
|
||||
Support for expanding CSI volumes is enabled by default but it also requires a specific CSI driver to support volume expansion. Refer to documentation of the specific CSI driver for more information.
|
||||
-->
|
||||
对 CSI 卷的扩充能力默认是被启用的,不过扩充 CSI 卷要求 CSI 驱动支持
|
||||
卷扩充操作。可参阅特定 CSI 驱动的文档了解更多信息。
|
||||
对 CSI 卷的扩充能力默认是被启用的,不过扩充 CSI 卷要求 CSI
|
||||
驱动支持卷扩充操作。可参阅特定 CSI 驱动的文档了解更多信息。
|
||||
|
||||
<!--
|
||||
#### Resizing a volume containing a file system
|
||||
@@ -628,13 +626,12 @@ or when a Pod is running and the underlying file system supports online expansio
|
||||
FlexVolumes (deprecated since Kubernetes v1.23) allow resize if the driver is configured with the
|
||||
`RequiresFSResize` capability to `true`. The FlexVolume can be resized on Pod restart.
|
||||
-->
|
||||
当卷中包含文件系统时,只有在 Pod 使用 `ReadWrite` 模式来使用 PVC 申领的
|
||||
情况下才能重设其文件系统的大小。
|
||||
文件系统扩充的操作或者是在 Pod 启动期间完成,或者在下层文件系统支持在线
|
||||
扩充的前提下在 Pod 运行期间完成。
|
||||
当卷中包含文件系统时,只有在 Pod 使用 `ReadWrite` 模式来使用 PVC
|
||||
申领的情况下才能重设其文件系统的大小。文件系统扩充的操作或者是在 Pod
|
||||
启动期间完成,或者在下层文件系统支持在线扩充的前提下在 Pod 运行期间完成。
|
||||
|
||||
如果 FlexVolumes 的驱动将 `RequiresFSResize` 能力设置为 `true`,则该
|
||||
FlexVolume 卷(于 Kubernetes v1.23 弃用)可以在 Pod 重启期间调整大小。
|
||||
如果 FlexVolumes 的驱动将 `RequiresFSResize` 能力设置为 `true`,
|
||||
则该 FlexVolume 卷(于 Kubernetes v1.23 弃用)可以在 Pod 重启期间调整大小。
|
||||
|
||||
<!--
|
||||
#### Resizing an in-use PersistentVolumeClaim
|
||||
@@ -691,9 +688,9 @@ If a user specifies a new size that is too big to be satisfied by underlying sto
|
||||
<!--
|
||||
If expanding underlying storage fails, the cluster administrator can manually recover the Persistent Volume Claim (PVC) state and cancel the resize requests. Otherwise, the resize requests are continuously retried by the controller without administrator intervention.
|
||||
-->
|
||||
如果扩充下层存储的操作失败,集群管理员可以手动地恢复 PVC 申领的状态并
|
||||
取消重设大小的请求。否则,在没有管理员干预的情况下,控制器会反复重试
|
||||
重设大小的操作。
|
||||
如果扩充下层存储的操作失败,集群管理员可以手动地恢复 PVC
|
||||
申领的状态并取消重设大小的请求。否则,在没有管理员干预的情况下,
|
||||
控制器会反复重试重设大小的操作。
|
||||
|
||||
<!--
|
||||
1. Mark the PersistentVolume(PV) that is bound to the PersistentVolumeClaim(PVC) with `Retain` reclaim policy.
|
||||
@@ -702,7 +699,7 @@ If expanding underlying storage fails, the cluster administrator can manually re
|
||||
4. Re-create the PVC with smaller size than PV and set `volumeName` field of the PVC to the name of the PV. This should bind new PVC to existing PV.
|
||||
5. Don't forget to restore the reclaim policy of the PV.
|
||||
-->
|
||||
1. 将绑定到 PVC 申领的 PV 卷标记为 `Retain` 回收策略;
|
||||
1. 将绑定到 PVC 申领的 PV 卷标记为 `Retain` 回收策略。
|
||||
2. 删除 PVC 对象。由于 PV 的回收策略为 `Retain`,我们不会在重建 PVC 时丢失数据。
|
||||
3. 删除 PV 规约中的 `claimRef` 项,这样新的 PVC 可以绑定到该卷。
|
||||
这一操作会使得 PV 卷变为 "可用(Available)"。
|
||||
@@ -736,12 +733,12 @@ size that is within the capacity limits of underlying storage provider. You can
|
||||
-->
|
||||
如果集群中的特性门控 `RecoverVolumeExpansionFailure`
|
||||
已启用,在 PVC 的扩展发生失败时,你可以使用比先前请求的值更小的尺寸来重试扩展。
|
||||
要使用一个更小的尺寸尝试请求新的扩展,请编辑该 PVC 的 `.spec.resources` 并选择
|
||||
一个比你之前所尝试的值更小的值。
|
||||
要使用一个更小的尺寸尝试请求新的扩展,请编辑该 PVC 的 `.spec.resources`
|
||||
并选择一个比你之前所尝试的值更小的值。
|
||||
如果由于容量限制而无法成功扩展至更高的值,这将很有用。
|
||||
如果发生了这种情况,或者你怀疑可能发生了这种情况,你可以通过指定一个在底层存储供应容量
|
||||
限制内的尺寸来重试扩展。你可以通过查看 `.status.resizeStatus` 以及 PVC 上的事件
|
||||
来监控调整大小操作的状态。
|
||||
如果发生了这种情况,或者你怀疑可能发生了这种情况,
|
||||
你可以通过指定一个在底层存储制备容量限制内的尺寸来重试扩展。
|
||||
你可以通过查看 `.status.resizeStatus` 以及 PVC 上的事件来监控调整大小操作的状态。
|
||||
|
||||
<!--
|
||||
Note that,
|
||||
@@ -796,8 +793,7 @@ PV 持久卷是用插件的形式来实现的。Kubernetes 目前支持以下插
|
||||
* [`gcePersistentDisk`](/zh-cn/docs/concepts/storage/volumes/#gcepersistentdisk) - GCE 持久化盘
|
||||
* [`glusterfs`](/zh-cn/docs/concepts/storage/volumes/#glusterfs) - Glusterfs 卷
|
||||
* [`hostPath`](/zh-cn/docs/concepts/storage/volumes/#hostpath) - HostPath 卷
|
||||
(仅供单节点测试使用;不适用于多节点集群;
|
||||
请尝试使用 `local` 卷作为替代)
|
||||
(仅供单节点测试使用;不适用于多节点集群;请尝试使用 `local` 卷作为替代)
|
||||
* [`iscsi`](/zh-cn/docs/concepts/storage/volumes/#iscsi) - iSCSI (SCSI over IP) 存储
|
||||
* [`local`](/zh-cn/docs/concepts/storage/volumes/#local) - 节点上挂载的本地存储设备
|
||||
* [`nfs`](/zh-cn/docs/concepts/storage/volumes/#nfs) - 网络文件系统 (NFS) 存储
|
||||
@@ -889,7 +885,7 @@ Helper programs relating to the volume type may be required for consumption of a
|
||||
<!--
|
||||
### Capacity
|
||||
|
||||
Generally, a PV will have a specific storage capacity. This is set using the PV's `capacity` attribute. Read the glossary term [Quantity](/docs/reference/glossary/?all=true#term-quantity) to understand the units expected by `capacity`.
|
||||
Generally, a PV will have a specific storage capacity. This is set using the PV's `capacity` attribute. Read the glossary term [Quantity](/docs/reference/glossary/?all=true#term-quantity) to understand the units expected by `capacity`.
|
||||
|
||||
Currently, storage size is the only resource that can be set or requested. Future attributes may include IOPS, throughput, etc.
|
||||
-->
|
||||
@@ -897,8 +893,7 @@ Currently, storage size is the only resource that can be set or requested. Futu
|
||||
|
||||
一般而言,每个 PV 卷都有确定的存储容量。
|
||||
容量属性是使用 PV 对象的 `capacity` 属性来设置的。
|
||||
参考词汇表中的
|
||||
[量纲(Quantity)](/zh-cn/docs/reference/glossary/?all=true#term-quantity)
|
||||
参考词汇表中的[量纲(Quantity)](/zh-cn/docs/reference/glossary/?all=true#term-quantity)
|
||||
词条,了解 `capacity` 字段可以接受的单位。
|
||||
|
||||
目前,存储大小是可以设置和请求的唯一资源。
|
||||
@@ -954,11 +949,9 @@ A PersistentVolume can be mounted on a host in any way supported by the resource
|
||||
### 访问模式 {#access-modes}
|
||||
|
||||
PersistentVolume 卷可以用资源提供者所支持的任何方式挂载到宿主系统上。
|
||||
如下表所示,提供者(驱动)的能力不同,每个 PV 卷的访问模式都会设置为
|
||||
对应卷所支持的模式值。
|
||||
例如,NFS 可以支持多个读写客户,但是某个特定的 NFS PV 卷可能在服务器
|
||||
上以只读的方式导出。每个 PV 卷都会获得自身的访问模式集合,描述的是
|
||||
特定 PV 卷的能力。
|
||||
如下表所示,提供者(驱动)的能力不同,每个 PV 卷的访问模式都会设置为对应卷所支持的模式值。
|
||||
例如,NFS 可以支持多个读写客户,但是某个特定的 NFS PV 卷可能在服务器上以只读的方式导出。
|
||||
每个 PV 卷都会获得自身的访问模式集合,描述的是特定 PV 卷的能力。
|
||||
|
||||
<!--
|
||||
The access modes are:
|
||||
@@ -992,7 +985,7 @@ ReadWriteOnce 访问模式也允许运行在同一节点上的多个 Pod 访问
|
||||
`ReadWriteOncePod`
|
||||
: 卷可以被单个 Pod 以读写方式挂载。
|
||||
如果你想确保整个集群中只有一个 Pod 可以读取或写入该 PVC,
|
||||
请使用ReadWriteOncePod 访问模式。这只支持 CSI 卷以及需要 Kubernetes 1.22 以上版本。
|
||||
请使用 ReadWriteOncePod 访问模式。这只支持 CSI 卷以及需要 Kubernetes 1.22 以上版本。
|
||||
|
||||
这篇博客文章 [Introducing Single Pod Access Mode for PersistentVolumes](/blog/2021/09/13/read-write-once-pod-access-mode-alpha/)
|
||||
描述了更详细的内容。
|
||||
@@ -1032,10 +1025,9 @@ Kubernetes 使用卷访问模式来匹配 PersistentVolumeClaim 和 PersistentVo
|
||||
<!--
|
||||
> __Important!__ A volume can only be mounted using one access mode at a time, even if it supports many. For example, a GCEPersistentDisk can be mounted as ReadWriteOnce by a single node or ReadOnlyMany by many nodes, but not at the same time.
|
||||
-->
|
||||
> __重要提醒!__ 每个卷同一时刻只能以一种访问模式挂载,即使该卷能够支持
|
||||
> 多种访问模式。例如,一个 GCEPersistentDisk 卷可以被某节点以 ReadWriteOnce
|
||||
> 模式挂载,或者被多个节点以 ReadOnlyMany 模式挂载,但不可以同时以两种模式
|
||||
> 挂载。
|
||||
> **重要提醒!** 每个卷同一时刻只能以一种访问模式挂载,即使该卷能够支持多种访问模式。
|
||||
> 例如,一个 GCEPersistentDisk 卷可以被某节点以 ReadWriteOnce
|
||||
> 模式挂载,或者被多个节点以 ReadOnlyMany 模式挂载,但不可以同时以两种模式挂载。
|
||||
|
||||
<!--
|
||||
| Volume Plugin | ReadWriteOnce | ReadOnlyMany | ReadWriteMany|
|
||||
@@ -1078,8 +1070,7 @@ to PVCs that request no particular class.
|
||||
每个 PV 可以属于某个类(Class),通过将其 `storageClassName` 属性设置为某个
|
||||
[StorageClass](/zh-cn/docs/concepts/storage/storage-classes/) 的名称来指定。
|
||||
特定类的 PV 卷只能绑定到请求该类存储卷的 PVC 申领。
|
||||
未设置 `storageClassName` 的 PV 卷没有类设定,只能绑定到那些没有指定特定
|
||||
存储类的 PVC 申领。
|
||||
未设置 `storageClassName` 的 PV 卷没有类设定,只能绑定到那些没有指定特定存储类的 PVC 申领。
|
||||
|
||||
<!--
|
||||
In the past, the annotation `volume.beta.kubernetes.io/storage-class` was used instead
|
||||
@@ -1167,6 +1158,17 @@ it will become fully deprecated in a future Kubernetes release.
|
||||
-->
|
||||
### 节点亲和性 {#node-affinity}
|
||||
|
||||
<!--
|
||||
For most volume types, you do not need to set this field. It is automatically populated for [AWS EBS](/docs/concepts/storage/volumes/#awselasticblockstore), [GCE PD](/docs/concepts/storage/volumes/#gcepersistentdisk) and [Azure Disk](/docs/concepts/storage/volumes/#azuredisk) volume block types. You need to explicitly set this for [local](/docs/concepts/storage/volumes/#local) volumes.
|
||||
-->
|
||||
{{< note >}}
|
||||
对大多数类型的卷而言,你不需要设置节点亲和性字段。
|
||||
[AWS EBS](/zh-cn/docs/concepts/storage/volumes/#awselasticblockstore)、
|
||||
[GCE PD](/zh-cn/docs/concepts/storage/volumes/#gcepersistentdisk) 和
|
||||
[Azure Disk](/zh-cn/docs/concepts/storage/volumes/#azuredisk) 卷类型都能自动设置相关字段。
|
||||
你需要为 [local](/zh-cn/docs/concepts/storage/volumes/#local) 卷显式地设置此属性。
|
||||
{{< /note >}}
|
||||
|
||||
<!--
|
||||
A PV can specify node affinity to define constraints that limit what nodes this volume can be accessed from. Pods that use a PV will only be scheduled to nodes that are selected by the node affinity. To specify node affinity, set `nodeAffinity` in the `.spec` of a PV. The [PersistentVolume](/docs/reference/kubernetes-api/config-and-storage-resources/persistent-volume-v1/#PersistentVolumeSpec) API reference has more details on this field.
|
||||
-->
|
||||
@@ -1176,19 +1178,6 @@ A PV can specify node affinity to define constraints that limit what nodes this
|
||||
[持久卷](/docs/reference/kubernetes-api/config-and-storage-resources/persistent-volume-v1/#PersistentVolumeSpec)
|
||||
API 参考关于该字段的更多细节。
|
||||
|
||||
<!--
|
||||
For most volume types, you do not need to set this field. It is automatically populated for [AWS EBS](/docs/concepts/storage/volumes/#awselasticblockstore), [GCE PD](/docs/concepts/storage/volumes/#gcepersistentdisk) and [Azure Disk](/docs/concepts/storage/volumes/#azuredisk) volume block types. You need to explicitly set this for [local](/docs/concepts/storage/volumes/#local) volumes.
|
||||
-->
|
||||
{{< note >}}
|
||||
对大多数类型的卷而言,你不需要设置节点亲和性字段。
|
||||
[AWS EBS](/zh-cn/docs/concepts/storage/volumes/#awselasticblockstore)、
|
||||
[GCE PD](/zh-cn/docs/concepts/storage/volumes/#gcepersistentdisk) 和
|
||||
[Azure Disk](/zh-cn/docs/concepts/storage/volumes/#azuredisk) 卷类型都能
|
||||
自动设置相关字段。
|
||||
你需要为 [local](/zh-cn/docs/concepts/storage/volumes/#local) 卷显式地设置
|
||||
此属性。
|
||||
{{< /note >}}
|
||||
|
||||
<!--
|
||||
### Phase
|
||||
|
||||
@@ -1223,7 +1212,6 @@ The name of a PersistentVolumeClaim object must be a valid
|
||||
PersistentVolumeClaim 对象的名称必须是合法的
|
||||
[DNS 子域名](/zh-cn/docs/concepts/overview/working-with-objects/names#dns-subdomain-names).
|
||||
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
@@ -1265,13 +1253,13 @@ Claims use [the same convention as volumes](#volume-mode) to indicate the consum
|
||||
<!--
|
||||
### Resources
|
||||
|
||||
Claims, like Pods, can request specific quantities of a resource. In this case, the request is for storage. The same [resource model](https://git.k8s.io/community/contributors/design-proposals/scheduling/resources.md) applies to both volumes and claims.
|
||||
Claims, like Pods, can request specific quantities of a resource. In this case, the request is for storage. The same [resource model](https://git.k8s.io/design-proposals-archive/scheduling/resources.md) applies to both volumes and claims.
|
||||
-->
|
||||
### 资源 {#resources}
|
||||
|
||||
申领和 Pod 一样,也可以请求特定数量的资源。在这个上下文中,请求的资源是存储。
|
||||
卷和申领都使用相同的
|
||||
[资源模型](https://git.k8s.io/community/contributors/design-proposals/scheduling/resources.md)。
|
||||
[资源模型](https://git.k8s.io/design-proposals-archive/scheduling/resources.md)。
|
||||
|
||||
<!--
|
||||
### Selector
|
||||
@@ -1323,10 +1311,10 @@ by the cluster, depending on whether the
|
||||
is turned on.
|
||||
-->
|
||||
PVC 申领不必一定要请求某个类。如果 PVC 的 `storageClassName` 属性值设置为 `""`,
|
||||
则被视为要请求的是没有设置存储类的 PV 卷,因此这一 PVC 申领只能绑定到未设置
|
||||
存储类的 PV 卷(未设置注解或者注解值为 `""` 的 PersistentVolume(PV)对象在系统中不会被删除,因为这样做可能会引起数据丢失。
|
||||
未设置 `storageClassName` 的 PVC 与此大不相同,也会被集群作不同处理。
|
||||
具体筛查方式取决于
|
||||
则被视为要请求的是没有设置存储类的 PV 卷,因此这一 PVC 申领只能绑定到未设置存储类的
|
||||
PV 卷(未设置注解或者注解值为 `""` 的 PersistentVolume(PV)对象在系统中不会被删除,
|
||||
因为这样做可能会引起数据丢失。未设置 `storageClassName` 的 PVC 与此大不相同,
|
||||
也会被集群作不同处理。具体筛查方式取决于
|
||||
[`DefaultStorageClass` 准入控制器插件](/zh-cn/docs/reference/access-authn-authz/admission-controllers/#defaultstorageclass)
|
||||
是否被启用。
|
||||
|
||||
@@ -1348,11 +1336,11 @@ PVC 申领不必一定要请求某个类。如果 PVC 的 `storageClassName` 属
|
||||
所有未设置 `storageClassName` 的 PVC 都只能绑定到隶属于默认存储类的 PV 卷。
|
||||
设置默认 StorageClass 的工作是通过将对应 StorageClass 对象的注解
|
||||
`storageclass.kubernetes.io/is-default-class` 赋值为 `true` 来完成的。
|
||||
如果管理员未设置默认存储类,集群对 PVC 创建的处理方式与未启用准入控制器插件
|
||||
时相同。如果设定的默认存储类不止一个,准入控制插件会禁止所有创建 PVC 操作。
|
||||
如果管理员未设置默认存储类,集群对 PVC 创建的处理方式与未启用准入控制器插件时相同。
|
||||
如果设定的默认存储类不止一个,准入控制插件会禁止所有创建 PVC 操作。
|
||||
* 如果准入控制器插件被关闭,则不存在默认 StorageClass 的说法。
|
||||
所有未设置 `storageClassName` 的 PVC 都只能绑定到未设置存储类的 PV 卷。
|
||||
在这种情况下,未设置 `storageClassName` 的 PVC 与 `storageClassName` 设置未
|
||||
在这种情况下,未设置 `storageClassName` 的 PVC 与 `storageClassName` 设置为
|
||||
`""` 的 PVC 的处理方式相同。
|
||||
|
||||
<!--
|
||||
@@ -1366,14 +1354,14 @@ the requested labels may be bound to the PVC.
|
||||
取决于安装方法,默认的 StorageClass 可能在集群安装期间由插件管理器(Addon
|
||||
Manager)部署到集群中。
|
||||
|
||||
当某 PVC 除了请求 StorageClass 之外还设置了 `selector`,则这两种需求会按
|
||||
逻辑与关系处理:只有隶属于所请求类且带有所请求标签的 PV 才能绑定到 PVC。
|
||||
当某 PVC 除了请求 StorageClass 之外还设置了 `selector`,则这两种需求会按逻辑与关系处理:
|
||||
只有隶属于所请求类且带有所请求标签的 PV 才能绑定到 PVC。
|
||||
|
||||
<!--
|
||||
Currently, a PVC with a non-empty `selector` can't have a PV dynamically provisioned for it.
|
||||
-->
|
||||
{{< note >}}
|
||||
目前,设置了非空 `selector` 的 PVC 对象无法让集群为其动态供应 PV 卷。
|
||||
目前,设置了非空 `selector` 的 PVC 对象无法让集群为其动态制备 PV 卷。
|
||||
{{< /note >}}
|
||||
|
||||
<!--
|
||||
@@ -1448,7 +1436,7 @@ See [an example of `hostPath` typed volume](/docs/tasks/configure-pod-container/
|
||||
The following volume plugins support raw block volumes, including dynamic provisioning where
|
||||
applicable:
|
||||
-->
|
||||
以下卷插件支持原始块卷,包括其动态供应(如果支持的话)的卷:
|
||||
以下卷插件支持原始块卷,包括其动态制备(如果支持的话)的卷:
|
||||
|
||||
* AWSElasticBlockStore
|
||||
* AzureDisk
|
||||
@@ -1502,9 +1490,158 @@ spec:
|
||||
requests:
|
||||
storage: 10Gi
|
||||
```
|
||||
<!--
|
||||
### Pod specification adding Raw Block Device path in container
|
||||
-->
|
||||
### 在容器中添加原始块设备路径的 Pod 规约 {#pod-spec-adding-raw-block-device-path-in-container}
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: pod-with-block-volume
|
||||
spec:
|
||||
containers:
|
||||
- name: fc-container
|
||||
image: fedora:26
|
||||
command: ["/bin/sh", "-c"]
|
||||
args: [ "tail -f /dev/null" ]
|
||||
volumeDevices:
|
||||
- name: data
|
||||
devicePath: /dev/xvda
|
||||
volumes:
|
||||
- name: data
|
||||
persistentVolumeClaim:
|
||||
claimName: block-pvc
|
||||
```
|
||||
|
||||
<!--
|
||||
When adding a raw block device for a Pod, you specify the device path in the container instead of a mount path.
|
||||
-->
|
||||
{{< note >}}
|
||||
向 Pod 中添加原始块设备时,你要在容器内设置设备路径而不是挂载路径。
|
||||
{{< /note >}}
|
||||
|
||||
<!--
|
||||
### Binding Block Volumes
|
||||
|
||||
If a user requests a raw block volume by indicating this using the `volumeMode` field in the PersistentVolumeClaim spec, the binding rules differ slightly from previous releases that didn't consider this mode as part of the spec.
|
||||
Listed is a table of possible combinations the user and admin might specify for requesting a raw block device. The table indicates if the volume will be bound or not given the combinations:
|
||||
Volume binding matrix for statically provisioned volumes:
|
||||
-->
|
||||
### 绑定块卷 {#binding-block-volumes}
|
||||
|
||||
如果用户通过 PersistentVolumeClaim 规约的 `volumeMode` 字段来表明对原始块设备的请求,
|
||||
绑定规则与之前版本中未在规约中考虑此模式的实现略有不同。
|
||||
下面列举的表格是用户和管理员可以为请求原始块设备所作设置的组合。
|
||||
此表格表明在不同的组合下卷是否会被绑定。
|
||||
|
||||
静态制备卷的卷绑定矩阵:
|
||||
|
||||
<!--
|
||||
| PV volumeMode | PVC volumeMode | Result |
|
||||
| --------------|:---------------:| ----------------:|
|
||||
| unspecified | unspecified | BIND |
|
||||
| unspecified | Block | NO BIND |
|
||||
| unspecified | Filesystem | BIND |
|
||||
| Block | unspecified | NO BIND |
|
||||
| Block | Block | BIND |
|
||||
| Block | Filesystem | NO BIND |
|
||||
| Filesystem | Filesystem | BIND |
|
||||
| Filesystem | Block | NO BIND |
|
||||
| Filesystem | unspecified | BIND |
|
||||
-->
|
||||
| PV volumeMode | PVC volumeMode | Result |
|
||||
| --------------|:---------------:| ----------------:|
|
||||
| 未指定 | 未指定 | 绑定 |
|
||||
| 未指定 | Block | 不绑定 |
|
||||
| 未指定 | Filesystem | 绑定 |
|
||||
| Block | 未指定 | 不绑定 |
|
||||
| Block | Block | 绑定 |
|
||||
| Block | Filesystem | 不绑定 |
|
||||
| Filesystem | Filesystem | 绑定 |
|
||||
| Filesystem | Block | 不绑定 |
|
||||
| Filesystem | 未指定 | 绑定 |
|
||||
|
||||
<!--
|
||||
Only statically provisioned volumes are supported for alpha release. Administrators should take care to consider these values when working with raw block devices.
|
||||
-->
|
||||
{{< note >}}
|
||||
Alpha 发行版本中仅支持静态制备的卷。
|
||||
管理员需要在处理原始块设备时小心处理这些值。
|
||||
{{< /note >}}
|
||||
|
||||
<!--
|
||||
## Volume Snapshot and Restore Volume from Snapshot Support
|
||||
-->
|
||||
## 对卷快照及从卷快照中恢复卷的支持 {#volume-snapshot-and-restore-volume-from-snapshot-support}
|
||||
|
||||
{{< feature-state for_k8s_version="v1.20" state="stable" >}}
|
||||
|
||||
<!--
|
||||
Volume snapshots only support the out-of-tree CSI volume plugins. For details, see [Volume Snapshots](/docs/concepts/storage/volume-snapshots/).
|
||||
In-tree volume plugins are deprecated. You can read about the deprecated volume plugins in the [Volume Plugin FAQ](https://github.com/kubernetes/community/blob/master/sig-storage/volume-plugin-faq.md).
|
||||
-->
|
||||
卷快照(Volume Snapshot)仅支持树外 CSI 卷插件。
|
||||
有关细节可参阅[卷快照](/zh-cn/docs/concepts/storage/volume-snapshots/)文档。
|
||||
树内卷插件被弃用。你可以查阅[卷插件 FAQ](https://git.k8s.io/community/sig-storage/volume-plugin-faq.md)
|
||||
了解已弃用的卷插件。
|
||||
|
||||
<!--
|
||||
### Create a PersistentVolumeClaim from a Volume Snapshot {#create-persistent-volume-claim-from-volume-snapshot}
|
||||
-->
|
||||
### 基于卷快照创建 PVC 申领 {#create-persistent-volume-claim-from-volume-snapshot}
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: restore-pvc
|
||||
spec:
|
||||
storageClassName: csi-hostpath-sc
|
||||
dataSource:
|
||||
name: new-snapshot-test
|
||||
kind: VolumeSnapshot
|
||||
apiGroup: snapshot.storage.k8s.io
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 10Gi
|
||||
```
|
||||
|
||||
<!--
|
||||
## Volume Cloning
|
||||
|
||||
[Volume Cloning](/docs/concepts/storage/volume-pvc-datasource/) only available for CSI volume plugins.
|
||||
-->
|
||||
## 卷克隆 {#volume-cloning}
|
||||
|
||||
[卷克隆](/zh-cn/docs/concepts/storage/volume-pvc-datasource/)功能特性仅适用于 CSI 卷插件。
|
||||
|
||||
<!--
|
||||
### Create PersistentVolumeClaim from an existing PVC {#create-persistent-volume-claim-from-an-existing-pvc}
|
||||
-->
|
||||
### 基于现有 PVC 创建新的 PVC 申领 {#create-persistent-volume-claim-from-an-existing-pvc}
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: cloned-pvc
|
||||
spec:
|
||||
storageClassName: my-csi-plugin
|
||||
dataSource:
|
||||
name: existing-src-pvc-name
|
||||
kind: PersistentVolumeClaim
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 10Gi
|
||||
```
|
||||
|
||||
<!--
|
||||
## Volume populators and data sources
|
||||
|
||||
Kubernetes supports custom volume populators.
|
||||
@@ -1523,11 +1660,9 @@ gate enabled, use of the `dataSourceRef` is preferred over `dataSource`.
|
||||
|
||||
{{< feature-state for_k8s_version="v1.24" state="beta" >}}
|
||||
|
||||
{{< note >}}
|
||||
Kubernetes 支持自定义的卷填充器;要使用自定义的卷填充器,你必须为
|
||||
Kubernetes 支持自定义的卷填充器。要使用自定义的卷填充器,你必须为
|
||||
kube-apiserver 和 kube-controller-manager 启用 `AnyVolumeDataSource`
|
||||
[特性门控](/zh-cn/docs/reference/command-line-tools-reference/feature-gates/)。
|
||||
{{< /note >}}
|
||||
|
||||
卷填充器利用了 PVC 规约字段 `dataSourceRef`。
|
||||
不像 `dataSource` 字段只能包含对另一个持久卷申领或卷快照的引用,
|
||||
@@ -1554,6 +1689,7 @@ contents.
|
||||
<!--
|
||||
There are two differences between the `dataSourceRef` field and the `dataSource` field that
|
||||
users should be aware of:
|
||||
|
||||
* The `dataSource` field ignores invalid values (as if the field was blank) while the
|
||||
`dataSourceRef` field never ignores values and will cause an error if an invalid value is
|
||||
used. Invalid values are any core object (objects with no apiGroup) except for PVCs.
|
||||
@@ -1567,6 +1703,7 @@ backwards compatibility. In particular, a mixture of older and newer controllers
|
||||
interoperate because the fields are the same.
|
||||
-->
|
||||
在 `dataSourceRef` 字段和 `dataSource` 字段之间有两个用户应该注意的区别:
|
||||
|
||||
* `dataSource` 字段会忽略无效的值(如同是空值),
|
||||
而 `dataSourceRef` 字段永远不会忽略值,并且若填入一个无效的值,会导致错误。
|
||||
无效值指的是 PVC 之外的核心对象(没有 apiGroup 的对象)。
|
||||
@@ -1627,161 +1764,6 @@ the process.
|
||||
如果没有填充器处理该数据源的情况下,该控制器会在 PVC 上产生警告事件。
|
||||
当一个合适的填充器被安装到 PVC 上时,该控制器的职责是上报与卷创建有关的事件,以及在该过程中发生的问题。
|
||||
|
||||
<!--
|
||||
### Pod specification adding Raw Block Device path in container
|
||||
-->
|
||||
### 在容器中添加原始块设备路径的 Pod 规约
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: pod-with-block-volume
|
||||
spec:
|
||||
containers:
|
||||
- name: fc-container
|
||||
image: fedora:26
|
||||
command: ["/bin/sh", "-c"]
|
||||
args: [ "tail -f /dev/null" ]
|
||||
volumeDevices:
|
||||
- name: data
|
||||
devicePath: /dev/xvda
|
||||
volumes:
|
||||
- name: data
|
||||
persistentVolumeClaim:
|
||||
claimName: block-pvc
|
||||
```
|
||||
|
||||
<!--
|
||||
When adding a raw block device for a Pod, you specify the device path in the container instead of a mount path.
|
||||
-->
|
||||
{{< note >}}
|
||||
向 Pod 中添加原始块设备时,你要在容器内设置设备路径而不是挂载路径。
|
||||
{{< /note >}}
|
||||
|
||||
<!--
|
||||
### Binding Block Volumes
|
||||
|
||||
If a user requests a raw block volume by indicating this using the `volumeMode` field in the PersistentVolumeClaim spec, the binding rules differ slightly from previous releases that didn't consider this mode as part of the spec.
|
||||
Listed is a table of possible combinations the user and admin might specify for requesting a raw block device. The table indicates if the volume will be bound or not given the combinations:
|
||||
Volume binding matrix for statically provisioned volumes:
|
||||
-->
|
||||
### 绑定块卷 {#binding-block-volumes}
|
||||
|
||||
如果用户通过 PersistentVolumeClaim 规约的 `volumeMode` 字段来表明对原始
|
||||
块设备的请求,绑定规则与之前版本中未在规约中考虑此模式的实现略有不同。
|
||||
下面列举的表格是用户和管理员可以为请求原始块设备所作设置的组合。
|
||||
此表格表明在不同的组合下卷是否会被绑定。
|
||||
|
||||
静态供应卷的卷绑定矩阵:
|
||||
|
||||
<!--
|
||||
| PV volumeMode | PVC volumeMode | Result |
|
||||
| --------------|:---------------:| ----------------:|
|
||||
| unspecified | unspecified | BIND |
|
||||
| unspecified | Block | NO BIND |
|
||||
| unspecified | Filesystem | BIND |
|
||||
| Block | unspecified | NO BIND |
|
||||
| Block | Block | BIND |
|
||||
| Block | Filesystem | NO BIND |
|
||||
| Filesystem | Filesystem | BIND |
|
||||
| Filesystem | Block | NO BIND |
|
||||
| Filesystem | unspecified | BIND |
|
||||
-->
|
||||
| PV volumeMode | PVC volumeMode | Result |
|
||||
| --------------|:---------------:| ----------------:|
|
||||
| 未指定 | 未指定 | 绑定 |
|
||||
| 未指定 | Block | 不绑定 |
|
||||
| 未指定 | Filesystem | 绑定 |
|
||||
| Block | 未指定 | 不绑定 |
|
||||
| Block | Block | 绑定 |
|
||||
| Block | Filesystem | 不绑定 |
|
||||
| Filesystem | Filesystem | 绑定 |
|
||||
| Filesystem | Block | 不绑定 |
|
||||
| Filesystem | 未指定 | 绑定 |
|
||||
|
||||
<!--
|
||||
Only statically provisioned volumes are supported for alpha release. Administrators should take care to consider these values when working with raw block devices.
|
||||
-->
|
||||
{{< note >}}
|
||||
Alpha 发行版本中仅支持静态供应的卷。
|
||||
管理员需要在处理原始块设备时小心处理这些值。
|
||||
{{< /note >}}
|
||||
|
||||
<!--
|
||||
## Volume Snapshot and Restore Volume from Snapshot Support
|
||||
-->
|
||||
## 对卷快照及从卷快照中恢复卷的支持
|
||||
|
||||
{{< feature-state for_k8s_version="v1.17" state="beta" >}}
|
||||
|
||||
<!--
|
||||
Volume snapshot feature was added to support CSI Volume Plugins only. For details, see [volume snapshots](/docs/concepts/storage/volume-snapshots/).
|
||||
|
||||
To enable support for restoring a volume from a volume snapshot data source, enable the
|
||||
`VolumeSnapshotDataSource` feature gate on the apiserver and controller-manager.
|
||||
-->
|
||||
卷快照(Volume Snapshot)特性的添加仅是为了支持 CSI 卷插件。
|
||||
有关细节可参阅[卷快照](/zh-cn/docs/concepts/storage/volume-snapshots/)文档。
|
||||
|
||||
要启用从卷快照数据源恢复数据卷的支持,可在 API 服务器和控制器管理器上启用
|
||||
`VolumeSnapshotDataSource` 特性门控。
|
||||
|
||||
<!--
|
||||
### Create a PersistentVolumeClaim from a Volume Snapshot {#create-persistent-volume-claim-from-volume-snapshot}
|
||||
-->
|
||||
### 基于卷快照创建 PVC 申领 {#create-persistent-volume-claim-from-volume-snapshot}
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: restore-pvc
|
||||
spec:
|
||||
storageClassName: csi-hostpath-sc
|
||||
dataSource:
|
||||
name: new-snapshot-test
|
||||
kind: VolumeSnapshot
|
||||
apiGroup: snapshot.storage.k8s.io
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 10Gi
|
||||
```
|
||||
|
||||
<!--
|
||||
## Volume Cloning
|
||||
|
||||
[Volume Cloning](/docs/concepts/storage/volume-pvc-datasource/) only available for CSI volume plugins.
|
||||
-->
|
||||
## 卷克隆 {#volume-cloning}
|
||||
|
||||
[卷克隆](/zh-cn/docs/concepts/storage/volume-pvc-datasource/)功能特性仅适用于
|
||||
CSI 卷插件。
|
||||
|
||||
<!--
|
||||
### Create PersistentVolumeClaim from an existing PVC {#create-persistent-volume-claim-from-an-existing-pvc}
|
||||
-->
|
||||
### 基于现有 PVC 创建新的 PVC 申领 {#create-persistent-volume-claim-from-an-existing-pvc}
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: cloned-pvc
|
||||
spec:
|
||||
storageClassName: my-csi-plugin
|
||||
dataSource:
|
||||
name: existing-src-pvc-name
|
||||
kind: PersistentVolumeClaim
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 10Gi
|
||||
```
|
||||
|
||||
<!--
|
||||
## Writing Portable Configuration
|
||||
|
||||
@@ -1802,6 +1784,7 @@ and need persistent storage, it is recommended that you use the following patter
|
||||
以及 ConfigMap 等放在一起。
|
||||
- 不要在配置中包含 PersistentVolume 对象,因为对配置进行实例化的用户很可能
|
||||
没有创建 PersistentVolume 的权限。
|
||||
|
||||
<!--
|
||||
- Give the user the option of providing a storage class name when instantiating
|
||||
the template.
|
||||
@@ -1819,9 +1802,10 @@ and need persistent storage, it is recommended that you use the following patter
|
||||
- 仍按用户提供存储类名称,将该名称放到 `persistentVolumeClaim.storageClassName` 字段中。
|
||||
这样会使得 PVC 在集群被管理员启用了存储类支持时能够匹配到正确的存储类,
|
||||
- 如果用户未指定存储类名称,将 `persistentVolumeClaim.storageClassName` 留空(nil)。
|
||||
这样,集群会使用默认 `StorageClass` 为用户自动供应一个存储卷。
|
||||
这样,集群会使用默认 `StorageClass` 为用户自动制备一个存储卷。
|
||||
很多集群环境都配置了默认的 `StorageClass`,或者管理员也可以自行创建默认的
|
||||
`StorageClass`。
|
||||
|
||||
<!--
|
||||
- In your tooling, watch for PVCs that are not getting bound after some time
|
||||
and surface this to the user, as this may indicate that the cluster has no
|
||||
|
||||
Reference in New Issue
Block a user