Shared content for Kubernetes snapshots - in-place restore PVC from snap
When you perform an in-place restore to a PVC, Stork takes the pods using that PVC offline, restores the volume from the snapshot, then brings the pods back online.
In-place restore using VolumeSnapshotRestore works only for applications deployed using the stork scheduler.
If you're not using the Stork scheduler, Portworx displays the following error when describing the VolumeSnapshotRestore resource:
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning Failed 5s (x2 over 15s) stork application not scheduled by stork scheduler
Create a
VolumeSnapshotRestoreYAML file specifying the following:apiVersion as
stork.libopenstorage.org/v1alpha1kind as
VolumeSnapshotRestoremetadata.name with the name of the object that performs the restore
metadata.namespace with the name of the target namespace
spec.sourceName with the name of the snapshot you want to restore
spec.sourceNamespace with the namespace in which the snapshot resides
The following example restores data from a snapshot called
mysql-snapshotwhich was created in themysql-snap-restore-splocalnamespace to a PVC calledmysql-snap-inrestorein thedefaultnamespace:apiVersion: stork.libopenstorage.org/v1alpha1
kind: VolumeSnapshotRestore
metadata:
name: mysql-snap-inrestore
namespace: default
spec:
sourceName: mysql-snapshot
sourceNamespace: mysql-snap-restore-splocal
Place the spec into a file called
mysql-cloud-snapshot-restore.yamland apply it:kubectl apply -f mysql-cloud-snapshot-restore.yamlYou can enter the following command to see the status of the restore process:
storkctl get volumesnapshotrestoreNAME SOURCE-SNAPSHOT SOURCE-SNAPSHOT-NAMESPACE STATUS VOLUMES CREATED
mysql-snap-inrestore mysql-snapshot default Successful 1 23 Sep 19 21:55 EDTYou can also use the
kubectl describecommand to retrieve more detailed information about the status of the restore process.Example:
kubectl describe volumesnapshotrestore mysql-snap-inrestoreName: mysql-snap-inrestore
Namespace: default
Labels: <none>
Annotations: kubectl.kubernetes.io/last-applied-configuration:
{"apiVersion":"stork.libopenstorage.org/v1alpha1","kind":"VolumeSnapshotRestore","metadata":{"annotations":{},"name":"mysql-snap-inrestore...
API Version: stork.libopenstorage.org/v1alpha1
Kind: VolumeSnapshotRestore
Metadata:
Creation Timestamp: 2019-09-23T17:24:30Z
Generation: 5
Resource Version: 904014
Self Link: /apis/stork.libopenstorage.org/v1alpha1/namespaces/default/volumesnapshotrestores/mysql-snap-inrestore
UID: 00474a5c-de27-11e9-986b-000c295d6364
Spec:
Group Snapshot: false
Source Name: mysql-snapshot
Source Namespace: default
Status:
Status: Successful
Volumes:
Namespace: default
Pvc: mysql-data
Reason: Restore is successful
Snapshot: k8s-volume-snapshot-cb909cf9-de26-11e9-ad56-320ff611f4ca
Status: Successful
Volume: pvc-8b996a17-de26-11e9-986b-000c295d6364
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Successful 0s stork Snapshot in-Place Restore completed