vmware-tanzu / velero

Backup and migrate Kubernetes applications and their persistent volumes
https://velero.io
Apache License 2.0
8.79k stars 1.41k forks source link

Adding Support For VolumeAttributes in Resource Policy #8383

Open mayankagg9722 opened 2 weeks ago

mayankagg9722 commented 2 weeks ago

Summary of the changes

Currently Velero Resource policies are only supporting "Driver" to be filtered in CSI volume conditions

We are adding support for filtering Persistent Volumes (PVs) based on additional VolumeAttributes properties under CSI PVs.

Use Case: Customers asked to back up AFS (Azure file shares) and want to only backup SMB type of file share volumes and not NFS file share volumes.

How Provisioning happens: Define the Storage class with protocol: nfs under storage class parameters to provision CSI NFS Azure File Shares.

Link: https://learn.microsoft.com/en-us/azure/aks/azure-files-csi#nfs-file-shares

The same protocol:nfs property will be floated to the PersistentVolumes as part of CSI VolumeAttributes.

Constraints with current Velero Resource Policies: As the current resource policies only offer to filter based on the driver type, we are bringing an additional filter VolumeAttributes to extend and allow customer to skip/snapshot only certain types of persistent volumes for the same driver.

Sample AFS NFS PV attached below:

image

Please indicate you've done the following:

ywk253100 commented 2 weeks ago

@mayankagg9722 Thank you for the contribution! Before starting review the code changes, could you create a simple design about your proposed improvement for the resource policy so that the maintainers can better understand the requirement and the approach?

mayankagg9722 commented 2 weeks ago

@mayankagg9722 Thank you for the contribution! Before starting review the code changes, could you create a simple design about your proposed improvement for the resource policy so that the maintainers can better understand the requirement and the approach?

Thanks @ywk253100, I have added both the description about the proposal as well as the use case in the Summary section above, Can you please go through it once and let me know in case any more details are required?

mayankagg9722 commented 1 week ago

Hello @ywk253100, please check I have added the design spec now in this PR. Thanks! https://github.com/vmware-tanzu/velero/pull/8383/commits/306cc20a90a9abc5ed823df437b3fe1be122869d

shubham-pampattiwar commented 1 week ago

@mayankagg9722 Would you be able to work on extending the Volume Policy criteria for labelSelector and names as well ? we have an issue targeted for 1.16: https://github.com/vmware-tanzu/velero/issues/8256 It would be great if you could combine the current PRs proposal as well as https://github.com/vmware-tanzu/velero/issues/8256 and propose a design, followed by implementation. Let us know your thoughts on this. Thank you !

kaovilai commented 1 week ago

@shubham-pampattiwar are you suggesting a new PR for a combined design? leaving this PR to be implementation only for one or both issues?

mayankagg9722 commented 1 week ago

@shubham-pampattiwar thanks for tagging your issue, I will definitely try to pick this up post this. Currently only prioritizing to complete this PR for adding one more CSI filter. Thanks!

codecov[bot] commented 1 week ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 59.00%. Comparing base (32a8c62) to head (0de43a3). Report is 34 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #8383 +/- ## ========================================== + Coverage 58.95% 59.00% +0.05% ========================================== Files 367 368 +1 Lines 38902 39015 +113 ========================================== + Hits 22933 23022 +89 - Misses 14507 14530 +23 - Partials 1462 1463 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.


🚨 Try these New Features: