Create and use cloud snapshots
This document will show you how to create cloud snapshots of Portworx volumes and how you can clone those snapshots to use them in pods.
Back up a volume and restore it to the same Portworx cluster
This requires that you already have Stork installed and running on your Kubernetes cluster. If you fetched the Portworx specs from the Portworx spec generator in PX-Central and used the default options, Stork is already installed.
Cloud snapshots using below method is supported in Portworx version 1.4 and above. Cloud snapshots (for aggregated volumes) using below method is supported in Portworx version 2.0 and above.
Configuring cloud secrets
To create cloud snapshots, one needs to setup secrets with Portworx which will get used to connect and authenticate with the configured cloud provider.
Follow instructions on the pxctl credentials page to setup secrets.
Creating cloud snapshots
With cloud snapshots, you can either snapshot individual PVCs one by one or snapshot a group of PVCs.
Cloud backups for single PVCs
Instructions for backing up a PVC with consistency to cloud and restore PVCs from the backup
Cloud backups for group of PVCs
Instructions for backing up a group of PVCs with consistency to cloud and restore PVCs from the backups
Creating PVCs from cloud snapshots
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
If the snapshot exists in another namespace, the snapshot namespace should be specified with
stork/snapshot-source-namespace annotation in the PVC.
Note that the storageClassName needs to be the Stork StorageClass
stork-snapshot-sc as in the example below.
For the above snapshot, the spec would like this:
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: mysql-snap-clone annotations: snapshot.alpha.kubernetes.io/snapshot: mysql-snapshot spec: accessModes: - ReadWriteOnce storageClassName: stork-snapshot-sc resources: requests: storage: 2Gi
Once you apply the above spec, you will see a PVC created by Stork. This PVC will be backed by a Portworx volume clone of the snapshot created above.
kubectl get pvc
NAMESPACE NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE default mysql-data Bound pvc-f782bf5c-20e7-11e8-931d-0214683e8447 2Gi RWO px-mysql-sc 2d default mysql-snap-clone Bound pvc-05d3ce48-2280-11e8-98cc-0214683e8447 2Gi RWO stork-snapshot-sc 2s
- To create PVCs from existing snapshots, read Creating PVCs from cloud snapshots.
- To create PVCs from group snapshots, read Creating PVCs from group snapshots.