Snapshot
The LVM driver supports creating snapshots of the LVM volumes. This requires the dm-snapshot
kernel module to be loaded. Certain settings are applied by the LVM driver which modifies the default behaviour of the LVM snapshot:
- Snapshots created by the LVM driver are ReadOnly by default as opposed to the ReadWrite snapshots created by default by
lvcreate
command. - The size of snapshot will be set to the size of the origin volume.
#
Default SnapshotClass without SnapSize ParameterIn the default snapshotclass case, for thin volumes, a thin snapshot will be created. Similarly, for thick volume, a thick snapshot will be created.
While creating the thick snapshot for thick volumes, since the snapsize parameter is not provided, the driver will reserve a size equal to the volume for snapshots.
#
SnapshotClass with Snapsize ParameterUsing the SnapshotClass snapSize
parameter we can configure the snapshot size for persistent volumes where snapSize
can be configured as a percentage or an absolute value.
In this case, whether the volume is thin provisioned or thick provisioned, the driver will create a thick snapshot with size as snapSize
mentioned in the SnapshotClass
.
- SnapshotClass with
snapSize
parameter as a percentage(%) value:
- SnapshotClass with
snapSize
parameter as a absolute value:
#
Steps to Create a SnapshotA SnapshotClass needs to be created. A sample SnapshotClass can be found here.
- Apply the SnapshotClass YAML.
- Find a PVC for which snapshot has to be created.
- Create the snapshot using the created SnapshotClass for the selected PVC.
- Apply the Snapshot YAML.
note
You have to create the snapshot in the same namespace where the PVC is created. Check the created snapshot resource and make sure readyToUsefield is true, before using this snapshot for any purpose.
- Check the OpenEBS resource for the created snapshot and make sure the status is
Ready
.
- To confirm that snapshot has been created, ssh into the node and check for LVM volumes.
#
LimitationsResize is not supported for volumes that have a snapshot. This is not an LVM limitation but is intentionally done from the LVM driver since LVM does not automatically resize the snapshots when the origin volume is resized.