The kubevirt-storage-class-defaults ConfigMap provides access mode and volume mode defaults for DataVolumes. You can edit or add storage class defaults to the ConfigMap in order to create DataVolumes in the web console that better match the underlying storage.

About storage settings for DataVolumes

DataVolumes require a defined access mode and volume mode to be created in the web console. These storage settings are configured by default with a ReadWriteOnce access mode and Filesystem volume mode.

You can modify these settings by editing the kubevirt-storage-class-defaults ConfigMap in the openshift-cnv namespace. You can also add settings for other storage classes in order to create DataVolumes in the web console for different storage types.

You must configure storage settings that are supported by the underlying storage.

All DataVolumes that you create in the web console use the default storage settings unless you specify a storage class that is also defined in the ConfigMap.

Access modes

DataVolumes support the following access modes:

  • ReadWriteOnce: The volume can be mounted as read-write by a single node. ReadWriteOnce has greater versatility and is the default setting.

  • ReadWriteMany: The volume can be mounted as read-write by many nodes. ReadWriteMany is required for some features, such as live migration of virtual machines between nodes.

ReadWriteMany is recommended if the underlying storage supports it.

Volume modes

The volume mode defines if a volume is intended to be used with a formatted filesystem or to remain in raw block state. DataVolumes support the following volume modes:

  • Filesystem: Creates a filesystem on the DataVolume. This is the default setting.

  • Block: Creates a block DataVolume. Only use Block if the underlying storage supports it.

Editing the kubevirt-storage-class-defaults ConfigMap in the web console

Modify the storage settings for DataVolumes by editing the kubevirt-storage-class-defaults ConfigMap in the openshift-cnv namespace. You can also add settings for other storage classes in order to create DataVolumes in the web console for different storage types.

You must configure storage settings that are supported by the underlying storage.

Procedure
  1. Click WorkloadsConfig Maps from the side menu.

  2. In the Project list, select openshift-cnv.

  3. Click kubevirt-storage-class-defaults to open the Config Map Overview.

  4. Click the YAML tab to display the editable configuration.

  5. Update the data values with the storage configuration that is appropriate for your underlying storage:

    ...
    data:
      accessMode: ReadWriteOnce (1)
      volumeMode: Filesystem (2)
      <new>.accessMode: ReadWriteMany (3)
      <new>.volumeMode: Block (4)
    1 The default accessMode is ReadWriteOnce.
    2 The default volumeMode is Filesystem.
    3 If you add an access mode for a storage class, replace the <new> part of the parameter with the storage class name.
    4 If you add a volume mode for a storage class, replace the <new> part of the parameter with the storage class name.
  6. Click Save to update the ConfigMap.

Editing the kubevirt-storage-class-defaults ConfigMap in the CLI

Modify the storage settings for DataVolumes by editing the kubevirt-storage-class-defaults ConfigMap in the openshift-cnv namespace. You can also add settings for other storage classes in order to create DataVolumes in the web console for different storage types.

You must configure storage settings that are supported by the underlying storage.

Procedure
  1. Edit the ConfigMap by running the following command:

    $ oc edit configmap kubevirt-storage-class-defaults -n openshift-cnv
  2. Update the data values of the ConfigMap:

    ...
    data:
      accessMode: ReadWriteOnce (1)
      volumeMode: Filesystem (2)
      <new>.accessMode: ReadWriteMany (3)
      <new>.volumeMode: Block (4)
    1 The default accessMode is ReadWriteOnce.
    2 The default volumeMode is Filesystem.
    3 If you add an access mode for storage class, replace the <new> part of the parameter with the storage class name.
    4 If you add a volume mode for a storage class, replace the <new> part of the parameter with the storage class name.
  3. Save and exit the editor to update the ConfigMap.

Example of multiple storage class defaults

The following YAML file is an example of a kubevirt-storage-class-defaults ConfigMap that has storage settings configured for two storage classes, migration and block.

Ensure that all settings are supported by your underlying storage before you update the ConfigMap.

kind: ConfigMap
apiVersion: v1
metadata:
  name: kubevirt-storage-class-defaults
  namespace: openshift-cnv
...
data:
  accessMode: ReadWriteOnce
  volumeMode: Filesystem
  nfs-sc.accessMode: ReadWriteMany
  nfs-sc.volumeMode: Filesystem
  block-sc.accessMode: ReadWriteMany
  block-sc.volumeMode: Block