Restore VolumeSnapshot
Restoring a VolumeSnapshot means creating a PVC while specifying the dataSource
field referencing to the target snapshot.
Precaution
- The new PVC must have the same access mode as the VolumeSnapshot.
- The new PVC must have the same storage value as the VolumeSnapshot.
Procedure
Create a YAML config
restore.yaml
. Specify the fielddataSource.name
.# Source: restore.yaml apiVersion: v1 kind: PersistentVolumeClaim metadata: name: example-restore spec: storageClassName: iomesh-csi-driver dataSource: name: example-snapshot # Specify the VolumeSnapshot. kind: VolumeSnapshot apiGroup: snapshot.storage.k8s.io accessModes: - ReadWriteOnce # Must be same as the access mode in the VolumeSnapshot. resources: requests: storage: 6Gi # Must be same as the storage value in the VolumeSnapshot.
Apply the YAML config to create the PVC.
kubectl apply -f restore.yaml
Check the PVC. A PV will be created and bounded to this PVC.
kubectl get pvc example-restore
If successful, you should see output like this:
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE example-restore Bound pvc-54230f3f-47dc-46e8-8c42-38c073c40598 6Gi RWO iomesh-csi-driver 21h
View the PV. You can find the PV name from the PVC output.
kubectl get pv pvc-54230f3f-47dc-46e8-8c42-38c073c40598 # The PV name you get in Step 3.
NAME CAPACITY RECLAIM POLICY STATUS CLAIM STORAGECLASS pvc-54230f3f-47dc-46e8-8c42-38c073c40598 6Gi Delete Bound example-restore iomesh-csi-driver