OpenShift Container Platform is capable of provisioning persistent volumes (PVs) using the Container Storage Interface (CSI) driver for Red Hat Virtualization (RHV).

Familiarity with persistent storage and configuring CSI volumes is recommended when working with a Container Storage Interface (CSI) Operator and driver.

To create CSI-provisioned PVs that mount to RHV storage assets, OpenShift Container Platform installs the oVirt CSI Driver Operator and the oVirt CSI driver by default in the openshift-cluster-csi-drivers namespace.

  • The oVirt CSI Driver Operator provides a default StorageClass object that you can use to create Persistent Volume Claims (PVCs).

  • The oVirt CSI driver enables you to create and mount oVirt PVs.

About CSI

Storage vendors have traditionally provided storage drivers as part of Kubernetes. With the implementation of the Container Storage Interface (CSI), third-party providers can instead deliver storage plugins using a standard interface without ever having to change the core Kubernetes code.

CSI Operators give OpenShift Container Platform users storage options, such as volume snapshots, that are not possible with in-tree volume plugins.

The oVirt CSI driver does not support snapshots.

Red Hat Virtualization (RHV) CSI driver storage class

OpenShift Container Platform creates a default object of type StorageClass named ovirt-csi-sc which is used for creating dynamically provisioned persistent volumes.

To create additional storage classes for different configurations, create and save a file with the StorageClass object described by the following sample YAML:

apiVersion: storage.k8s.io/v1
kind: StorageClass
  name: <storage_class_name>  (1)
    storageclass.kubernetes.io/is-default-class: "<boolean>"  (2)
provisioner: csi.ovirt.org
allowVolumeExpansion: <boolean> (3)
reclaimPolicy: Delete (4)
volumeBindingMode: Immediate (5)
  storageDomainName: <rhv-storage-domain-name> (6)
  thinProvisioning: "<boolean>"  (7)
  csi.storage.k8s.io/fstype: <file_system_type> (8)
1 Name of the storage class.
2 Set to false if the storage class is the default storage class in the cluster. If set to true, the existing default storage class must be edited and set to false.
3 true enables dynamic volume expansion, false prevents it. true is recommended.
4 Dynamically provisioned persistent volumes of this storage class are created with this reclaim policy. This default policy is Delete.
5 Indicates how to provision and bind PersistentVolumeClaims. When not set, VolumeBindingImmediate is used. This field is only applied by servers that enable the VolumeScheduling feature.
6 The RHV storage domain name to use.
7 If true, the disk is thin provisioned. If false, the disk is preallocated. Thin provisioning is recommended.
8 Optional: File system type to be created. Possible values: ext4 (default) or xfs.

Creating a persistent volume on RHV

When you create a PersistentVolumeClaim (PVC) object, OpenShift Container Platform provisions a new persistent volume (PV) and creates a PersistentVolume object.

  • You are logged in to a running OpenShift Container Platform cluster.

  • You provided the correct RHV credentials in ovirt-credentials secret.

  • You have installed the oVirt CSI driver.

  • You have defined at least one storage class.

  • If you are using the web console to dynamically create a persistent volume on RHV:

    1. In the OpenShift Container Platform console, click StoragePersistent Volume Claims.

    2. In the persistent volume claims overview, click Create Persistent Volume Claim.

    3. Define the required options on the resulting page.

    4. Select the appropriate StorageClass object, which is ovirt-csi-sc by default.

    5. Enter a unique name for the storage claim.

    6. Select the access mode. Currently, RWO (ReadWriteOnce) is the only supported access mode.

    7. Define the size of the storage claim.

    8. Select the Volume Mode:

      Filesystem: Mounted into pods as a directory. This mode is the default.

      Block: Block device, without any file system on it

    9. Click Create to create the PersistentVolumeClaim object and generate a PersistentVolume object.

  • If you are using the command-line interface (CLI) to dynamically create a RHV CSI volume:

    1. Create and save a file with the PersistentVolumeClaim object described by the following sample YAML:

      apiVersion: v1
      kind: PersistentVolumeClaim
        name: pvc-ovirt
        storageClassName: ovirt-csi-sc (1)
          - ReadWriteOnce
            storage: <volume size>  (2)
        volumeMode: <volume mode> (3)
      1 Name of the required storage class.
      2 Volume size in GiB.
      3 Supported options:
      • Filesystem: Mounted into pods as a directory. This mode is the default.

      • Block: Block device, without any file system on it.

    2. Create the object you saved in the previous step by running the following command:

      $ oc create -f pvc-ovirt.yaml
    3. To verify that the volume was created and is ready, run the following command:

      $ oc get pvc pvc-ovirt

      The pvc-ovirt shows that it is Bound.

If you need to update the Operator credentials, see the instructions in How to modify the RHV credentials in OCP 4.