Creating a StorageClass

Create a StorageClass YAML file in order to define the storage parameters, such as file system name, Secret reference, SpaceEfficiency, and fstype for use with Ceph File Systems (CephFS) for Ceph-CSI driver. StorageClass files are used for dynamic provisioning.

Before you begin

Before you begin, make sure that you have the following prerequisites in place:
  • Ceph Manager (ceph-mgr) permissions. For more information, see User roles and permissions.
  • A Secret. When configuring the file, be sure to use the same array Secret and array Secret namespace as defined in Creating a Secret.

About this task

Create a storage class YAML file in one of the following ways:

  • Mounting with FUSE
  • Mounting with kernel

Procedure

  1. Create a StorageClass file with either FUSE or kernel mounting.
    Important: Use the same *-secret-name and *-secret-namespace information as was defined in Creating a Secret.
    • Create the StorageClass file with FUSE mounting, similar to the following ceph-cephfs-sc-fuse.yaml file.
      kind: StorageClass
      metadata:
      name: ceph-cephfs-sc-fuse
      provisioner: cephfs.csi.ceph.com
      parameters
        clusterID: CLUSTER_ID
        fsName: cephfs
        csi.storage.k8s.io/provisioner-secret-name: cephfs-secret
        csi.storage.k8s.io/provisioner-secret-namespace: default
        csi.storage.k8s.io/node-stage-secret-name: cephfs-secret
        csi.storage.k8s.io/node-stage-secret-namespace: default
        mounter: fuse
      reclaimPolicy: Delete
      allowVolumeExpansion: true
    • Create the StorageClass file with kernel mounting, similar to the following ceph-cephfs-sc-kernel.yaml file.
      kind: StorageClass
      metadata:
      name: ceph-cephfs-sc-kernel
      provisioner: cephfs.csi.ceph.com
      parameters
       clusterID: CLUSTER_ID
       fsName: cephfs
       csi.storage.k8s.io/provisioner-secret-name: cephfs-secret
       csi.storage.k8s.io/provisioner-secret-namespace: default
       csi.storage.k8s.io/node-stage-secret-name: cephfs-secret
       csi.storage.k8s.io/node-stage-secret-namespace: default
       mounter: kernel
      reclaimPolicy: Delete
      allowVolumeExpansion: true
  2. Apply the StorageClass, by using the kubectl apply command.
    kubectl apply -fFILENAME.YAML
    The storageclass.storage.k8s.io/STORAGECLASS_NAME created message is emitted.

What to do next

Verify that the StorageClass has been applied, by using the kubectl get sc command.
For example,
host01$ kubectl get sc
NAME                     PROVISIONER         RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
cephfs-storageclass-fuse cephfs.csi.ceph.com Delete        Immediate         true                 7d1h
cephfs-storageclass-ibm  cephfs.csi.ceph.com Delete        Immediate         true                 7d

After the StorageClass is created and applied, create the StorageClass. For more information, see Creating a PersistentVolumeClaim (PVC).