Configuring Static and Dynamic Provisioning for a Raw Block Volume

Raw block volumes are supported for both static and dynamic provisioning. To request a raw-block PersistentVolumeClaim, set volumeMode: Block. If not specified, volumeMode defaults to Filesystem in the PersistentVolumeClaimSpec. PersistentVolumes also have a volumeMode field in the PersistentVolumeSpec that is used for static provisioning. Block-type PVCs can only bind to Block-type PVs.

All the features supported on Filesystem-persistent volumes are supported on Block volumes. For example:
  • Create and Delete Volumes
  • Expand Volumes
  • Clone Volumes
  • Create and Delete Snapshot
  • Snapshot Restore

Block volumes are supported only in single-node-writer access modes. At any given time, they can only be published once as read/write on a single node. For Block volumes, the CSI driver does not format the block device; it just binds the block device to the target path. The application pod can choose to format the block device to any required Linux file system, such as ext4, xfs, btrfs, and others.

Each block volume is stored in an HPE Ezmeral Data Fabric file. Statically provisioned block files are located at the path designated in the volumePath specified in the persistent volume definition. Dynamically provisioned block files are located at the path designated by the mountPrefix in the storage class. For fast, random block-write performance, these files should not be erasure coded (warm tiering) or tiered off to an objectstore (cold tiering).

Static Provisioning Example
apiVersion: v1
kind: PersistentVolume
metadata:
  name: test-blockpv
  namespace: test-csi
spec:
  accessModes:
  - ReadWriteOnce
  volumeMode: Block
  persistentVolumeReclaimPolicy: Delete
  capacity:
    storage: 5G
  csi:
    driver: com.mapr.csi-kdf
    volumeHandle: test-simplepv
    volumeAttributes:
      volumePath: "/user/guest/myblockvolume"
      cluster: "clusterA"
      cldbHosts: "10.10.10.210"
      securityType: "secure"
      platinum: "true"
      capacityBytes: "5000000000"
NOTE For the Loopback NFS CSI driver, change driver to com.mapr.csi-nfskdf.

Dynamic Provisioning Example

Note that no change in the StorageClass is required:
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: test-secure-block-pvc
  namespace: test-csi
spec:
  storageClassName: test-secure-sc
  accessModes:
    - ReadWriteOnce
  volumeMode: Block
  resources:
    requests:
      storage: 5G

Pod Specification

In the pod specification, you must specify volumeDevices and devicePath for the block volume instead of volumeMounts and mountPath.
apiVersion: v1
kind: Pod
metadata:
  name: test-secure-block-pod
spec:
  containers:
    - name: fc-container
      image: fedora:26
      command: ["/bin/sh", "-c"]
      args: [ "tail -f /dev/null" ]
      volumeDevices:
        - name: data
          devicePath: /dev/xvda
  volumes:
    - name: data
      persistentVolumeClaim:
        claimName: test-secure-block-pvc