To restore your cloudsnap to a different namespace, you may use the following PVC object and create it under the different namespace while applying.
When you install Stork, it also creates a storage class called stork-snapshot-sc . This storage class can be used to create PVCs from snapshots.
To create a PVC from a snapshot, you would add the snapshot.alpha.kubernetes.io/snapshot
annotation to refer to the snapshot name.
– Restoring to same namespace:
Pre-requisites:
-
Name of the snapshot object
- You can get this withkubectl get volume snapshot -n test-namespace
Use the annotation:
snapshot.alpha.kubernetes.io/snapshot:
kubectl apply -f restore_pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mysql-snap-clone
annotations:
snapshot.alpha.kubernetes.io/snapshot: mysql-snapshot //This is exact snapshot name
spec:
accessModes:
- ReadWriteOnce
storageClassName: stork-snapshot-sc
resources:
requests:
storage: 2Gi
– Restoring to different namespace:
Pre-requisites:
-
Name of the snapshot object
- You can get this withkubectl get volumesnapshot -n test-namespace
NameSpace of the snapshot object currently
Lets say, you are trying to restore a PVC into a new namespace, other than the original namespace,
If the snapshot exists in another namespace, the snapshot namespace should be specified with the annotation in the restored PVC as follows:
stork.libopenstorage.org/snapshot-source-namespace: <EXISTING-NAMESPACE>
Note that the storageClassName needs to be the Stork StorageClass stork-snapshot-sc
as in the example below.
The following spec restores a PVC from the snapshot in the example above:
kubectl apply -f restore_pvc.yaml -n <NEW-NAMESPACE>
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mysql-snap-clone
annotations:
snapshot.alpha.kubernetes.io/snapshot: mysql-snapshot //This is exact snapshot name
stork.libopenstorage.org/snapshot-source-namespace: <Namespace of mysql-snapshot>
spec:
accessModes:
- ReadWriteOnce
storageClassName: stork-snapshot-sc
resources:
requests:
storage: 2Gi