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

Switch roles to clusterroles #117

Closed
wants to merge 2 commits into from

Conversation

willemm
Copy link

@willemm willemm commented Aug 1, 2024

Description

Accompanies pull request tinkerbell/hegel#370

Why is this needed

If hegel is going to read from multiple namespaces it need accompanying rbac

How are existing users impacted? What migration steps/scripts do we need?

May break compatibility if a user is running in an environment where they are not allowed to roll out cluster-rbac resources ?
Otherwise there should be no impact.

Checklist:

I have:

  • updated the documentation and/or roadmap (if required)
  • added unit or e2e tests
  • provided instructions on how to upgrade

@jacobweinstock
Copy link
Member

@willemm Can this be provided as opt-in only?

@willemm
Copy link
Author

willemm commented Sep 2, 2024

Shouldn't be that hard, I'll give that a go.

@willemm
Copy link
Author

willemm commented Sep 2, 2024

Like this? I named the option allNamespaces: false
I also took the liberty of adding the --kubernetes-namespace option when not opting in to clusterroles for all namespaces because I felt that was prudent.

@chrisdoherty4
Copy link
Member

chrisdoherty4 commented Sep 3, 2024

What do we think about offering a .Values.rbac.enabled which, when disabled, assumes the user configures the RBAC however they want? You can already set --kubernetes-namespace with the .Values.args field.

I'm not fond of the RBAC customizations and would prefer this approach because it seems simpler and maintains the minimal set of CLI flags.

@willemm
Copy link
Author

willemm commented Sep 3, 2024

If I, as a user, have to configure my own RBAC that means I have to introduce additional configurations myself, outside of the chart, and can no longer install it off-the-shelf as it were. That kinda defeats the whole purpose of having a helm chart in the first place.

But if you're really not fond of the RBAC customizations, then I would suggest that most users will be fine with the default of ClusterRole and ClusterRoleBinding, which can then be disabled with a value. Note that would also be consistent with all the other components which have cluster-wide rbac. (hegel is the exception in this).
That would be better anyway, because if a user really needs it to just look at a specific namespace, it's at least equally likely that that will not be the namespace hegel is installed in in the first place.

The values.args thing seems valid, I don't have any argument for or against.

@chrisdoherty4
Copy link
Member

Thanks for the feedback, @willemm. I'm open to making ClusterRole and ClusterRoleBinding the default, though it still needs to be opt-out so users can define a small scope should they want to.

... have to configure my own RBAC that means I have to introduce additional configurations myself, outside of the chart, and can no longer install it off-the-shelf as it were. That kinda defeats the whole purpose of having a helm chart in the first place.

The existing RBAC aligned with historical design decisions. I appreciate it doesn't suit your deployment model, but it is a valid deployment model that's been working for some time.

I don't think tweaking a chart to satisfy a different deployment model is abnormal.

Willem Monsuwe added 2 commits September 4, 2024 08:56
Signed-off-by: Willem Monsuwe <[email protected]>
also put other rbac values under the same heading in a backwards compatible manner

Signed-off-by: Willem Monsuwe <[email protected]>
@willemm
Copy link
Author

willemm commented Sep 4, 2024

Ok. I had a small look and I'm not sure .Values.rbac.enabled works "nicely" without some other changes, mainly because there are currewntly two values, .Values.roleName and .Values.roleBindingName which seem like they shoud also go under .Values.rbac.* ?

@chrisdoherty4
Copy link
Member

Ok. I had a small look and I'm not sure .Values.rbac.enabled works "nicely" without some other changes, mainly because there are currewntly two values, .Values.roleName and .Values.roleBindingName which seem like they shoud also go under .Values.rbac.* ?

That's fine. There isn't an expectation to remain backward compatible yet, though we do our best to minimize disruptions.

metadata:
name: {{ .Values.roleName }}
namespace: {{ .Release.Namespace | quote }}
name: {{ coalesce .Values.roleName .Values.rbac.roleName }}
Copy link
Member

@chrisdoherty4 chrisdoherty4 Sep 4, 2024

Choose a reason for hiding this comment

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

TIL coalesce

@chrisdoherty4
Copy link
Member

@jacobweinstock Feel free to merge at your discretion.

@jacobweinstock
Copy link
Member

jacobweinstock commented Oct 2, 2024

#120 says, "unrestricted access shouldn't be the default or only option". I agree with this. @willemm, i apologize. i think we've gone back and forth on this, but i think we're going to need to be able to select between both role and clusterRole.

@willemm
Copy link
Author

willemm commented Oct 4, 2024

For Rufio that makes sense, as it can read secrets. Which it can currently do, cluster-wide.
However, hegel only reads 'hardware' resources from the tinkerbell.org apigroup.

So I'm afraid I don't understand why this is an issue for the hegel chart. Currently it is the only exception that does not have clusterrolebindings, and it's the least impactful one from a security standpoint. Negligible impact, in fact.

So while this PR could include a switch option, I feel it would be much better if all the charts had the same rbac structure/setup, whuich should IMO be part of how you fix the #120 issue. (i.e. don't just fix rufio there, but copy-paste the fix across all the charts)

@jacobweinstock
Copy link
Member

Hey @willemm , Apologies for all the churn on this one. Thank you for putting this up. @chrisdoherty4 and I spoke today. I would like us to go back to what you originally had. Apologies for the flip-flopping. Also, as you've noted, we need a fix across all services. Not only that, but not all of our services handle single namespaces properly either. With all this said, I've created PR #129 and I'm working across the Tinkerbell service repos in order to make sure they all handle namespacing properly.

If you have some cycles (if not, totally fine), I'd really appreciate your review on #129. Thanks again for contributing!

@willemm
Copy link
Author

willemm commented Oct 16, 2024

No worries, I work in fintech so this is a breeze, comparatively ;)

I looked at it, all of it looks good. (Assuming hegel indeed does not need access to workflows, which I think it shouldn't, but I'm not sure)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants