Cloning a data volume using smart-cloning

Smart-cloning is a built-in feature of Red Hat OpenShift Data Foundation. Smart-cloning is faster and more efficient than host-assisted cloning.

You do not need to perform any action to enable smart-cloning, but you need to ensure your storage environment is compatible with smart-cloning to use this feature.

When you create a data volume with a persistent volume claim (PVC) source, you automatically initiate the cloning process. You always receive a clone of the data volume if your environment supports smart-cloning or not. However, you will only receive the performance benefits of smart cloning if your storage provider supports smart-cloning.

About smart-cloning

When a data volume is smart-cloned, the following occurs:

  1. A snapshot of the source persistent volume claim (PVC) is created.

  2. A PVC is created from the snapshot.

  3. The snapshot is deleted.

Cloning a data volume

Prerequisites

For smart-cloning to occur, the following conditions are required:

  • Your storage provider must support snapshots.

  • The source and target PVCs must be defined to the same storage class.

  • The source and target PVCs share the same volumeMode.

  • The VolumeSnapshotClass object must reference the storage class defined to both the source and target PVCs.

Procedure

To initiate cloning of a data volume:

  1. Create a YAML file for a DataVolume object that specifies the name of the new data volume and the name and namespace of the source PVC. In this example, because you specify the storage API, there is no need to specify accessModes or volumeMode. The optimal values will be calculated for you automatically.

    1. apiVersion: cdi.kubevirt.io/v1beta1
    2. kind: DataVolume
    3. metadata:
    4. name: <cloner-datavolume> (1)
    5. spec:
    6. source:
    7. pvc:
    8. namespace: "<source-namespace>" (2)
    9. name: "<my-favorite-vm-disk>" (3)
    10. storage: (4)
    11. resources:
    12. requests:
    13. storage: <2Gi> (5)
    1The name of the new data volume.
    2The namespace where the source PVC exists.
    3The name of the source PVC.
    4Specifies allocation with the storage API
    5The size of the new data volume.
  2. Start cloning the PVC by creating the data volume:

    1. $ oc create -f <cloner-datavolume>.yaml

    Data volumes prevent a virtual machine from starting before the PVC is prepared, so you can create a virtual machine that references the new data volume while the PVC clones.

Additional resources