-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add --or-selector
for backup and restore command
#6475
Conversation
@@ -101,6 +101,14 @@ Includes cluster-scoped resources. Cannot work with `--include-cluster-scoped-re | |||
|
|||
For more information read the [Kubernetes label selector documentation](https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking this docs, couldn't we achieve the same result using the --selector
flag with in
?
Ex.: Do these commands produce the same result?
velero backup create nginx-backup --selector "app in (nginx,my-nginx,nginx-example)"
velero backup create nginx-backup --or-selector "app=nginx|app=my-nginx|app=nginx-example"
Did not try every possibility, but maybe this PR can be achieve only adding examples to the docs with different scenarios (and updating help description of --selector
flag in CLI)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I think the usage from the docs is limited. For example, if I have 2 (or more) different labels (KEYs), I can't do an OR with them ("Similarly the comma separator acts as an AND operator.")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mateusoliveira43 yes -- that's the sort of scenario the or selector was added for:
velero backup create nginx-backup --or-selector "app=nginx|foo=bar"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If resources to be backed up are labeled either env=prod
or environment=production
, then we cannot use --selector env=prod,environment=production
. But we can use --or-selector "env=prod|environment=production"
I have updated the PR to include examples and explanations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have modified the syntax a little bit. The or
keyword can be used in place of |
pipe symbol.
--or-selector
for backup and restore command
Signed-off-by: Nilesh Akhade <[email protected]>
Codecov Report
@@ Coverage Diff @@
## main #6475 +/- ##
==========================================
- Coverage 60.28% 60.26% -0.03%
==========================================
Files 238 239 +1
Lines 25256 25306 +50
==========================================
+ Hits 15226 15250 +24
- Misses 8976 8998 +22
- Partials 1054 1058 +4
|
Since it's passed the v1.12 FC milestone, and this does not introduce big changes to the API, we'll target this one to the patch v1.12.1 |
Now that 1.12 is released, can this PR be merged? |
Thank you for contributing to Velero!
Please add a summary of your change
Add 'orLabelSelector' that allows selecting resources matching any one of the label selectors.
With the current implementation of the
--selector
, it is not possible to select resources that have any one of the labels,app=nginx
orfoo=bar
. This is because the selector,app=nginx,foo=bar
will expect both the labels on the resource.Selecting resources that have any one of the labels is already supported by the Restore and Backup CRDs, through
orLabelSelectors
: https://velero.io/docs/v1.11/api-types/restore/. This PR adds--or-selector
to achieve the same thing using velero cli.Does your change fix a particular issue?
Fixes #5679
Please indicate you've done the following:
/kind changelog-not-required
as a comment on this pull request.site/content/docs/main
.