Cloning Volumes

Explore this Page

Overview

Cloning volumes is a powerful feature in that enables you to create new volumes either from existing snapshots or directly from existing volumes. This can be especially useful for backup, testing, or deploying duplicate environments with minimal effort and storage overhead. DataCore Puls8 supports cloning through Kubernetes Persistent Volume Claims (PVCs) by utilizing either a pre-created snapshot or another PVC as the data source.

This document provides detailed instructions to:

  • Clone a volume from an existing snapshot
  • Clone a volume directly from an existing volume

Cloning functionality requires Kubernetes 1.23 or later for native VolumeSnapshotDataSource support. If using an earlier version, the VolumeSnapshotDataSource feature gate must be enabled manually on both the kubelet and kube-apiserver components.

  • Cloning from snapshot is currently supported exclusively for Local PV ZFS and Replicated PV Mayastor.
  • Cloning from existing volume is only supported for Local PV ZFS.

Clone from a Snapshot

Requirements

Ensure your Kubernetes version is 1.23 or higher to avoid manual configuration. If using a version below 1.23, enable the VolumeSnapshotDataSource feature gate as follows:

  • kube-apiserver: --feature-gates=VolumeSnapshotDataSource=true
  • kubelet: --feature-gates=VolumeSnapshotDataSource=true

Creating a Clone from a Snapshot

To create a volume clone from a snapshot, define a new PersistentVolumeClaim (PVC) that references the snapshot as a data source.

Copy
YAML Definition for Clone from Snapshot
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: zfspv-clone
spec:
  storageClassName: puls8-zfspv
  dataSource:
    name: zfspv-snap
    kind: VolumeSnapshot
    apiGroup: snapshot.storage.k8s.io
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 4Gi

 

Copy
Apply the Clone PVC
kubectl apply -f clone.yaml
Copy
Sample Output
persistentvolumeclaim/zfspv-clone created
  • The clone PVC must be the same size as the original volume.
  • Clones must be created in the same ZFS pool (ZPOOL) as the source snapshot. Cloning across pools is not supported.
  • If using a different StorageClass, ensure it refers to the same ZPOOL.
Copy
Verify the Clone PVC
kubectl get pvc
Copy
Sample Output
NAME          STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS    AGE
csi-zfspv     Bound    pvc-73402f6e-d054-4ec2-95a4-eb8452724afb   4Gi        RWO            puls8-zfspv     13m
zfspv-clone   Bound    pvc-c095aa52-8d09-4bbe-ac3c-bb88a0e7be19   4Gi        RWO            puls8-zfspv     34s

 

Copy
Confirm Volume Creation via ZFS
zfs list -t all
Copy
Sample Output
NAME                                                                                               USED  AVAIL  REFER  MOUNTPOINT
test-pool                                                                                          834K  9.63G    24K  /test-pool
test-pool/pvc-73402f6e-d054-4ec2-95a4-eb8452724afb                                                  24K  4.00G    24K  /var/lib/kubelet/pods/3862895a-8a67-446e-80f7-f3c18881e391/volumes/kubernetes.io~csi/pvc-73402f6e-d054-4ec2-95a4-eb8452724afb/mount
test-pool/pvc-73402f6e-d054-4ec2-95a4-eb8452724afb@snapshot-3cbd5e59-4c6f-4bd6-95ba-7f72c9f12fcd     0B      -    24K  -
test-pool/pvc-c095aa52-8d09-4bbe-ac3c-bb88a0e7be19                                                   0B  9.63G    24K  none

 

Copy
View Clone Volume Metadata
kubectl describe zv pvc-c095aa52-8d09-4bbe-ac3c-bb88a0e7be19 -n puls8

Look for the Snapname field to confirm the volume is created from a snapshot:

Copy
Sample Output
Name:         pvc-c095aa52-8d09-4bbe-ac3c-bb88a0e7be19
Namespace:    puls8
Labels:       kubernetes.io/nodename=e2e1-node2
Annotations:  none
API Version:  openebs.io/v1alpha1
Kind:         ZFSVolume
Metadata:
  Creation Timestamp:  2020-02-25T08:34:25Z
  Finalizers:
    zfs.openebs.io/finalizer
  Generation:        1
  Resource Version:  448930
  Self Link:         /apis/openebs.io/v1alpha1/namespaces/puls8/zfsvolumes/pvc-c095aa52-8d09-4bbe-ac3c-bb88a0e7be19
  UID:               e38a9f9a-fb76-466b-a6f9-8d070e0bec6f
Spec:
  Capacity:       4294967296
  Fs Type:        zfs
  Owner Node ID:  e2e1-node2
  Pool Name:      test-pool
  Snapname:       pvc-73402f6e-d054-4ec2-95a4-eb8452724afb@snapshot-3cbd5e59-4c6f-4bd6-95ba-7f72c9f12fcd
  Volume Type:    DATASET
Events:           none

Clone from an Existing Volume

Creating a Clone from Another PVC

To create a clone directly from an existing PVC, specify the source PVC in the dataSource section of the new PVC manifest.

Copy
YAML Definition for Clone from Volume
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: zfspv-clone
spec:
  storageClassName: puls8-zfspv
  dataSource:
    name: zfspv-pvc
    kind: PersistentVolumeClaim
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 4Gi

 

Copy
Apply the Clone PVC
kubectl apply -f clone.yaml
Copy
Sample Output
persistentvolumeclaim/zfspv-clone created
  • The clone PVC size must match the source PVC size.
  • Both volumes must exist in the same ZPOOL.
Copy
Verify the PVCs
kubectl get pvc
Copy
Sample Output
NAME          STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS    AGE
zfspv-clone   Bound    pvc-b757fbca-f008-49c6-954e-7ea3e1c1bbc7   4Gi        RWO            puls8-zfspv     52s
zfspv-pvc     Bound    pvc-9df1e7ba-bcb1-414a-b318-5084f4f6edeb   4Gi        RWO            puls8-zfspv     92s

 

Copy
Confirm Volume Creation via ZFS
zfs list -t all
Copy
Sample Output
NAME                                                                                           USED  AVAIL  REFER  MOUNTPOINT
zfspv-pool                                                                                    4.26G   497G    24K  /zfspv-pool
zfspv-pool/pvc-9df1e7ba-bcb1-414a-b318-5084f4f6edeb                                           4.25G   502G   130M  -
zfspv-pool/pvc-9df1e7ba-bcb1-414a-b318-5084f4f6edeb@pvc-b757fbca-f008-49c6-954e-7ea3e1c1bbc7     0B      -   130M  -
zfspv-pool/pvc-b757fbca-f008-49c6-954e-7ea3e1c1bbc7                                             67K   497G   130M  -

 

Copy
View Clone Volume Metadata
kubectl describe zv pvc-b757fbca-f008-49c6-954e-7ea3e1c1bbc7 -n puls8

The Snapname field indicates the internal snapshot used for the clone:

Copy
Sample Output
Name:         pvc-b757fbca-f008-49c6-954e-7ea3e1c1bbc7
Namespace:    puls8
Labels:       kubernetes.io/nodename=pawan-node-1
              openebs.io/source-volume=pvc-9df1e7ba-bcb1-414a-b318-5084f4f6edeb
Annotations:  <none>
API Version:  zfs.openebs.io/v1
Kind:         ZFSVolume
Metadata:
  Creation Timestamp:  2020-12-10T05:00:54Z
  Finalizers:
    zfs.openebs.io/finalizer
  Generation:        2
  Resource Version:  53615100
  Self Link:         /apis/zfs.openebs.io/v1/namespaces/puls8/zfsvolumes/pvc-b757fbca-f008-49c6-954e-7ea3e1c1bbc7
  UID:               b67ea231-0f5c-4d15-918c-425160706953
Spec:
  Capacity:       4294967296
  Owner Node ID:  pawan-node-1
  Pool Name:      zfspv-pool
  Snapname:       pvc-9df1e7ba-bcb1-414a-b318-5084f4f6edeb@pvc-b757fbca-f008-49c6-954e-7ea3e1c1bbc7
  Volume Type:    ZVOL
Status:
  State:  Ready
Events:   <none>

When cloning from a volume, DataCore Puls8 automatically creates an internal snapshot on the source volume using the clone PVC name and then uses it to create the new volume.

Benefits of Cloning Volumes

  • Accelerates Application Deployment: Rapidly provision new environments using existing data to support development and testing needs.
  • Minimizes Storage Overhead: Cloning avoids full data duplication, making it highly space-efficient.
  • Simplifies Data Recovery: Enables quick restoration or rollback from a known good state.
  • Facilitates CI/CD Pipelines: Provides consistent data sets to streamline integration and testing processes.

Learn More