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 in order 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 in order 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 in order 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:

    ...
    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 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 in order 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:

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

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

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