Creating a PersistentVolumeClaim (PVC)

Create a PersistentVolumeClaim (PVC) YAML file for a 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 PersistentVolume, which is backed with a Ceph Block Device (RBD) image.

  • Specify the volumeMode for Block for supporting raw block device-based volumes.
  • 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, similar to the following raw-block-pvc.yaml file.
    kind: PersistentVolumeClaim
    apiVersion: v1
    metadata:
      name: raw-block-pvc
    spec:
      accessModes:
        - ReadWriteOnce
      volumeMode: Block
      resources:
        requests:
          storage: 2Gi
      storageClassName: ceph-rbd-sc
  2. Apply the PVC, by using the kubectl apply command.
    kubectl apply -f FILENAME.YAML
    The persistentvolumeclaim/PVC_NAME created message is emitted.