×

A storage profile provides recommended storage settings based on the associated storage class. A storage profile is allocated for each storage class.

The Containerized Data Importer (CDI) recognizes a storage provider if it has been configured to identify and interact with the storage provider’s capabilities.

For recognized storage types, the CDI provides values that optimize the creation of PVCs. You can also configure automatic settings for the storage class by customizing the storage profile. If the CDI does not recognize your storage provider, you must configure storage profiles.

When using OKD Virtualization with Red Hat OpenShift Data Foundation, specify RBD block mode persistent volume claims (PVCs) when creating virtual machine disks. RBD block mode volumes are more efficient and provide better performance than Ceph FS or RBD filesystem-mode PVCs.

To specify RBD block mode PVCs, use the 'ocs-storagecluster-ceph-rbd' storage class and VolumeMode: Block.

Customizing the storage profile

You can specify default parameters by editing the StorageProfile object for the provisioner’s storage class. These default parameters only apply to the persistent volume claim (PVC) if they are not configured in the DataVolume object.

You cannot modify storage class parameters. To make changes, delete and re-create the storage class. You must then reapply any customizations that were previously made to the storage profile.

An empty status section in a storage profile indicates that a storage provisioner is not recognized by the Containerized Data Importer (CDI). Customizing a storage profile is necessary if you have a storage provisioner that is not recognized by CDI. In this case, the administrator sets appropriate values in the storage profile to ensure successful allocations.

If you are creating a snapshot of a VM, a warning appears if the storage class of the disk has more than one VolumeSnapshotClass associated with it. In this case, you must specify one volume snapshot class; otherwise, any disk that has more than one volume snapshot class is excluded from the snapshots list.

If you create a data volume and omit YAML attributes and these attributes are not defined in the storage profile, then the requested storage will not be allocated and the underlying persistent volume claim (PVC) will not be created.

Prerequisites
  • Ensure that your planned configuration is supported by the storage class and its provider. Specifying an incompatible configuration in a storage profile causes volume provisioning to fail.

Procedure
  1. Edit the storage profile. In this example, the provisioner is not recognized by CDI.

    $ oc edit storageprofile <storage_class>
  2. Specify the accessModes and volumeMode values you want to configure for the storage profile. For example:

    Example storage profile

    apiVersion: cdi.kubevirt.io/v1beta1
    kind: StorageProfile
    metadata:
      name: <unknown_provisioner_class>
    # ...
    spec:
      claimPropertySets:
      - accessModes:
        - ReadWriteOnce (1)
        volumeMode: Filesystem (2)
    status:
      provisioner: <unknown_provisioner>
      storageClass: <unknown_provisioner_class>
    1 Specify the accessModes.
    2 Specify the volumeMode.

Specifying a volume snapshot class by using the web console

If you are creating a snapshot of a VM, a warning appears if the storage class of the disk has more than one volume snapshot class associated with it. In this case, you must specify one volume snapshot class; otherwise, any disk that has more than one volume snapshot class is excluded from the snapshots list.

You can specify the default volume snapshot class in the OKD web console.

Procedure
  1. From the Virtualization focused view, select Storage.

  2. Click VolumeSnapshotClasses.

  3. Select a volume snapshot class from the list.

  4. Click the Annotations pencil icon.

  5. Enter the following Key: snapshot.storage.kubernetes.io/is-default-class.

  6. Enter the following Value: true.

  7. Click Save.

Specifying a volume snapshot class by using the CLI

If you are creating a snapshot of a VM, a warning appears if the storage class of the disk has more than one volume snapshot class associated with it. In this case, you must specify one volume snapshot class; otherwise, any disk that has more than one volume snapshot class is excluded from the snapshots list.

You can select which volume snapshot class to use by either:

  • Setting the spec.snapshotClass for the storage profile.

  • Setting a default volume snapshot class.

Procedure
  • Set the VolumeSnapshotClass you want to use. For example:

    apiVersion: cdi.kubevirt.io/v1beta1
    kind: StorageProfile
    metadata:
      name: ocs-storagecluster-ceph-rbd-virtualization
    spec:
      snapshotClass: ocs-storagecluster-rbdplugin-snapclass
  • Alternatively, set the default volume snapshot class by running the following command:

    # oc patch VolumeSnapshotClass ocs-storagecluster-cephfsplugin-snapclass --type=merge -p '{"metadata":{"annotations":{"snapshot.storage.kubernetes.io/is-default-class":"true"}}}'

Viewing automatically created storage profiles

The system creates storage profiles for each storage class automatically.

Procedure
  1. To view the list of storage profiles, run the following command:

    $ oc get storageprofile
  2. To fetch the details of a particular storage profile, run the following command:

    $ oc describe storageprofile <name>
    Example storage profile details

    Name:         ocs-storagecluster-ceph-rbd-virtualization
    Namespace:
    Labels:       app=containerized-data-importer
                  app.kubernetes.io/component=storage
                  app.kubernetes.io/managed-by=cdi-controller
                  app.kubernetes.io/part-of=hyperconverged-cluster
                  app.kubernetes.io/version=4.17.2
                  cdi.kubevirt.io=
    Annotations:  <none>
    API Version:  cdi.kubevirt.io/v1beta1
    Kind:         StorageProfile
    Metadata:
      Creation Timestamp:  2023-11-13T07:58:02Z
      Generation:          2
      Owner References:
        API Version:           cdi.kubevirt.io/v1beta1
        Block Owner Deletion:  true
        Controller:            true
        Kind:                  CDI
        Name:                  cdi-kubevirt-hyperconverged
        UID:                   2d6f169a-382c-4caf-b614-a640f2ef8abb
      Resource Version:        4186799537
      UID:                     14aef804-6688-4f2e-986b-0297fd3aaa68
    Spec:
    Status:
      Claim Property Sets: (1)
        accessModes:
          ReadWriteMany
        volumeMode:  Block
        accessModes:
          ReadWriteOnce
        volumeMode:  Block
        accessModes:
          ReadWriteOnce
        volumeMode:                   Filesystem
      Clone Strategy:                  csi-clone (2)
      Data Import Cron Source Format:  snapshot (3)
      Provisioner:                     openshift-storage.rbd.csi.ceph.com
      Snapshot Class:                  ocs-storagecluster-rbdplugin-snapclass
      Storage Class:                   ocs-storagecluster-ceph-rbd-virtualization
    Events:                            <none>
    1 Claim Property Sets is an ordered list of AccessMode/VolumeMode pairs, which describe the PVC modes that are used to provision VM disks.
    2 The Clone Strategy line indicates the clone strategy to be used.
    3 Data Import Cron Source Format indicates whether golden images on this storage are stored as PVCs or volume snapshots.

Setting a default cloning strategy by using a storage profile

You can use storage profiles to set a default cloning method for a storage class by creating a cloning strategy. Setting cloning strategies can be helpful, for example, if your storage vendor supports only certain cloning methods. It also allows you to select a method that limits resource usage or maximizes performance.

Cloning strategies are specified by setting the cloneStrategy attribute in a storage profile to one of the following values:

  • snapshot is used by default when snapshots are configured. The Containerized Data Importer (CDI) will use the snapshot method if it recognizes the storage provider and the provider supports Container Storage Interface (CSI) snapshots. This cloning strategy uses a temporary volume snapshot to clone the volume.

  • copy uses a source pod and a target pod to copy data from the source volume to the target volume. Host-assisted cloning is the least efficient method of cloning.

  • csi-clone uses the CSI clone API to efficiently clone an existing volume without using an interim volume snapshot. Unlike snapshot or copy, which are used by default if no storage profile is defined, CSI volume cloning is only used when you specify it in the StorageProfile object for the provisioner’s storage class.

You can set clone strategies using the CLI without modifying the default claimPropertySets in your YAML spec section.

Example storage profile

apiVersion: cdi.kubevirt.io/v1beta1
kind: StorageProfile
metadata:
  name: <provisioner_class>
# ...
spec:
  claimPropertySets:
  - accessModes:
    - ReadWriteOnce (1)
    volumeMode:  Filesystem (2)
  cloneStrategy: csi-clone (3)
status:
  provisioner: <provisioner>
  storageClass: <provisioner_class>
1 Specify the accessModes.
2 Specify the volumeMode.
3 Specify the default cloneStrategy.