Volume Snapshots for Self-Hosted Okteto
Volume Snapshots allow you to initialize persistent volume claims with the contents of a preexisting Volume Snapshot. Use Volume Snapshots when working with large datasets or to create Development Environments with real data 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.
CSI driver installation
Volume Snapshots are compatible with any CSI-compliant driver, such as:
- Google Compute Engine Persistent Disk CSI Driver
- Amazon EBS CSI driver
- DigitalOcean Block Storage CSI Driver
As of February 2021, if you use the Amazon EBS CSI driver, you need to install the alpha version to enable Volume Snapshots. See the AWS EBS CSI driver repository for details.
Follow your vendor's installation instructions for driver-specific setup details.
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:
- 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
To create the VolumeSnapshotClass, run the following command after creating the file:
kubectl apply -f okteto-snapshot-class.yaml
StorageClass (optional)
Optionally, you can also create a storage class. Okteto uses this storage class when creating 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
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.
See the Volume Snapshots Helm configuration for all available settings.
- 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, all users in your cluster can use any available snapshot as a data source for their Development Environments. To restrict this, set the enableNamespaceAccessValidation key to true in the volumeSnapshots section of the configuration.
Using Volume Snapshots in your Development Environment
Follow this guide to use Volume Snapshots in your development environment.