In order to enable volume snapshotting feature one your cluster, you first need to install the snapshot-controller as well as snapshot CRDs. You can do so by following those instructions.
You will also need to install the snapshot validation webhook, by following those instructions.
To create a snapshot of a volume, you first have to create a VolumeSnapshotClass
, which is equivalent of a StorageClass
but for snapshots. Then you can create a VolumeSnapshot
which use the newly created VolumeSnapshotClass
. You can follow this snapshot example. For more informations, please refer to the kubernetes documentation.
To restore a snapshot, you have to create a new PersistantVolumeClaim
and specify the desired snapshot as a dataSource. You can find an example here. You can also refer to the kubernetes documentation.
To clone a volume, you can follow the same procedure than to restore a snapshot, but configure another volume instead of a snapshot. An example can be found here and the kubernetes documentation here.
References:
- https://kubernetes.io/docs/concepts/storage/volume-snapshots
- https://github.com/kubernetes-csi/external-snapshotter
- https://kubernetes-csi.github.io/docs/snapshot-controller
- https://kubernetes-csi.github.io/docs/snapshot-validation-webhook
- https://kubernetes-csi.github.io/docs/snapshot-restore-feature
- https://kubernetes-csi.github.io/docs/volume-cloning
- https://github.com/kubernetes-csi/external-snapshotter/tree/release-4.0/examples/kubernetes