diff --git a/content/zh/docs/concepts/storage/storage-classes.md b/content/zh/docs/concepts/storage/storage-classes.md index 28ca72dd42..539f444168 100644 --- a/content/zh/docs/concepts/storage/storage-classes.md +++ b/content/zh/docs/concepts/storage/storage-classes.md @@ -120,7 +120,7 @@ for provisioning PVs. This field must be specified. | Glusterfs | ✓ | [Glusterfs](#glusterfs) | | iSCSI | - | - | | Quobyte | ✓ | [Quobyte](#quobyte) | -| NFS | - | - | +| NFS | - | [NFS](#nfs) | | RBD | ✓ | [Ceph RBD](#ceph-rbd) | | VsphereVolume | ✓ | [vSphere](#vsphere) | | PortworxVolume | ✓ | [Portworx Volume](#portworx-卷) | @@ -316,6 +316,43 @@ to see its supported topology keys and examples. 动态配置和预先创建的 PV 也支持 [CSI卷](/zh/docs/concepts/storage/volumes/#csi), 但是你需要查看特定 CSI 驱动程序的文档以查看其支持的拓扑键名和例子。 +{{< note >}} + + 如果你选择使用 `WaitForFirstConsumer`,请不要在 Pod 规约中使用 `nodeName` 来指定节点亲和性。 + 如果在这种情况下使用 `nodeName`,Pod 将会绕过调度程序,PVC 将停留在 `pending` 状态。 + + 相反,在这种情况下,你可以使用节点选择器作为主机名,如下所示 + +{{< /note >}} + +```yaml +apiVersion: v1 +kind: Pod +metadata: + name: task-pv-pod +spec: + nodeSelector: + kubernetes.io/hostname: kube-01 + volumes: + - name: task-pv-storage + persistentVolumeClaim: + claimName: task-pv-claim + containers: + - name: task-pv-container + image: nginx + ports: + - containerPort: 80 + name: "http-server" + volumeMounts: + - mountPath: "/usr/share/nginx/html" + name: task-pv-storage +``` + @@ -647,6 +684,41 @@ parameters: 当动态制备持久卷时,Gluster 插件自动创建名为 `gluster-dynamic-` 的端点和无头服务。在 PVC 被删除时动态端点和无头服务会自动被删除。 +### NFS + +```yaml +apiVersion: storage.k8s.io/v1 +kind: StorageClass +metadata: + name: example-nfs +provisioner: example.com/external-nfs +parameters: + server: nfs-server.example.com + path: /share + readOnly: false +``` + + +* `server`:NFS 服务器的主机名或 IP 地址。 +* `path`:NFS 服务器导出的路径。 +* `readOnly`:是否将存储挂载为只读的标志(默认为 false)。 + + +Kubernetes 不包含内部 NFS 驱动。你需要使用外部驱动为 NFS 创建 StorageClass。 +这里有些例子: +* [NFS Ganesha 服务器和外部驱动](https://github.com/kubernetes-sigs/nfs-ganesha-server-and-external-provisioner) +* [NFS subdir 外部驱动](https://github.com/kubernetes-sigs/nfs-subdir-external-provisioner) + + ### OpenStack Cinder ```yaml @@ -912,6 +984,17 @@ parameters: ### Quobyte +{{< feature-state for_k8s_version="v1.22" state="deprecated" >}} + + +Quobyte 树内(in-tree)存储插件已弃用, +你可以在 Quobyte CSI 仓库中找到用于树外(out-of-tree)Quobyte 插件的 `StorageClass` +[示例](https://github.com/quobyte/quobyte-csi/blob/master/example/StorageClass.yaml)。 + ```yaml apiVersion: storage.k8s.io/v1 kind: StorageClass diff --git a/content/zh/docs/concepts/storage/volumes.md b/content/zh/docs/concepts/storage/volumes.md index 81e4ebf738..e8ec03fdc1 100644 --- a/content/zh/docs/concepts/storage/volumes.md +++ b/content/zh/docs/concepts/storage/volumes.md @@ -219,23 +219,22 @@ beta features must be enabled. -如欲禁止 `awsElasticBlockStore` 存储插件被控制器管理器和 kubelet -组件加载,可将 `CSIMigrationAWSComplete` 特性门控设置为 `true`。此特性要求在 -集群中所有工作节点上安装 `ebs.csi.aws.com` 容器存储接口驱动。 +要禁止控制器管理器和 kubelet 加载 `awsElasticBlockStore` 存储插件, +请将 `InTreePluginAWSUnregister` 标志设置为 `true`。 ### azureDisk {#azuredisk} `azureDisk` 卷类型用来在 Pod 上挂载 Microsoft Azure [数据盘(Data Disk)](https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-linux-about-disks-vhds/) 。 -若需了解更多详情,请参考 [`azureDisk` 卷插件](https://github.com/kubernetes/examples/tree/{{< param "githubbranch" >}}/staging/volumes/azure_disk/README.md)。 +若需了解更多详情,请参考 [`azureDisk` 卷插件](https://github.com/kubernetes/examples/tree/master/staging/volumes/azure_disk/README.md)。 `azureFile` 卷类型用来在 Pod 上挂载 Microsoft Azure 文件卷(File Volume)(SMB 2.1 和 3.0)。 -更多详情请参考 [`azureFile` 卷插件](https://github.com/kubernetes/examples/tree/{{< param "githubbranch" >}}/staging/volumes/azure_file/README.md)。 +更多详情请参考 [`azureFile` 卷插件](https://github.com/kubernetes/examples/tree/master/staging/volumes/azure_file/README.md)。 -更多信息请参考 [CephFS 示例](https://github.com/kubernetes/examples/tree/{{< param "githubbranch" >}}/volumes/cephfs/)。 +更多信息请参考 [CephFS 示例](https://github.com/kubernetes/examples/tree/master/volumes/cephfs/)。 ### cinder {#cinder} @@ -589,15 +588,15 @@ targetWWNs expect that those WWNs are from multi-path connections. -{{< caution >}} +{{< note >}} 你必须配置 FC SAN Zoning,以便预先向目标 WWN 分配和屏蔽这些 LUN(卷), 这样 Kubernetes 主机才可以访问它们。 -{{< /caution >}} +{{< /note >}} -更多详情请参考 [FC 示例](https://github.com/kubernetes/examples/tree/{{< param "githubbranch" >}}/staging/volumes/fibre_channel)。 +更多详情请参考 [FC 示例](https://github.com/kubernetes/examples/tree/master/staging/volumes/fibre_channel)。 -更多详情请参考 [Flocker 示例](https://github.com/kubernetes/examples/tree/{{< param "githubbranch" >}}/staging/volumes/flocker)。 +更多详情请参考 [Flocker 示例](https://github.com/kubernetes/examples/tree/master/staging/volumes/flocker)。 +#### GCE CSI 迁移完成 + +{{< feature-state for_k8s_version="v1.21" state="alpha" >}} + +要禁止控制器管理器和 kubelet 加载 `gcePersistentDisk` 存储插件, +请将 `InTreePluginGCEUnregister` 标志设置为 `true`。 + @@ -883,12 +898,28 @@ You must have your own GlusterFS installation running before you can use it. {{< /note >}} -更多详情请参考 [GlusterFS 示例](https://github.com/kubernetes/examples/tree/{{< param "githubbranch" >}}/volumes/glusterfs)。 +更多详情请参考 [GlusterFS 示例](https://github.com/kubernetes/examples/tree/master/volumes/glusterfs)。 ### hostPath +{{< warning >}} + +HostPath 卷存在许多安全风险,最佳做法是尽可能避免使用 HostPath。 +当必须使用 HostPath 卷时,它的范围应仅限于所需的文件或目录,并以只读方式挂载。 + +如果通过 AdmissionPolicy 限制 HostPath 对特定目录的访问, +则必须要求 `volumeMounts` 使用 `readOnly` 挂载以使策略生效。 +{{< /warning >}} + 当使用这种类型的卷时要小心,因为: +* HostPath 卷可能会暴露特权系统凭据(例如 Kubelet)或特权 API(例如容器运行时套接字), + 可用于容器逃逸或攻击集群的其他部分。 * 具有相同配置(例如基于同一 PodTemplate 创建)的多个 Pod 会由于节点上文件的不同 而在不同节点上有不同的行为。 * 下层主机上创建的文件或目录只能由 root 用户写入。你需要在 @@ -1065,9 +1101,9 @@ iSCSI 的一个特点是它可以同时被多个用户以只读方式挂载。 不幸的是,iSCSI 卷只能由单个使用者以读写模式挂载。不允许同时写入。 -更多详情请参考 [iSCSI 示例](https://github.com/kubernetes/examples/tree/{{< param "githubbranch" >}}/volumes/iscsi)。 +更多详情请参考 [iSCSI 示例](https://github.com/kubernetes/examples/tree/master/volumes/iscsi)。 -要了解更多详情请参考 [NFS 示例](https://github.com/kubernetes/examples/tree/{{< param "githubbranch" >}}/staging/volumes/nfs)。 +要了解更多详情请参考 [NFS 示例](https://github.com/kubernetes/examples/tree/master/staging/volumes/nfs)。 ### persistentVolumeClaim {#persistentvolumeclaim} @@ -1283,10 +1319,10 @@ before using it in the Pod. {{< /note >}} -更多详情可以参考 [Portworx 卷](https://github.com/kubernetes/examples/tree/{{< param "githubbranch" >}}/staging/volumes/portworx/README.md)。 +更多详情可以参考 [Portworx 卷](https://github.com/kubernetes/examples/tree/master/staging/volumes/portworx/README.md)。 ### projected @@ -1306,10 +1342,10 @@ Currently, the following types of volume sources can be projected: 所有的卷来源需要和 Pod 处于相同的命名空间。 -更多详情请参考[一体化卷设计文档](https://github.com/kubernetes/community/blob/{{< param "githubbranch" >}}/contributors/design-proposals/node/all-in-one-volume.md)。 +更多详情请参考[一体化卷设计文档](https://github.com/kubernetes/community/blob/master/contributors/design-proposals/node/all-in-one-volume.md)。 RBD 的一个特性是它可以同时被多个用户以只读方式挂载。 这意味着你可以用数据集预先填充卷,然后根据需要在尽可能多的 Pod 中并行地使用卷。 不幸的是,RBD 卷只能由单个使用者以读写模式安装。不允许同时写入。 更多详情请参考 -[RBD 示例](https://github.com/kubernetes/examples/tree/{{< param "githubbranch" >}}/volumes/rbd)。 - - -### scaleIO (已弃用) {#scaleio} - - -ScaleIO 是基于软件的存储平台,可以使用现有硬件来创建可伸缩的、共享的而且是网络化的块存储集群。 -`scaleIO` 卷插件允许部署的 Pod 访问现有的 ScaleIO 卷(或者它可以动态地为持久卷申领提供新的卷, -参见 [ScaleIO 持久卷](/zh/docs/concepts/storage/persistent-volumes/#scaleio))。 - - -{{< note >}} -在使用前,你必须有个安装完毕且运行正常的 ScaleIO 集群,并且创建好了存储卷。 -{{< /note >}} - - -下面是配置了 ScaleIO 的 Pod 示例: - -```yaml -apiVersion: v1 -kind: Pod -metadata: - name: pod-0 -spec: - containers: - - image: k8s.gcr.io/test-webserver - name: pod-0 - volumeMounts: - - mountPath: /test-pd - name: vol-0 - volumes: - - name: vol-0 - scaleIO: - gateway: https://localhost:443/api - system: scaleio - protectionDomain: sd0 - storagePool: sp1 - volumeName: vol-0 - secretRef: - name: sio-secret - fsType: xfs -``` - - -更多详情,请参考 [ScaleIO 示例](https://github.com/kubernetes/examples/tree/{{< param "githubbranch" >}}/staging/volumes/scaleio)。 +[RBD 示例](https://github.com/kubernetes/examples/tree/master/volumes/rbd)。 ### secret @@ -1633,7 +1610,7 @@ For more details, see [Configuring Secrets](/docs/concepts/configuration/secret/ --> 更多详情请参考[配置 Secrets](/zh/docs/concepts/configuration/secret/)。 -### storageOS {#storageos} +### storageOS (已弃用) {#storageos} 为了避免控制器管理器和 kubelet 加载 `vsphereVolume` 插件,你需要将 -`CSIMigrationVSphereComplete` 特性设置为 `true`。你还必须在所有工作节点上安装 +`InTreePluginvSphereUnregister` 特性设置为 `true`。你还必须在所有工作节点上安装 `csi.vsphere.vmware.com` {{< glossary_tooltip text="CSI" term_id="csi" >}} 驱动。