Snapshots
Prerequisites¶
-
Rook officially supports v1 snapshots for Kubernetes v1.20+.
-
Install the snapshot controller and snapshot v1 CRD as required. More info can be found here.
Note
If only Alpha snapshots are available, enable snapshotter in rook-ceph-operator-config
or helm chart values.yaml
, change the external-snapshotter image to registry.k8s.io/sig-storage/csi-snapshotter:v1.2.2
and refer to the alpha snapshots documentation
VolumeSnapshot betav1 is deprecated in Kubernetes 1.20+ and removed in 1.24.0. If you still require betav1 snapshots, change the external-snapshotter image to registry.k8s.io/sig-storage/csi-snapshotter:v5.0.1
and refer to the betav1 snapshots documentation
- We also need a
VolumeSnapshotClass
for volume snapshot to work. The purpose of aVolumeSnapshotClass
is defined in the kubernetes documentation. In short, as the documentation describes it:
Info
Just like StorageClass provides a way for administrators to describe the "classes" of storage they offer when provisioning a volume, VolumeSnapshotClass provides a way to describe the "classes" of storage when provisioning a volume snapshot.
Upgrade Snapshot API¶
If your Kubernetes version is updated to a newer version of the snapshot API, follow the upgrade guide here to upgrade from v1alpha1 to v1beta1, or v1beta1 to v1.
RBD Snapshots¶
VolumeSnapshotClass¶
In VolumeSnapshotClass, the csi.storage.k8s.io/snapshotter-secret-name
parameter should reference the name of the secret created for the rbdplugin and pool
to reflect the Ceph pool name.
Update the value of the clusterID
field to match the namespace that Rook is running in. When Ceph CSI is deployed by Rook, the operator will automatically maintain a configmap whose contents will match this key. By default this is "rook-ceph".
Volumesnapshot¶
In snapshot, volumeSnapshotClassName
should be the name of the VolumeSnapshotClass
previously created. The persistentVolumeClaimName
should be the name of the PVC which is already created by the RBD CSI driver.
Verify RBD Snapshot Creation¶
The snapshot will be ready to restore to a new PVC when the READYTOUSE
field of the volumesnapshot
is set to true.
Restore the snapshot to a new PVC¶
In pvc-restore, dataSource
should be the name of the VolumeSnapshot
previously created. The dataSource
kind should be the VolumeSnapshot
.
Create a new PVC from the snapshot
Verify RBD Clone PVC Creation¶
RBD snapshot resource Cleanup¶
To clean your cluster of the resources created by this example, run the following:
CephFS Snapshots¶
VolumeSnapshotClass¶
In VolumeSnapshotClass, the csi.storage.k8s.io/snapshotter-secret-name
parameter should reference the name of the secret created for the cephfsplugin.
In the volumesnapshotclass, update the value of the clusterID
field to match the namespace that Rook is running in. When Ceph CSI is deployed by Rook, the operator will automatically maintain a configmap whose contents will match this key. By default this is "rook-ceph".
VolumeSnapshot¶
In snapshot, volumeSnapshotClassName
should be the name of the VolumeSnapshotClass
previously created. The persistentVolumeClaimName
should be the name of the PVC which is already created by the CephFS CSI driver.
Verify CephFS Snapshot Creation¶
The snapshot will be ready to restore to a new PVC when READYTOUSE
field of the volumesnapshot
is set to true.
Restore the snapshot to a new PVC¶
In pvc-restore, dataSource
should be the name of the VolumeSnapshot
previously created. The dataSource
kind should be the VolumeSnapshot
.
Create a new PVC from the snapshot
Verify CephFS Restore PVC Creation¶
CephFS snapshot resource Cleanup¶
To clean your cluster of the resources created by this example, run the following:
Limitations¶
- There is a limit of 400 snapshots per cephFS filesystem.
- The PVC cannot be deleted if it has snapshots. make sure all the snapshots on the PVC are deleted before you delete the PVC.