Storage defaults for data volumes

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

About storage settings for data volumes

Data volumes 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 config map in the openshift-cnv namespace. You can also add settings for other storage classes to create data volumes in the web console for different storage types.

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

All data volumes that you create in the web console use the default storage settings unless you specify a storage class that is also defined in the config map.

Access modes

Data volumes 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 file system or to remain in raw block state. Data volumes support the following volume modes:

  • Filesystem: Creates a file system on the data volume. This is the default setting.

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

Editing the kubevirt-storage-class-defaults config map in the web console

Modify the storage settings for data volumes by editing the kubevirt-storage-class-defaults config map in the openshift-cnv namespace. You can also add settings for other storage classes to create data volumes 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:

    1. ...
    2. data:
    3. accessMode: ReadWriteOnce (1)
    4. volumeMode: Filesystem (2)
    5. <new>.accessMode: ReadWriteMany (3)
    6. <new>.volumeMode: Block (4)
    1The default accessMode is ReadWriteOnce.
    2The default volumeMode is Filesystem.
    3If you add an access mode for a storage class, replace the <new> part of the parameter with the storage class name.
    4If 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 config map.

Editing the kubevirt-storage-class-defaults config map in the CLI

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

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

Procedure

  1. Edit the config map by running the following command:

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

    1. ...
    2. data:
    3. accessMode: ReadWriteOnce (1)
    4. volumeMode: Filesystem (2)
    5. <new>.accessMode: ReadWriteMany (3)
    6. <new>.volumeMode: Block (4)
    1The default accessMode is ReadWriteOnce.
    2The default volumeMode is Filesystem.
    3If you add an access mode for a storage class, replace the <new> part of the parameter with the storage class name.
    4If 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 config map.

Example of multiple storage class defaults

The following YAML file is an example of a kubevirt-storage-class-defaults config map 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 config map.

  1. kind: ConfigMap
  2. apiVersion: v1
  3. metadata:
  4. name: kubevirt-storage-class-defaults
  5. namespace: openshift-cnv
  6. ...
  7. data:
  8. accessMode: ReadWriteOnce
  9. volumeMode: Filesystem
  10. nfs-sc.accessMode: ReadWriteMany
  11. nfs-sc.volumeMode: Filesystem
  12. block-sc.accessMode: ReadWriteMany
  13. block-sc.volumeMode: Block