Red Hat Virtualization CSI Driver Operator

Overview

OKD is capable of provisioning persistent volumes (PVs) using the Container Storage Interface (CSI) driver for oVirt.

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 oVirt storage assets, OKD 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). You can disable this default storage class if desired (see Managing the default storage class).

  • 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 OKD users storage options, such as volume snapshots, that are not possible with in-tree volume plugins.

The oVirt CSI driver does not support snapshots.

oVirt CSI driver storage class

OKD 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:

ovirt-storageclass.yaml

  1. apiVersion: storage.k8s.io/v1
  2. kind: StorageClass
  3. metadata:
  4. name: <storage_class_name> (1)
  5. annotations:
  6. storageclass.kubernetes.io/is-default-class: "<boolean>" (2)
  7. provisioner: csi.ovirt.org
  8. allowVolumeExpansion: <boolean> (3)
  9. reclaimPolicy: Delete (4)
  10. volumeBindingMode: Immediate (5)
  11. parameters:
  12. storageDomainName: <rhv-storage-domain-name> (6)
  13. thinProvisioning: "<boolean>" (7)
  14. csi.storage.k8s.io/fstype: <file_system_type> (8)
1Name of the storage class.
2Set 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.
3true enables dynamic volume expansion, false prevents it. true is recommended.
4Dynamically provisioned persistent volumes of this storage class are created with this reclaim policy. This default policy is Delete.
5Indicates how to provision and bind PersistentVolumeClaims. When not set, VolumeBindingImmediate is used. This field is only applied by servers that enable the VolumeScheduling feature.
6The oVirt storage domain name to use.
7If true, the disk is thin provisioned. If false, the disk is preallocated. Thin provisioning is recommended.
8Optional: 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, OKD provisions a new persistent volume (PV) and creates a PersistentVolume object.

Prerequisites

  • You are logged in to a running OKD cluster.

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

  • You have installed the oVirt CSI driver.

  • You have defined at least one storage class.

Procedure

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

    1. In the OKD 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 oVirt CSI volume:

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

      pvc-ovirt.yaml

      1. apiVersion: v1
      2. kind: PersistentVolumeClaim
      3. metadata:
      4. name: pvc-ovirt
      5. spec:
      6. storageClassName: ovirt-csi-sc (1)
      7. accessModes:
      8. - ReadWriteOnce
      9. resources:
      10. requests:
      11. storage: <volume size> (2)
      12. volumeMode: <volume mode> (3)
      1Name of the required storage class.
      2Volume size in GiB.
      3Supported 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:

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

      1. $ 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.

Additional resources