7.18.2.4. 创建存储类
当您创建存储类时,您将设置参数,它们会影响属于该存储类的持久性卷(PV)的动态置备。您不能在创建 StorageClass
对象后更新其参数。
重要
在 OpenShift Container Platform Container Storage 中使用 OpenShift Virtualization 时,指定创建虚拟机磁盘时 RBD 块模式持久性卷声明(PVC)。使用虚拟机磁盘时,RBD 块模式卷更高效,并且比 Ceph FS 或 RBD 文件系统模式 PVC 提供更好的性能。
要指定 RBD 块模式 PVC,请使用 'ocs-storagecluster-ceph-rbd' 存储类和 VolumeMode: Block
。
流程
创建用于定义存储类的 YAML 文件。例如:
$ touch storageclass.yaml
编辑该文件。例如:
apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: hostpath-provisioner 1 provisioner: kubevirt.io/hostpath-provisioner reclaimPolicy: Delete 2 volumeBindingMode: WaitForFirstConsumer 3
注意虚拟机使用基于本地 PV 的数据卷。本地 PV 与特定节点绑定。虽然磁盘镜像准备供虚拟机消耗,但可能不会将虚拟机调度到之前固定本地存储 PV 的节点。
要解决这个问题,使用 Kubernetes pod 调度程序将 PVC 绑定到正确的节点上的 PV。通过使用
volumeBindingMode
设置为WaitForFirstConsumer
的StorageClass
,PV 的绑定和置备会延迟到Pod
创建前。创建
StorageClass
对象:$ oc create -f storageclass.yaml
其它资源