Volume Snapshots
Volume Snapshots let you initialize persistent volume claims with the contents of an existing Volume Snapshot. Use them to work with large datasets, or to create application environments with real data from your production or staging environments.
Requirements
Volume Snapshots need a CSI driver that supports snapshots, and a VolumeSnapshotClass for that driver.
CSI driver installation
Volume Snapshots work with any CSI-compliant driver, such as:
- Google Compute Engine Persistent Disk CSI Driver
- Amazon EBS CSI driver
- DigitalOcean Block Storage CSI Driver
Follow your vendor's instructions to install and set up the driver.
VolumeSnapshotClass
Create a VolumeSnapshotClass in your cluster to set the CSI driver and the deletionPolicy for your VolumeSnapshots. For example:
- Amazon EBS
- GCE Persistent Disk
- DigitalOcean Block Storage
# okteto-snapshot-class.yaml
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshotClass
metadata:
name: okteto-snapshot-class
driver: ebs.csi.aws.com
deletionPolicy: Delete
# okteto-snapshot-class.yaml
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshotClass
metadata:
name: okteto-snapshot-class
driver: pd.csi.storage.gke.io
deletionPolicy: Delete
# okteto-snapshot-class.yaml
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshotClass
metadata:
name: okteto-snapshot-class
driver: dobs.csi.digitalocean.com
deletionPolicy: Delete
Save the manifest as okteto-snapshot-class.yaml and run the following command to create the VolumeSnapshotClass:
kubectl apply -f okteto-snapshot-class.yaml
StorageClass (optional)
You can also create a storage class for Okteto to use when it creates the volumes.
- Amazon EBS
- GCE Persistent Disk
- DigitalOcean Block Storage
# okteto-snapshot-sc.yaml
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: okteto-snapshot-sc
provisioner: ebs.csi.aws.com
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer
# okteto-snapshot-sc.yaml
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: okteto-snapshot-sc
provisioner: pd.csi.storage.gke.io
parameters:
type: pd-standard
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer
# okteto-snapshot-sc.yaml
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: okteto-snapshot-sc
provisioner: dobs.csi.digitalocean.com
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumer
Save the manifest as okteto-snapshot-sc.yaml and run the following command to create the StorageClass:
kubectl apply -f okteto-snapshot-sc.yaml
Enabling Volume Snapshots
To enable Volume Snapshots in your Okteto instance, add the following values to your config.yaml file and run a Helm upgrade to apply them.
The volumeSnapshots Helm configuration lists every available setting.
- Amazon EBS
- GCE Persistent Disk
- DigitalOcean Block Storage
volumeSnapshots:
enabled: true
driver: ebs.csi.aws.com
class: okteto-snapshot-class
storageClass: okteto-snapshot-sc
volumeSnapshots:
enabled: true
driver: pd.csi.storage.gke.io
class: okteto-snapshot-class
storageClass: okteto-snapshot-sc
volumeSnapshots:
enabled: true
driver: dobs.csi.digitalocean.com
class: okteto-snapshot-class
storageClass: okteto-snapshot-sc
By default, every user in your cluster can use any available snapshot as a data source for their application environments. To restrict this, set the enableNamespaceAccessValidation key to true in the volumeSnapshots section of the configuration.
Using Volume Snapshots in Application Environments
Volume Snapshots in Development Environments explains how to use Volume Snapshots in your application environments.