Chapter 10. Volume Snapshots
A volume snapshot is the state of the storage volume in a cluster at a particular point in time. These snapshots help to use storage more efficiently by not having to make a full copy each time and can be used as building blocks for developing an application.
You can create multiple snapshots of the same persistent volume claim (PVC). For CephFS, you can create up to 100 snapshots per PVC. For RADOS Block Device (RBD), you can create up to 512 snapshots per PVC.
You cannot schedule periodic creation of snapshots.
10.1. Creating volume snapshots
You can create a volume snapshot either from the Persistent Volume Claim (PVC) page or the Volume Snapshots page.
Prerequisites
-
PVC must be in
Bound
state and must not be in use.
OpenShift Container Storage only provides crash consistency for a volume snapshot of a PVC if a pod is using it. For application consistency, be sure to first tear down a running pod to ensure consistent snapshots or use any quiesce mechanism provided by the application to ensure it.
Procedure
- From the Persistent Volume Claims page
-
Click Storage
Persistent Volume Claims from the OpenShift Web Console. To create a volume snapshot, do one of the following:
-
Beside the desired PVC, click Action menu (⋮)
Create Snapshot. -
Click on the PVC for which you want to create the snapshot and click Actions
Create Snapshot.
-
Beside the desired PVC, click Action menu (⋮)
- Enter a Name for the volume snapshot.
- Choose the Snapshot Class from the drop-down list.
- Click Create. You will be redirected to the Details page of the volume snapshot that is created.
-
Click Storage
- From the Volume Snapshots page
-
Click Storage
Volume Snapshots from the OpenShift Web Console. - In the Volume Snapshots page, click Create Volume Snapshot.
- Choose the required Project from the drop-down list.
- Choose the Persistent Volume Claim from the drop-down list.
- Enter a Name for the snapshot.
- Choose the Snapshot Class from the drop-down list.
- Click Create. You will be redirected to the Details page of the volume snapshot that is created.
-
Click Storage
Verification steps
- Go to the Details page of the PVC and click the Volume Snapshots tab to see the list of volume snapshots. Verify that the new volume snapshot is listed.
-
Click Storage
Volume Snapshots from the OpenShift Web Console. Verify that the new volume snapshot is listed. -
Wait for the volume snapshot to be in
Ready
state.
10.2. Restoring volume snapshots
When you restore a volume snapshot, a new Persistent Volume Claim (PVC) gets created. The restored PVC is independent of the volume snapshot and the parent PVC.
You can restore a volume snapshot from either the Persistent Volume Claim page or the Volume Snapshots page.
Procedure
- From the Persistent Volume Claims page
You can restore volume snapshot from the Persistent Volume Claims page only if the parent PVC is present.
-
Click Storage
Persistent Volume Claims from the OpenShift Web Console. - Click on the PVC name which has the volume snapshot that needs to be restored as a new PVC.
-
In the Volume Snapshots tab, beside the desired volume snapshot, click Action menu (⋮)
Restore as new PVC. - Enter a name for the new PVC.
Select the Storage Class name.
Note(For Rados Block Device (RBD)) You must select a storage class with the same pool as that of the parent PVC.
- Click Restore. You will be redirected to the new PVC details page.
-
Click Storage
- From the Volume Snapshots page
-
Click Storage
Volume Snapshots from the OpenShift Web Console. -
Beside the desired volume snapshot click Action Menu (⋮)
Restore as new PVC. - Enter a name for the new PVC.
Select the Storage Class name.
Note(For Rados Block Device (RBD)) You must select a storage class with the same pool as that of the parent PVC.
- Click Restore. You will be redirected to the new PVC details page.
-
Click Storage
When you restore volume snapshots, the PVCs are created with the access mode of the parent PVC only if the parent PVC exists. Otherwise, the PVCs are created only with the ReadWriteOnce (RWO) access mode. Currently, you cannot specify the access mode using the OpenShift Web Console. However, you can specify the access mode from the CLI using the YAML. For more information, see Restoring a volume snapshot.
Verification steps
-
Click Storage
Persistent Volume Claims from the OpenShift Web Console and confirm that the new PVC is listed in the Persistent Volume Claims page. -
Wait for the new PVC to reach
Bound
state.
10.3. Deleting volume snapshots
Prerequisites
- For deleting a volume snapshot, the volume snapshot class which is used in that particular volume snapshot should be present.
Procedure
- From Persistent Volume Claims page
-
Click Storage
Persistent Volume Claims from the OpenShift Web Console. - Click on the PVC name which has the volume snapshot that needs to be deleted.
-
In the Volume Snapshots tab, beside the desired volume snapshot, click Action menu (⋮)
Delete Volume Snapshot.
-
Click Storage
- From Volume Snapshots page
-
Click Storage
Volume Snapshots from the OpenShift Web Console. -
In the Volume Snapshots page, beside the desired volume snapshot click Action menu (⋮)
Delete Volume Snapshot.
-
Click Storage
Verfication steps
- Ensure that the deleted volume snapshot is not present in the Volume Snapshots tab of the PVC details page.
-
Click Storage
Volume Snapshots and ensure that the deleted volume snapshot is not listed.