Install Ceph

With a Ceph server, you can choose Ceph RBD or Ceph CSI as the underlying storage plugin. Ceph RBD is an in-tree storage plugin on Kubernetes, and Ceph CSI is a Container Storage Interface (CSI) driver for RBD, CephFS.

Which plugin to select for Ceph

Ceph CSI RBD is the preferred choice if you work with 14.0.0 (Nautilus)+ Ceph cluster. Here are some reasons:

  • The in-tree plugin will be deprecated in the future.
  • Ceph RBD only works on Kubernetes with hyperkube images, and hyperkube images were deprecated since Kubernetes 1.17.
  • Ceph CSI has more features such as cloning, expanding and snapshots.

Ceph CSI RBD

Ceph-CSI needs to be installed on v1.14.0+ Kubernetes, and work with 14.0.0 (Nautilus)+ Ceph Cluster. For details about compatibility, see Ceph CSI Support Matrix.

The following is an example of KubeKey add-on configurations for Ceph CSI RBD installed by Helm Charts. As the StorageClass is not included in the chart, a StorageClass needs to be configured in the add-on config.

Chart configurations

  1. csiConfig:
  2. - clusterID: "cluster1"
  3. monitors:
  4. - "192.168.0.8:6789" # <--TobeReplaced-->
  5. - "192.168.0.9:6789" # <--TobeReplaced-->
  6. - "192.168.0.10:6789" # <--TobeReplaced-->

If you want to configure more values, see chart configuration for ceph-csi-rbd.

StorageClass (including secret)

  1. apiVersion: v1
  2. kind: Secret
  3. metadata:
  4. name: csi-rbd-secret
  5. namespace: kube-system
  6. stringData:
  7. userID: admin
  8. userKey: "AQDoECFfYD3DGBAAm6CPhFS8TQ0Hn0aslTlovw==" # <--ToBeReplaced-->
  9. ---
  10. apiVersion: storage.k8s.io/v1
  11. kind: StorageClass
  12. metadata:
  13. name: csi-rbd-sc
  14. annotations:
  15. storageclass.beta.kubernetes.io/is-default-class: "true"
  16. storageclass.kubesphere.io/supported-access-modes: '["ReadWriteOnce","ReadOnlyMany","ReadWriteMany"]'
  17. provisioner: rbd.csi.ceph.com
  18. parameters:
  19. clusterID: "cluster1"
  20. pool: "rbd" # <--ToBeReplaced-->
  21. imageFeatures: layering
  22. csi.storage.k8s.io/provisioner-secret-name: csi-rbd-secret
  23. csi.storage.k8s.io/provisioner-secret-namespace: kube-system
  24. csi.storage.k8s.io/controller-expand-secret-name: csi-rbd-secret
  25. csi.storage.k8s.io/controller-expand-secret-namespace: kube-system
  26. csi.storage.k8s.io/node-stage-secret-name: csi-rbd-secret
  27. csi.storage.k8s.io/node-stage-secret-namespace: kube-system
  28. csi.storage.k8s.io/fstype: ext4
  29. reclaimPolicy: Delete
  30. allowVolumeExpansion: true
  31. mountOptions:
  32. - discard

Add-on configurations

Save the above chart config and StorageClass locally (e.g. /root/ceph-csi-rbd.yaml and /root/ceph-csi-rbd-sc.yaml). The add-on configuration can be set like:

  1. addons:
  2. - name: ceph-csi-rbd
  3. namespace: kube-system
  4. sources:
  5. chart:
  6. name: ceph-csi-rbd
  7. repo: https://ceph.github.io/csi-charts
  8. valuesFile: /root/ceph-csi-rbd.yaml
  9. - name: ceph-csi-rbd-sc
  10. sources:
  11. yaml:
  12. path:
  13. - /root/ceph-csi-rbd-sc.yaml

Ceph RBD

KubeKey will never use hyperkube images. Hence, in-tree Ceph RBD may not work on Kubernetes installed by KubeKey. However, if your Ceph cluster is lower than 14.0.0 which means Ceph CSI can’t be used, rbd provisioner can be used as a substitute for Ceph RBD. Its format is the same with in-tree Ceph RBD. The following is an example of KubeKey add-on configurations for rbd provisioner installed by Helm Charts including a StorageClass.

Chart configurations

  1. ceph:
  2. mon: "192.168.0.12:6789" # <--ToBeReplaced-->
  3. adminKey: "QVFBS1JkdGRvV0lySUJBQW5LaVpSKzBRY2tjWmd6UzRJdndmQ2c9PQ==" # <--ToBeReplaced-->
  4. userKey: "QVFBS1JkdGRvV0lySUJBQW5LaVpSKzBRY2tjWmd6UzRJdndmQ2c9PQ==" # <--ToBeReplaced-->
  5. sc:
  6. isDefault: false

If you want to configure more values, see chart configuration for rbd-provisioner.

Add-on configurations

Save the above chart config locally (e.g. /root/rbd-provisioner.yaml). The add-on config for rbd provisioner cloud be like:

  1. - name: rbd-provisioner
  2. namespace: kube-system
  3. sources:
  4. chart:
  5. name: rbd-provisioner
  6. repo: https://charts.kubesphere.io/test
  7. valuesFile: /root/rbd-provisioner.yaml