Skip to content
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 per-object-level filtering based on labels (excluding Rancher-generated resources) #125

Merged
merged 1 commit into from
Jan 24, 2022

Conversation

nobbs
Copy link
Contributor

@nobbs nobbs commented Jan 19, 2022

The set of rules is hardcoded as of now, as proposed in #104. The current rules are Rancher-specific, as Rancher does some propagation of roles, rolebindings and serviceaccounts on its own via its "projects" (used to group namespaces). Label equality is checked against both key and value - no regex support for now.

Tested: addded a new test to check whether roles propagation is prevented if the label is matched; also checked, that this prevents propagation only for the specified groups / kinds.


I'm not really satisfied with hardcoding these, I personally would prefer a configurable solution. Unfortunately, I'm not sure how to best implement that.

@k8s-ci-robot
Copy link
Contributor

Hi @nobbs. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 19, 2022
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 19, 2022
Copy link
Contributor

@adrianludwin adrianludwin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this change, it looks great! I've left a few comments the we're good to go. My overall comment is just to not add complexity where we don't need it yet, e.g. if we're only excluding ConfigMaps by name, we don't need to also test their groups/kinds as well. We can easily add that in the future if we need to.

Also, can you please change the title of the commit / PR to explicitly call out Rancher. I have no concerns about hardcoding this for now, we can always move it to a command-line option or even to HNCConfiguration later if needed.

/ok-to-test

internal/selectors/selectors.go Outdated Show resolved Hide resolved
internal/selectors/selectors.go Outdated Show resolved Hide resolved
internal/integtest/helpers.go Outdated Show resolved Hide resolved
internal/objects/reconciler_test.go Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 24, 2022
@adrianludwin adrianludwin added this to the release-v1.0 milestone Jan 24, 2022
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 24, 2022
@nobbs nobbs changed the title Add per-object-level filtering based on labels Add per-object-level filtering based on labels (excluding Rancher-generated resources) Jan 24, 2022
@nobbs
Copy link
Contributor Author

nobbs commented Jan 24, 2022

@adrianludwin Thank you for the thorough review! I've made the changes you requested - you are certainly right, that complexity that is not required should not be added.

As this change seems to be enough to make HNC usable with Rancher / RKE-based k8s clusters, I've got not problem with closing #123 without merging.

Copy link
Contributor

@adrianludwin adrianludwin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last tiny nit (sorry!), plus can you please update the docs at https://github.com/kubernetes-sigs/hierarchical-namespaces/blob/master/docs/user-guide/concepts.md#built-in-exceptions to mention this?

internal/selectors/selectors.go Show resolved Hide resolved
The set of rules is hardcoded as of now, as proposed in kubernetes-sigs#104. The
current rules are Rancher-specific, as Rancher does some propagation of
roles, rolebindings and serviceaccounts on its own via its "projects"
(used to group namespaces). Label equality is checked against both key
and value - no regex support for now.

Tested: added a new test to check whether roles / configmap propagation
is prevented if the label is matched.
@nobbs
Copy link
Contributor Author

nobbs commented Jan 24, 2022

One last tiny nit (sorry!), plus can you please update the docs at https://github.com/kubernetes-sigs/hierarchical-namespaces/blob/master/docs/user-guide/concepts.md#built-in-exceptions to mention this?

Done. And there is nothing to be sorry for ;)

Copy link
Contributor

@adrianludwin adrianludwin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this change!

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 24, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: adrianludwin, nobbs

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants