design/Implemented/supporting-volumeattributes-resource-policy.md
Currently Velero Resource policies are only supporting "Driver" to be filtered for CSI volume conditions
If user want to skip certain CSI volumes based on other volume attributes like protocol or SKU, etc, they can't do it with the current Velero resource policies. It would be convenient if Velero resource policies could be extended to filter on volume attributes along with existing driver filter in the resource policies conditions to handle the backup of volumes just by some specific volumes attributes conditions.
As of Today, Velero resource policy already provides us the way to filter volumes based on the driver name. But it's not enough to handle the volumes based on other volume attributes like protocol, SKU, etc.
protocol: nfs under storage class parameters to provision CSI NFS Azure File Shares.SMB type of file share volumes and not NFS file share volumes.VolumeAttributes filter along with driver filter in CSI volume conditions to handle volumes.Users want to skip PV with the requirements:
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: azurefile-csi-nfs
provisioner: file.csi.azure.com
allowVolumeExpansion: true
parameters:
protocol: nfs
Modifying the existing Resource Policies code for csiVolumeSource to add the new VolumeAttributes filter for CSI volumes and adding validations in existing csiCondition to match with volume attributes in the conditions from Resource Policy config map and original persistent volume.
The volume resources policies should contain a list of policies which is the combination of conditions and related action, when target volumes meet the conditions, the related action will take effection.
Below is the API Design for the user configuration:
type csiVolumeSource struct {
Driver string `yaml:"driver,omitempty"`
// [NEW] CSI volume attributes
VolumeAttributes map[string]string `yaml:"volumeAttributes,omitempty"`
}
The policies YAML config file would look like this:
version: v1
volumePolicies:
- conditions:
csi:
driver: disk.csi.azure.com
action:
type: skip
- conditions:
csi:
driver: file.csi.azure.com
volumeAttributes:
protocol: nfs
action:
type: skip`
Existing CSI Volume Condition can now add volumeAttributes which will be key and value pairs.
Specify details for the related volume source (currently only csi driver is supported filter)
yaml csi: // match volume using `file.csi.azure.com` and with volumeAttributes protocol as nfs driver: file.csi.azure.com volumeAttributes: protocol: nfs