一、前置要求

  • isisc
  • 系统盘之外的额外磁盘,不需要先格式化

二、安装

kubectl apply -f https://openebs.github.io/charts/cstor-operator.yaml

等待 operator 服务正常启动

kubectl get bd -n openebs

operator 服务正常启动之后,通过 kubectl get bd -n openebs会自动读取 node 上的可用磁盘,读取需要的 node 上的信息,保存为下面的文件内容

apiVersion: cstor.openebs.io/v1
kind: CStorPoolCluster
metadata:
 name: cstor-disk-pool
 namespace: openebs
spec:
 pools:
   - nodeSelector:
       kubernetes.io/hostname: "node1"
     dataRaidGroups:
       - blockDevices:
           - blockDeviceName: "blockdevice-3213a3bb3822161df3732b0321de495a"
     poolConfig:
       dataRaidGroupType: "stripe"

执行上面的 yaml 之后,我们的存储资源池就创建好了,再创建 sc 就可以正常使用了

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: cstor-csi-disk
provisioner: cstor.csi.openebs.io
allowVolumeExpansion: true
parameters:
  cas-type: cstor
  # cstorPoolCluster should have the name of the CSPC
  cstorPoolCluster: cstor-disk-pool
  # replicaCount should be <= no. of CSPI created in the selected CSPC
  replicaCount: "1"

需要注意的是,replicaCount 的值,要小于等于上面 pool 的数量