Skip to main content
Version: 1.9

Volume Snapshots

Volume snapshots allows you to initialize persistent volume claims with the contents of a preexisting volume snapshot. Use volume snapshots when working with large datasets or if you want to create development environments with real data coming from your production or staging environments.

Requirements

To use the Volume Snapshots feature, you must install a CSI driver that supports snapshots and create the corresponding VolumeSnapshotClass.

Installing the CSI Driver

Volume Snapshots is compatible with any CSI-compliant driver, such as:

Note: As of February 2021, if you're using the Amazon EBS CSI driver, you'll need to install the alpha version to enable Volume Snapshots. More information is available on their github repository.

We recommend you follow your vendor's installation instructions to learn more about this topic.

Create a VolumeSnapshotClass

Create a VolumeSnapshotClass in your cluster to determine the CSI driver and deletionPolicy for your VolumeSnapshots.

The following manifest is an example of a VolumeSnapshotClass:

# okteto-snapshot-class.yaml
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshotClass
metadata:
name: okteto-snapshot-class
driver: ebs.csi.aws.com
deletionPolicy: Delete

To create the VolumeSnapshotClass run the following command after creating the file.

kubectl apply -f okteto-snapshot-class.yaml

Create a StorageClass (optional)

Optionally, you can also create a storage class. This storage class will be used by Okteto when creating the volumes.

# 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

To create the StorageClass run the following command after creating the file.

kubectl apply -f okteto-snapshot-sc.yaml

Enabling Volume Snapshots

To enable Volume Snapshots on your Okteto instance, update your config.yaml file with the following values, and run a helm upgrade to apply the new configuration.

More information on the different configuration settings is available here.

volumeSnapshots:
enabled: true
driver: ebs.csi.aws.com
class: okteto-snapshot-class
storageClass: okteto-snapshot-sc

By default, all users in your cluster will be able to use any of the available snapshots as a data source for their development environments. You can limit this via the enableNamespaceAccessValidation key in the volumeSnapshots section of the configuration, value of true will enable the validation.

Using Volume Snapshots in your Development Environment

Follow this guide to use Volume Snapshots in your development environment.