Skip to content

Commit

Permalink
Add clone from VolumeSnapshot docs
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Kalenyuk <akalenyu@redhat.com>
  • Loading branch information
akalenyu committed Feb 8, 2023
1 parent 42ae2ab commit acaa016
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 1 deletion.
82 changes: 82 additions & 0 deletions doc/clone-from-volumesnapshot-source.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Data Volume cloning from a VolumeSnapshot source

## Introduction
Current CDI PVC cloning methods offer [smart cloning](./smart-clone.md) which uses a 1:1 cloning method that creates a temporary snapshot of the source PVC for each intended clone.
Some storage systems are designed to scale better with a 1:N method where a single snapshot of the source PVC is used to create multiple clones.
One examples is ceph, where this would be about utilizing RBD layering.
A much simpler example would be storage that can take around 5-10 minutes to snapshot a 200GB volume.

*Note: Data Volume cloning from snapshot source can work together with namespace transfer and size expansion*

### Prerequisites
1) The source snapshot and target PVC share the same provisioner
2) The user creating the DataVolume has permission to create the `datavolumes/source` resource in the source namespace
3) Storage supports expansion (if the user attempts clone to larger target)

### Flow Description
- DataVolume is created with a Snapshot source
- Check if restore from said snapshot to desired target is possible (as described in Prerequisites):
- If possible:
* Create the restore PVC
* Set the claim reference of the PV to point to the new target PVC ([namespace-transfer](./namespace-transfer.md))
- If not possible:
* Attempt [host-assisted cloning](./clone-datavolume.md) between 2 PVCs where CDI creates a temporary restore PVC (which will be cleaned up) from the snapshot to act as the source.

## Example
To kick off the process, we need a source volume snapshot.
We create a simple Data Volume that will act as a source for the snapshot.
```yaml
apiVersion: cdi.kubevirt.io/v1beta1
kind: DataVolume
metadata:
name: golden-snap-source
namespace: golden-ns
spec:
source:
http:
url: http://mirrors.nav.ro/fedora/linux/releases/33/Cloud/x86_64/images/Fedora-Cloud-Base-33-1.2.x86_64.qcow2
storage:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 8Gi
```
Next, we will create a VolumeSnapshot of the resulting PVC
```yaml
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshot
metadata:
name: golden-volumesnapshot
namespace: golden-ns
spec:
volumeSnapshotClassName: csi-rbdplugin-snapclass
source:
persistentVolumeClaimName: golden-snap-source
```
Double check snapshot is ready to use (not a must, but nice to know)
```bash
$ kubectl get volumesnapshot golden-volumesnapshot
NAME READYTOUSE SOURCEPVC SOURCESNAPSHOTCONTENT RESTORESIZE SNAPSHOTCLASS SNAPSHOTCONTENT CREATIONTIME AGE
golden-volumesnapshot true ...
```
Now we will go ahead and create the target DataVolume that clones the above VolumeSnapshot
```yaml
apiVersion: cdi.kubevirt.io/v1beta1
kind: DataVolume
metadata:
name: cloned-datavolume
namespace: default
spec:
source:
snapshot:
namespace: golden-ns
name: golden-volumesnapshot
storage:
storageClassName: rook-ceph-block
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 9Gi
```
1 change: 1 addition & 0 deletions doc/datavolumes.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ The following statuses are possible.
* Import/Clone/UploadInProgress: The operation (import/clone/upload) is in progress.
* SnapshotForSmartClone/SmartClonePVCInProgress: The Smart-Cloning operation is in progress.
* CSICloneInProgress: The CSI Volume Clone operation is in progress
* CloneFromSnapshotSourceInProgress: Clone from VolumeSnapshot source is in progress
* Paused: A [multi-stage](#multi-stage-import) import is waiting to transfer a new checkpoint.
* Succeeded: The operation has succeeded.
* Failed: The operation has failed.
Expand Down
3 changes: 2 additions & 1 deletion doc/efficient-cloning.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ _The required prerequisites in order to trigger efficient cloning methods_
4) The user creating the DataVolume has permission to create the `datavolumes/source` resource in the source namespace
5) The source volume is not in use

### Note: Data Volume Cloning can work together with namespace transfer and size expansion
*Note: Data Volume Cloning can work together with namespace transfer and size expansion*

### Additional Documentation
* DataVolumes: [datavolumes](./datavolumes.md)
* DataVolume Cloning: [clone-datavolumes](./clone-datavolume.md)
* CSI Volume Cloning: [csi-cloning](./csi-cloning.md)
* Cloning from VolumeSnapshot source: [clone-from-volumesnapshot-source](./clone-from-volumesnapshot-source.md)
* Smart Cloning: [smart-clone](./smart-clone.md)
* Namespace Transfer: [namespace-transfer](./namespace-transfer.md)
* StorageProfile (description of cloneStrategy): [storageprofile](./storageprofile.md)

0 comments on commit acaa016

Please sign in to comment.