Data Volumes (DV) can also be created by specifying a PVC as an input source. It will trigger a clone of the original PVC. See more details here.
The CDI implementation of cloning a PVC is done with host assisted cloning by streaming the data from the source PVC and write to the new PVC.
In order to improve the performance of the cloning process, we introduced Smart-Cloning where snapshots are used.
CDI uses the feature of creating a PVC from snapshot in order to clone PVCs more efficiently when a CSI plugin with snapshot capabilities is available.
The yaml structure and annotations of the DV are not changed.
Kubernetes v1.12 introduced a feature enabling the creation of a PVC from a volume snapshot. See more details here
Note: To enable support for restoring a volume from a volume snapshot data source, enable the VolumeSnapshotDataSource
feature gate on the apiserver and controller-manager.
Here is a description of the flow of the Smart-Cloning:
- DataVolume is created with a PVC source
- Check if Smart-Cloning is possible:
- The source and target PVCs must be in the same Storage Class
- There must be a Snapshot Class associated with the Storage Class
- If Smart-Cloning is possible:
- Create a snapshot of the source PVC
- Create a PVC from the created snapshot
- Delete the snapshot
- Expand the new PVC if requested size is larger than the snapshot
- If the DataVolume is in a different namespace, "transfer" the PVC to the target namespace via Namespace Transfer API
- If Smart-Cloning is not possible:
- Trigger a (slower) host-assisted clone
Note: For some CSI driver when restoring from a snapshot, the new PVC size must equal the size of the PVC the snapshot was created from
If for some reason you don't want to use smart cloning and prefer using a host-assisted copy, you can disable smart cloning by editing the CDI object:
kubectl patch cdi cdi --type merge -p '{"spec":{"cloneStrategyOverride":"copy"}}'
To enable smart cloning again:
kubectl patch cdi cdi --type merge -p '{"spec":{"cloneStrategyOverride":"snapshot"}}'