Volume Snapshots
Explore this Page
- Overview
- Requirements
- Volume Snapshots for Replicated PV Mayastor
- Volume Snapshots for Local PV ZFS
- Benefits of Volume Snapshots
Overview
Volume Snapshots enable point-in-time, consistent copies of persistent volumes managed by storages such as Replicated PV Mayastor and Local PV ZFS. These snapshots are critical for data protection, backup and restore, disaster recovery, and migration use cases in Kubernetes environments.
DataCore Puls8 supports copy-on-write (COW) based snapshots that capture only the changed blocks, thereby improving storage efficiency. Snapshots can be created, listed, and deleted using standard Kubernetes commands.
Typical use cases include:
- Backup and disaster recovery
- Application cloning and testing
- Rollbacks or troubleshooting
Snapshots are:
- Consistent: Data remains consistent across all volume replicas.
- Immutable: Once created, snapshot data cannot be altered.
Snapshots are not reconstructable in the event of node failure, unlike volume replicas.
Requirements
Before using Volume Snapshots, ensure the following requirements are met:
- Kubernetes cluster with CSI snapshot CRDs installed.
- CSI Snapshot Controller is deployed and running.
- DataCore Puls8 is installed and configured with:
- Replicated PV Mayastor
- Local PV ZFS
- DiskPools are created and operational (For Replicated PV Mayastor).
- A PVC is deployed using a compatible StorageClass.
Volume Snapshots for Replicated PV Mayastor
This section explains how to create, manage, and validate volume snapshots for persistent volumes provisioned by Replicated PV Mayastor. These snapshots are block-level, application-consistent, and support advanced storage capabilities such as incremental backup and thin provisioning.
Creating a StorageClass
cat <<EOF | kubectl create -f -
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: mayastor-3
parameters:
protocol: nvmf
repl: "3"
provisioner: io.openebs.csi-mayastor
EOF
Create and Verify a PVC
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
ms-volume-claim Bound pvc-fe1a5a16-ef70-4775-9eac-2f9c67b3cd5b 1Gi RWO mayastor-3 15s
Copy the PVC name (ms-volume-claim
in this case) for later use.
Ensure an application is deployed using the created PVC, as described in the Deploy an Application documentation.
Creating a Volume Snapshot
Snapshots can be created either with an active application or directly from the PVC.
-
Define the VolumeSnapshotClass.
CopyCreate a Default VolumeSnapshotClass for Replicated PV Mayastorcat <<EOF | kubectl create -f -
kind: VolumeSnapshotClass
apiVersion: snapshot.storage.k8s.io/v1
metadata:
name: csi-mayastor-snapshotclass
annotations:
snapshot.storage.kubernetes.io/is-default-class: "true"
driver: io.openebs.csi-mayastor
deletionPolicy: Delete
EOFAlternatively, apply using a YAML file:
-
Create the Snapshot.
CopyCreate a VolumeSnapshot from an Existing PVCcat <<EOF | kubectl create -f -
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshot
metadata:
name: mayastor-pvc-snap
spec:
volumeSnapshotClassName: csi-mayastor-snapshotclass
source:
persistentVolumeClaimName: ms-volume-claim
EOFSnapshots on thick-provisioned volumes are automatically converted to thin-provisioned volumes.
Listing Snapshots
Use the following commands to view snapshot and snapshot content details.
NAME READYTOUSE SOURCEPVC SOURCESNAPSHOTCONTENT RESTORESIZE SNAPSHOTCLASS SNAPSHOTCONTENT CREATIONTIME AGE
mayastor-pvc-snap true ms-volume-claim 1Gi csi-mayastor-snapshotclass snapcontent-174d9cd9-dfb2-4e53-9b56-0f3f783518df 57s 57s
NAME READYTOUSE RESTORESIZE DELETIONPOLICY DRIVER VOLUMESNAPSHOTCLASS VOLUMESNAPSHOT VOLUMESNAPSHOTNAMESPACE AGE
snapcontent-174d9cd9-dfb2-4e53-9b56-0f3f783518df true 1073741824 Delete io.openebs.csi-mayastor csi-mayastor-snapshotclass mayastor-pvc-snap default 87s
Deleting a Snapshot
Use the following commands to delete a snapshot.
Filesystem Consistent Snapshots
DataCore Puls8 supports filesystem-consistent snapshots by default. This ensures data integrity by quiescing active I/O operations using the FIFREEZE
and FITHAW
ioctls during snapshot creation. If the filesystem quiescing process fails, the entire snapshot operation is retried automatically by the Mayastor CSI controller.
To disable filesystem quiescing, modify the VolumeSnapshotClass
as follows:
kind: VolumeSnapshotClass
apiVersion: snapshot.storage.k8s.io/v1
metadata:
name: csi-mayastor-snapshotclass
annotations:
snapshot.storage.kubernetes.io/is-default-class: "true"
parameters:
quiesceFs: none
driver: io.openebs.csi-mayastor
deletionPolicy: Delete
Snapshot Space Requirement
When creating snapshots for an existing volume, each replica pool must have sufficient free space relative to the volume size. The minimum required free space is governed by the following configuration parameter:
openebs.mayastor.agents.core.capacity.thin.snapshotCommitment
This parameter specifies the required free space as a percentage of the volume size.
Example:
If the value is set to 40, and a pool has 40 GiB of free space, then the maximum volume size allowed for snapshot creation on that pool is 100 GiB.
Adjusting this parameter ensures that snapshots do not exceed the pool’s storage capacity, helping to maintain system stability and avoid failures during snapshot operations.
Volume Snapshots for Local PV ZFS
This section explains the process for creating and managing volume snapshots for Local PV ZFS volumes. ZFS snapshots are file-system level, point-in-time copies that support clone and backup workflows in Kubernetes environments.
Creating a Volume Snapshot
-
Define the VolumeSnapshotClass.
CopyCreate a Default VolumeSnapshotClass for Local PV ZFS$ cat snapshotclass.yaml
kind: VolumeSnapshotClass
apiVersion: snapshot.storage.k8s.io/v1
metadata:
name: zfspv-snapclass
annotations:
snapshot.storage.kubernetes.io/is-default-class: "true"
driver: zfs.csi.openebs.io
deletionPolicy: DeleteAlternatively, apply using a YAML file:
-
Identify the PVC.
CopySample OutputNAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
csi-zfspv Bound pvc-73402f6e-d054-4ec2-95a4-eb8452724afb 4Gi RWO openebs-zfspv 2m35s -
Create the Snapshot.
CopyCreate a VolumeSnapshot$ cat snapshot.yaml
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshot
metadata:
name: zfspv-snap
spec:
volumeSnapshotClassName: zfspv-snapclass
source:
persistentVolumeClaimName: csi-zfspvCreate the snapshot in the same namespace as the PVC. Ensure
readyToUse: true
before using the snapshot.
Listing Snapshots
Use the following commands to view snapshot and snapshot content details.
NAME READYTOUSE SOURCEPVC SOURCESNAPSHOTCONTENT RESTORESIZE SNAPSHOTCLASS SNAPSHOTCONTENT CREATIONTIME AGE
zfspv-snap true csi-zfspv - 4Gi zfspv-snapclass snapcontent-b747cc44-6845-4e72-b0a9-4fb65858e013 106s 106s
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshot
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"snapshot.storage.k8s.io/v1","kind":
"VolumeSnapshot","metadata":{"annotations":{},"name":
"zfspv-snap","namespace":"default"},"spec":{"source":{"persistentVolumeClaimName":"csi-zfspv"},"volumeSnapshotClassName":"zfspv-snapclass"}}
creationTimestamp: "2020-02-25T08:25:51Z"
finalizers:
- snapshot.storage.kubernetes.io/volumesnapshot-as-source-protection
- snapshot.storage.kubernetes.io/volumesnapshot-bound-protection
generation: 1
name: zfspv-snap
namespace: puls8
resourceVersion: "447494"
selfLink: /apis/snapshot.storage.k8s.io/v1/namespaces/default/volumesnapshots/zfspv-snap
uid: 3cbd5e59-4c6f-4bd6-95ba-7f72c9f12fcd
spec:
source:
persistentVolumeClaimName: csi-zfspv
volumeSnapshotClassName: zfspv-snapclass
status:
boundVolumeSnapshotContentName: snapcontent-3cbd5e59-4c6f-4bd6-95ba-7f72c9f12fcd
creationTime: "2020-02-25T08:25:51Z"
readyToUse: true
restoreSize: "0"
Verifying Local PV ZFS Snapshot CR
Check the custom resource created by the ZFS driver.
kubectl get zfssnap snapshot-3cbd5e59-4c6f-4bd6-95ba-7f72c9f12fcd -n puls8 -o yaml
apiVersion: openebs.io/v1alpha1
kind: ZFSSnapshot
metadata:
creationTimestamp: "2020-02-25T08:25:51Z"
finalizers:
- zfs.openebs.io/finalizer
generation: 2
labels:
kubernetes.io/nodename: e2e1-node2
openebs.io/persistent-volume: pvc-73402f6e-d054-4ec2-95a4-eb8452724afb
name: snapshot-3cbd5e59-4c6f-4bd6-95ba-7f72c9f12fcd
namespace: puls8
resourceVersion: "447328"
selfLink: /apis/openebs.io/v1alpha1/namespaces/openebs/zfssnapshots/snapshot-3cbd5e59-4c6f-4bd6-95ba-7f72c9f12fcd
uid: 6142492c-3785-498f-aa4a-569ec6c0e2b8
spec:
capacity: "4294967296"
fsType: zfs
ownerNodeID: e2e1-node2
poolName: test-pool
volumeType: DATASET
status:
state: Ready
Node-Level Validation
Validate snapshot presence directly on the node.
NAME USED AVAIL REFER MOUNTPOINT
test-pool 818K 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 -
Benefits of Volume Snapshots
- Enables point-in-time backup for critical applications.
- Facilitates fast and reliable disaster recovery.
- Minimizes downtime by enabling quick volume restores.
- Simplifies data migration across environments or clusters.
Learn More