Creating a StorageClass

Create a StorageClass YAML file to define the storage parameters, such as cluster information and Secret reference, for use with NVMe‑oF gateways 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:

About this task

Create a StorageClass YAML file that defines how the Ceph-CSI driver communicates with the NVMe‑oF gateway for volume provisioning.

Procedure

  1. Create a StorageClass file similar to the following ceph-nvmeof-sc.yaml file.
    Important: Use the same *-secret-name and *-secret-namespace values that were specified in Creating a Secret.
    apiVersion: storage.k8s.io/v1
    kind: StorageClass
    metadata:
      name: ceph-nvmeof-sc
    provisioner: nvmeof.csi.ceph.com
    volumeBindingMode: Immediate
    parameters:
      clusterID: CLUSTER_ID
    
      pool: myPool
      imageFeatures: layering
    
      csi.storage.k8s.io/fstype: ext4
    
      csi.storage.k8s.io/provisioner-secret-name: nvmeof-secret
      csi.storage.k8s.io/provisioner-secret-namespace: default
      csi.storage.k8s.io/node-stage-secret-name: nvmeof-secret
      csi.storage.k8s.io/node-stage-secret-namespace: default
    
      csi.storage.k8s.io/controller-expand-secret-name: ceph-admin
      csi.storage.k8s.io/controller-expand-secret-namespace: default
      csi.storage.k8s.io/controller-modify-secret-name: ceph-admin
      csi.storage.k8s.io/controller-modify-secret-namespace: default
      csi.storage.k8s.io/controller-publish-secret-name: ceph-admin
      csi.storage.k8s.io/controller-publish-secret-namespace: default
    
      nvmeofGatewayAddress: GW_MANAGEMENT_IP
      nvmeofGatewayPort: GW_MANAGEMENT_PORT
    
      subsystemNQN: SUBSYSTEM_NQN  # For example: nqn.2016-06.io.ceph:subsystem.test-integration
    
      listeners: |
        [
          {
            "address": "<LISTENER_IP_01>",
            "port": 4420,
            "hostname": "<GATEWAY_POD_NAME_01>"
          },
          {
            "address": "<LISTENER_IP_02>",
            "port": 4420,
            "hostname": "<GATEWAY_POD_NAME_02>"
          }
        ]
    
    reclaimPolicy: Delete
    allowVolumeExpansion: true
  2. Apply the StorageClass, by using the kubectl apply command.
    kubectl apply -f FILENAME.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
ceph-nvmeof-sc   nvmeof.csi.ceph.com     Delete        Immediate         true                 2m

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