When you create a data volume using the storage API, the Containerized Data Interface (CDI) optimizes your persistent volume claim (PVC) allocation based on the type of storage supported by your selected storage class. You only have to specify the data volume name, namespace, and the amount of storage that you want to allocate.
-
When using Ceph RBD, accessModes
is automatically set to ReadWriteMany
, which enables live migration. volumeMode
is set to Block
to maximize performance.
-
When you are using volumeMode: Filesystem
, more space will automatically be requested by the CDI, if required to accommodate file system overhead.
In the following YAML, using the storage API requests a data volume with two gigabytes of usable space. The user does not need to know the volumeMode
in order to correctly estimate the required persistent volume claim (PVC) size. The CDI chooses the optimal combination of accessModes
and volumeMode
attributes automatically. These optimal values are based on the type of storage or the defaults that you define in your storage profile. If you want to provide custom values, they override the system-calculated values.
Example DataVolume definition
apiVersion: cdi.kubevirt.io/v1beta1
kind: DataVolume
metadata:
name: <datavolume> (1)
spec:
source:
pvc: (2)
namespace: "<source_namespace>" (3)
name: "<my_vm_disk>" (4)
storage: (5)
resources:
requests:
storage: 2Gi (6)
storageClassName: <storage_class> (7)
1 |
The name of the new data volume. |
2 |
Indicate that the source of the import is an existing persistent volume claim (PVC). |
3 |
The namespace where the source PVC exists. |
4 |
The name of the source PVC. |
5 |
Indicates allocation using the storage API. |
6 |
Specifies the amount of available space that you request for the PVC. |
7 |
Optional: The name of the storage class. If the storage class is not specified, the system default storage class is used. |