velero-plugin-for-csi icon indicating copy to clipboard operation
velero-plugin-for-csi copied to clipboard

Support multiple snapshot classes per driver

Open blampe opened this issue 2 years ago • 2 comments

The plugin currently only supports one VolumeSnapshotClass via the "velero.io/csi-volumesnapshot-class" label. If a driver has more than one VolumeSnapshotClass with this label, there is no way to control which one will be used for backups.

It's not unusual to have multiple snapshot classes -- e.g. one for in-cluster snapshots, another for off-site backups -- and it would be enormously convenient to be able to use the CSI plugin to drive backups for all such classes.

To that end, this change introduces a new label "velero.io/csi-volumesnapshot-location" applied to VolumeSnapshotClass. If the value of this label matches one of the VolumeSnapshotLocations used by the backup, then that VolumeSnapshotClass will be used. This allows the user to control which VolumeSnapshotClasses is used for a particular driver based on their choice of volume snapshot location.

Existing behavior is unchanged.

blampe avatar Aug 29 '22 06:08 blampe

 If a driver has more than one VolumeSnapshotClass with this label, there is no way to control which one will be used for backups.

This should not happen, b/c the label is set to control which one will be used for backups of velero?

reasonerjt avatar Aug 29 '22 08:08 reasonerjt

This should not happen, b/c the label is set to control which one will be used for backups of velero?

@reasonerjt it's just a label, and the same label can be applied to any number of snapshot classes. Are you asking why someone would want multiple snapshot classes to be tagged with this label? I address that in the next sentence:

It's not unusual to have multiple snapshot classes -- e.g. one for in-cluster snapshots, another for off-site backups -- and it would be enormously convenient to be able to use the CSI plugin to drive backups for all such classes.

Restricting Velero to one snapshot class per driver is unnecessarily restrictive.

Example: I'd like to schedule daily backups for in-cluster snapshots, weekly backups for in-cluster object storage, and monthly off-site backups. Each of those scenarios has its own VolumeSnapshotClass. Currently, Velero can only satisfy one of these scenarios; this PR allows it to support all three.

blampe avatar Sep 16 '22 03:09 blampe

Wouldn't be a better solution to specify VolumeSnapshotClass by passing volumeSnapshotClass to velero.io/v1 - VolumeSnapshotLocation?

@blampe @reasonerjt wdyt?

iosifnicolae2 avatar Dec 21 '22 11:12 iosifnicolae2

Also, it seems that volumeSnapshotLocations from Backup CRD is not used at all by this plugin, right?

iosifnicolae2 avatar Dec 21 '22 11:12 iosifnicolae2

VolumeSnapshotLocations are used by VolumeSnapshotter plugins (aws, azure, gcp). The CSI plugin does not use them, since the CSI plugin doesn't interact with out-of-cluster cloud resources.

sseago avatar Dec 22 '22 21:12 sseago

Hi @reasonerjt! I would also like to share an other use case.

In our setup, all our snapshots requires tags to identity the source of the snapshots. By default, the CSI Snapshot driver to not create any tags.

We need a dedicated SnapshotClass for each Namespace/Customer, like:

apiVersion: snapshot.storage.k8s.io/v1beta1
kind: VolumeSnapshotClass
metadata:
  name: csi-azuredisk-vsc-inc-1000100
driver: disk.csi.azure.com
deletionPolicy: Delete
parameters:
  tags: 'mandantID=1000100'

For example, 1000100 is a reference.

In conclusion, we have multiple VolumeSnapshotClasses for one CSI StorageClass. Currently, I'm not able to define the snapshop class in velero. Maybe an annotation on the PVC are the rescue here for the future.

jkroepke avatar Jan 17 '23 13:01 jkroepke

@blampe you can consider closing this PR since this is being addressed in #178

anshulahuja98 avatar Jun 06 '23 08:06 anshulahuja98