https://docs.openebs.io/docs/next/ugcstor-csi.html

如果出现k8s.gcr.io/sig-storage 相关镜像拉取失败

  1. wget https://openebs.github.io/charts/cstor-operator.yaml
  2. sed -i "s#k8s.gcr.io/sig-storage#registry.aliyuncs.com/google_containers#g" cstor-operator.yaml
  3. kubectl apply -f cstor-operator.yaml

查看块设备

  1. kubectl get bd -n openebs
  2. NAME NODENAME SIZE CLAIMSTATE STATUS AGE
  3. blockdevice-e43d8a3af67696f0b94f501ba9c9d943 k8s-node1 10736352768 Unclaimed Active 3m35s

All the NDM cStor operator pods must be in a running state. To get the status of the pods execute:\

  1. kubectl get pod -n openebs

输出结果

  1. # kubectl get pod -n openebs
  2. NAME READY STATUS RESTARTS AGE
  3. cspc-operator-654f545f85-dsqdp 1/1 Running 0 9m30s
  4. cvc-operator-ccdff6f9f-dfwq7 1/1 Running 0 9m22s
  5. openebs-cstor-admission-server-7f49d85966-kjjpv 1/1 Running 0 9m13s
  6. openebs-cstor-csi-controller-0 6/6 Running 0 9m41s
  7. openebs-cstor-csi-node-89hrl 2/2 Running 0 9m40s
  8. openebs-cstor-csi-node-g8r87 2/2 Running 0 9m40s
  9. openebs-ndm-d88gb 1/1 Running 0 8m17s
  10. openebs-ndm-operator-5588776b5f-dgrvt 1/1 Running 0 8m17s
  11. openebs-ndm-tf6fn

Nodes must have disks attached to them. To get the list of attached block devices, execute:

  1. kubectl get bd -n openebs
  2. NAME NODENAME SIZE CLAIMSTATE STATUS AGE
  3. blockdevice-e43d8a3af67696f0b94f501ba9c9d943 k8s-node1 10736352768 Unclaimed Active 9m37s

Creating a CStorPoolCluster:

  • Get all the node labels present in the cluster with the following command, these node labels will be required to modify the CSPC yaml.
    1. # kubectl get node --show-labels
    2. NAME STATUS ROLES AGE VERSION LABELS
    3. k8s-master Ready master 22h v1.19.12 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=k8s-master,kubernetes.io/os=linux,node-role.kubernetes.io/master=,topology.cstor.openebs.io/nodeName=k8s-master
    4. k8s-node1 Ready <none> 22h v1.19.12 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=k8s-node1,kubernetes.io/os=linux,topology.cstor.openebs.io/nodeName=k8s-node1
    Modify the CSPC yaml to use the worker nodes. Use the value from labels kubernetes.io/hostname=< node_name >. This label value and node name could be different in some platforms. In this case, the label values and node names are: kubernetes.io/hostname:”worker-node-1”, kubernetes.io/hostname: “worker-node-2” and kubernetes.io/hostname: “worker-node-3”.
    获取kubernetes.io/hostname: 也是就是hostname

vim

  1. apiVersion: cstor.openebs.io/v1
  2. kind: CStorPoolCluster
  3. metadata:
  4. name: cstor-disk-pool
  5. namespace: openebs
  6. spec:
  7. pools:
  8. - nodeSelector:
  9. kubernetes.io/hostname: "k8s-node1"
  10. dataRaidGroups:
  11. - blockDevices:
  12. - blockDeviceName: "blockdevice-e43d8a3af67696f0b94f501ba9c9d943"
  13. poolConfig:
  14. dataRaidGroupType: "stripe"

执行

  1. kubectl apply -f cspc.yaml
  2. cstorpoolcluster.cstor.openebs.io/cstor-disk-pool created

查看

  1. kubectl get cspc -n openebs
  2. NAME HEALTHYINSTANCES PROVISIONEDINSTANCES DESIREDINSTANCES AGE
  3. cstor-disk-pool 1 1 27s

查看是否

  1. kubectl get cspi -n openebs
  2. NAME HOSTNAME FREE CAPACITY READONLY PROVISIONEDREPLICAS HEALTHYREPLICAS STATUS AGE
  3. cstor-disk-pool-zznw k8s-node1 9630M 9630078500 false 0 0 ONLINE 20m

cs

  1. kind: StorageClass
  2. apiVersion: storage.k8s.io/v1
  3. metadata:
  4. name: cstor-csi-disk
  5. provisioner: cstor.csi.openebs.io
  6. allowVolumeExpansion: true
  7. parameters:
  8. cas-type: cstor
  9. cstorPoolCluster: cstor-disk-pool
  10. replicaCount: "1"