文章大纲
ODF 部署完成后,默认会创键以下存储类:
oc get sc -o name
storageclass.storage.k8s.io/imxcai-lvmset
storageclass.storage.k8s.io/ocs-storagecluster-ceph-rbd
storageclass.storage.k8s.io/ocs-storagecluster-ceph-rgw
storageclass.storage.k8s.io/ocs-storagecluster-cephfs
storageclass.storage.k8s.io/openshift-storage.noobaa.io
如果默认的存储类不能满足需求,可以创建自定义存储类。
根据现有的存储类进行修改
默认的 openshift-storage.rbd.csi.ceph.com
存储类的资源定义:
allowVolumeExpansion: true
kind: StorageClass
apiVersion: storage.k8s.io/v12
metadata:
name: ocs-storagecluster-ceph-rbd
parameters:
clusterID: openshift-storage
csi.storage.k8s.io/controller-expand-secret-name: rook-csi-rbd-provisioner
csi.storage.k8s.io/controller-expand-secret-namespace: openshift-storage
csi.storage.k8s.io/fstype: ext4
csi.storage.k8s.io/node-stage-secret-name: rook-csi-rbd-node
csi.storage.k8s.io/node-stage-secret-namespace: openshift-storage
csi.storage.k8s.io/provisioner-secret-name: rook-csi-rbd-provisioner
csi.storage.k8s.io/provisioner-secret-namespace: openshift-storage
imageFeatures: layering
imageFormat: "2"
pool: ocs-storagecluster-cephblockpool
provisioner: openshift-storage.rbd.csi.ceph.com
reclaimPolicy: Delete
volumeBindingMode: Immediate
默认的为 ext4
文件系统,回收策略是 Delete
,可以修改为使用 xfs
文件系统和 Retain
策略:
allowVolumeExpansion: true
kind: StorageClass
apiVersion: storage.k8s.io/v12
metadata:
name: ocs-storagecluster-ceph-rbd
parameters:
clusterID: openshift-storage
csi.storage.k8s.io/controller-expand-secret-name: rook-csi-rbd-provisioner
csi.storage.k8s.io/controller-expand-secret-namespace: openshift-storage
csi.storage.k8s.io/fstype: xfs
csi.storage.k8s.io/node-stage-secret-name: rook-csi-rbd-node
csi.storage.k8s.io/node-stage-secret-namespace: openshift-storage
csi.storage.k8s.io/provisioner-secret-name: rook-csi-rbd-provisioner
csi.storage.k8s.io/provisioner-secret-namespace: openshift-storage
imageFeatures: layering
imageFormat: "2"
pool: ocs-storagecluster-cephblockpool
provisioner: openshift-storage.rbd.csi.ceph.com
reclaimPolicy: Retain
volumeBindingMode: Immediate
使用 Dashboard 创建自定义存储类
如果要更改池,首先需要创建池,这个步骤在 Dashboard 中操作会更方便:
在 CLI 中验证:
oc get sc
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
app-database-sc openshift-storage.rbd.csi.ceph.com Retain Immediate false 14s
imxcai-lvmset kubernetes.io/no-provisioner Delete WaitForFirstConsumer false 5d19h
ocs-storagecluster-ceph-rbd openshift-storage.rbd.csi.ceph.com Delete Immediate true 5d19h
ocs-storagecluster-ceph-rgw openshift-storage.ceph.rook.io/bucket Delete Immediate false 5d19h
ocs-storagecluster-cephfs openshift-storage.cephfs.csi.ceph.com Delete Immediate true 5d19h
openshift-storage.noobaa.io openshift-storage.noobaa.io/obc Delete Immediate false 5d19h
oc describe sc app-database-sc
Name: app-database-sc
IsDefaultClass: No
Annotations: <none>
Provisioner: openshift-storage.rbd.csi.ceph.com
Parameters: clusterID=openshift-storage,csi.storage.k8s.io/controller-expand-secret-name=rook-csi-rbd-provisioner,csi.storage.k8s.io/controller-expand-secret-namespace=openshift-storage,csi.storage.k8s.io/fstype=ext4,csi.storage.k8s.io/node-stage-secret-name=rook-csi-rbd-node,csi.storage.k8s.io/node-stage-secret-namespace=openshift-storage,csi.storage.k8s.io/provisioner-secret-name=rook-csi-rbd-provisioner,csi.storage.k8s.io/provisioner-secret-namespace=openshift-storage,imageFeatures=layering,imageFormat=2,pool=sc-pool
AllowVolumeExpansion: False
MountOptions: <none>
ReclaimPolicy: Retain
VolumeBindingMode: Immediate
Events: <none>