Volume Snapshots
This website/page will be End-of-life (EOL) after 31 August 2024. We recommend you to visit OpenEBS Documentation for the latest Mayastor documentation (v2.6 and above).
Mayastor is now also referred to as OpenEBS Replicated PV Mayastor.
Volume snapshots are copies of a persistent volume at a specific point in time. They can be used to restore a volume to a previous state or create a new volume. Mayastor provides support for industry standard copy-on-write (COW) snapshots, which is a popular methodology for taking snapshots by keeping track of only those blocks that have changed. Mayastor incremental snapshot capability enhances data migration and portability in Kubernetes clusters across different cloud providers or data centers. Using standard kubectl commands, you can seamlessly perform operations on snapshots and clones in a fully Kubernetes-native manner.
Use cases for volume snapshots include:
Efficient replication for backups.
Utilization of clones for troubleshooting.
Development against a read-only copy of data.
Volume snapshots allow the creation of read-only incremental copies of volumes, enabling you to maintain a history of your data. These volume snapshots possess the following characteristics:
Consistency: The data stored within a snapshot remains consistent across all replicas of the volume, whether local or remote.
Immutability: Once a snapshot is successfully created, the data contained within it cannot be modified.
Currently, Mayastor supports the following operations related to volume snapshots:
Creating a snapshot for a PVC
Listing available snapshots for a PVC
Deleting a snapshot for a PVC
Prerequisites
Deploy and configure Mayastor by following the steps given here and create disk pools.
Create a Mayastor StorageClass with single replica.
cat <<EOF | kubectl create -f -
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: mayastor-1
parameters:
ioTimeout: "30"
protocol: nvmf
repl: "1"
provisioner: io.openebs.csi-mayastor
EOFapiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: mayastor-1
parameters:
ioTimeout: "30"
protocol: nvmf
repl: "1"
provisioner: io.openebs.csi-mayastorCreate a PVC using these steps and check if the status of the PVC is Bound.
kubectl get pvcNAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
ms-volume-claim Bound pvc-fe1a5a16-ef70-4775-9eac-2f9c67b3cd5b 1Gi RWO mayastor-1 15sCopy the PVC name, for example,
ms-volume-claim.
(Optional) Create an application by following these steps.
Create a Snapshot
You can create a snapshot (with or without an application) using the PVC. Follow the steps below to create a volume snapshot:
Step 1: Create a Kubernetes VolumeSnapshotClass object
cat <<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
EOFkind: 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: DeleteName
String
Custom name of the snapshot class
Driver
String
CSI provisioner of the storage provider being requested to create a snapshot (io.openebs.csi-mayastor)
Apply VolumeSnapshotClass details
kubectl apply -f class.yamlvolumesnapshotclass.snapshot.storage.k8s.io/csi-mayastor-snapshotclass createdStep 2: Create the snapshot
cat <<EOF | kubectl create -f -
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshot
metadata:
name: mayastor-pvc-snap-1
spec:
volumeSnapshotClassName: csi-mayastor-snapshotclass
source:
persistentVolumeClaimName: ms-volume-claim
EOFapiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshot
metadata:
name: mayastor-pvc-snap-1
spec:
volumeSnapshotClassName: csi-mayastor-snapshotclass
source:
persistentVolumeClaimName: ms-volume-claim Name
String
Name of the snapshot
VolumeSnapshotClassName
String
Name of the created snapshot class
PersistentVolumeClaimName
String
Name of the PVC. Example- ms-volume-claim
Apply the snapshot
kubectl apply -f snapshot.yamlvolumesnapshot.snapshot.storage.k8s.io/mayastor-pvc-snap-1 createdList Snapshots
To retrieve the details of the created snapshots, use the following command:
kubectl get volumesnapshot NAME READYTOUSE SOURCEPVC SOURCESNAPSHOTCONTENT RESTORESIZE SNAPSHOTCLASS SNAPSHOTCONTENT CREATIONTIME AGE
mayastor-pvc-snap-1 true ms-volume-claim 1Gi csi-mayastor-snapshotclass snapcontent-174d9cd9-dfb2-4e53-9b56-0f3f783518df 57s 57skubectl get volumesnapshotcontentNAME 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-1 default 87sDelete a Snapshot
To delete a snapshot, use the following command:
kubectl delete volumesnapshot mayastor-pvc-snap-1 volumesnapshot.snapshot.storage.k8s.io "mayastor-pvc-snap-1" deletedLast updated
Was this helpful?