This is a cache of https://docs.openshift.com/container-platform/4.3/cnv/cnv_virtual_machines/cnv_virtual_disks/cnv-storage-defaults-for-datavolumes.html. It is a snapshot of the page at 2024-11-23T02:15:39.298+0000.
Storage defaults for DataVolumes - Virtual machines | Container-native virtualization | OpenShift Container Platform 4.3
×

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 specifya 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. Use oc edit to edit the configmap:

    $ 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