Creating a PersistentVolumeClaim (PVC)

Create a PersistentVolumeClaim (PVC) YAML file for a Ceph File System (CephFS) persistent volume (PV).

About this task

A PVC is a request for abstract storage resources by a user. The PVC is then be associated to a Pod resource to provision a PV, which is backed with a CephFS image.

  • Specify the accessMode with one of the following values: ReadWriteOnce, ReadWriteMany, or ReadOnlyMany.
  • Be sure to use the same StorageClass as defined in Creating a StorageClass when configuring the storageClassName.

Procedure

  1. Create the PVC file with either FUSE or kernel mounting.
    • Create the PVCfile with FUSE mounting, similar to the following cephfs-pvc-fuse.yaml file.
      kind: PersistentVolumeClaim
      metadata:
       name: cephfs-pvc-fuse
      spec:
       accessModes:
         - ReadWriteOnce
       resources:
         requests:
           storage: 10Gi
       storageClassName: cephfs-stroageclass-fuse
    • Create the PVC with kernel mounting, similar to the following cephfs-pvc-kernel.yaml file.
      kind: PersistentVolumeClaim
      metadata:
      name: cephfs-pvc-kernel
      spec:
      accessModes:
        - ReadWriteOnce
      resources:
        requests:
          storage: 10Gi
      storageClassName: cephfs-stroageclass-kernel
  2. Apply the PVC, by using the kubectl apply command.
    kubectl apply -fFILENAME.YAML
    The persistentvolumeclaim/PVC_NAME created message is emitted.

What to do next

  1. Verify that the PVC is in a bound state, by using the kubectl get pvc command.
    For example,
    host01:.kube$ kubectl get pvc
    NAME              STATUS VOLUME                                   CAPACITY ACCESS MODES  STORAGECLASS             VOLUMEATTRIBUTESCLASS AGE
    cephfs-pvc-ibm    Bound  pvc-b6c257c4-3da7-476b-9c0e-3547c1b1952a 10Gi     RWX           cephfs-storageclass-fuse  <unset>            2d3h
    cephfs-pvc-kernel Bound  pvc-f0d96599-7b98-4f56-b4ae-db22fb65c277 20Gi     RWX           cephfs-storageclass-ibm   <unset>            2d3h
  2. Verify that there are subvolumes in the Ceph cluster.
    ceph fs subvolume ls cephfs csi
    For example,
    [root@host01 ceph]# ceph fs subvolume ls cephfs csi
    [
      {
          "name": "csi-vol-ab1237a9-1fbd-43c1-8b41-0dfd9dc8dee9"
      },
      {
          "name": "csi-vol-d456149-72b9-4640-abe3-6e4987475dcc"
      }
    ]