feat: Improve user facing roles with dedicated roles#1555
Conversation
7fca278 to
9b90297
Compare
|
Hello @remyj38 , Thank you for your interest. We will reevaluate as people respond. For the implementation, it would require the maintainers to update rbac in a third file. It's already not ideal with the ClusterRole and the Role. |
|
Hello I understand to wait for community traction on it. Some other charts like cert-manager or external-secrets implement it and it prevents admins to searching all the doc about which CRDs they needs to add to there RBAC when implementing Traefik. It's also make upgrades easier for users when new CRD is added.
I think it can be possible to merge both to one file. I'll check and do a PR if it possible
Because of least privileges rule. Traefik don't need to edit the objects |
|
+1 for adding this feature. As someone who is new to Traefik, I was genuinely surprised that this capability isn’t already available. Implementing it would significantly improve the ability to set up proper RBAC for cluster users and aligns well with common Kubernetes security expectations. This addition would make the Traefik chart feel more complete and more secure to operate in multi‑user environments. |
|
Here an example on how these user cluster roles |
@remyj38 Do you think you can rebase and update this PR? |
I'll try to look at it next week |
Signed-off-by: Rémy Jacquin <remy@remyj.fr>
9b90297 to
2fa103b
Compare
Ok, it's rebased ! And I looked at merging service role and user roles, but it will create a lot of conditions in the template and makes it unreadable... |
|
@remyj38 🤔 A PR that duplicates RBAC lines to that extent won't be sustainable in the long term. We will surely miss a new right here or there. We clearly cannot review or merge it "as is". Wdyt about adopting the same pattern as for You are welcome to explore other patterns, too, if you find a better one. |
rmoreas
left a comment
There was a problem hiding this comment.
As suggested by @mloiseleur, usage of named templates can improve maintainability.
I've added some extra suggestions for improvement.
| @@ -0,0 +1,281 @@ | |||
| {{- $version := include "traefik.proxyVersion" $ }} | |||
| {{- if and .Values.rbac.enabled .Values.rbac.aggregateAdminTo }} | |||
There was a problem hiding this comment.
I would change this condition to just:
{{- if .Values.rbac.enabled }}
These roles should always be created, but aggregation should be optional (with .Values.rbac.aggregateClusterRoles)
| {{- if (not .Values.rbac.namespaced) }} | ||
| kind: ClusterRole | ||
| {{- else }} | ||
| kind: Role |
There was a problem hiding this comment.
Aggregation is not supported on namespace-scoped Role objects
| kind: Role | ||
| {{- end }} | ||
| metadata: | ||
| name: {{ template "traefik.clusterRoleName" . }}-admin |
There was a problem hiding this comment.
Two user-facing cluster roles are probably sufficient with the names:
{{ template "traefik.clusterRoleName" . }}-edit{{ template "traefik.clusterRoleName" . }}-view
There was a problem hiding this comment.
When .Values.rbac.namespaced is true, the names might be better:
{{ template "traefik.fullname" $ }}-edit{{ template "traefik.fullname" $ }}-view
| labels: | ||
| {{- include "traefik.labels" . | nindent 4 }} | ||
| {{- range .Values.rbac.aggregateAdminTo }} | ||
| rbac.authorization.k8s.io/aggregate-to-{{ . }}: "true" |
There was a problem hiding this comment.
For the edit ClusterRole, I would make this:
{{- if .Values.rbac.aggregateClusterRoles }}
rbac.authorization.k8s.io/aggregate-to-edit: "true"
rbac.authorization.k8s.io/aggregate-to-admin: "true"
{{- end }}| labels: | ||
| {{- include "traefik.labels" . | nindent 4 }} | ||
| {{- range .Values.rbac.aggregateViewTo }} | ||
| rbac.authorization.k8s.io/aggregate-to-{{ . }}: "true" |
There was a problem hiding this comment.
For the view ClusterRole this could be simply:
{{- if .Values.rbac.aggregateClusterRoles }}
rbac.authorization.k8s.io/aggregate-to-view: "true"
rbac.authorization.k8s.io/aggregate-to-edit: "true"
rbac.authorization.k8s.io/aggregate-to-admin: "true"
{{- end }}See also comment for the edit ClusterRole.
What does this PR do?
Creating two dedicated cluster roles (view and admin) for user facing aggregated roles.
Motivation
User facing aggregated roles were supported since #664 but only aggregating Traefik cluster role to aggregated role.
In my opinion, this is not the right way to implement it as the Traefik cluster role only have view permission to traefik CRDs while admin aggregated role should "allow read/write access to most resources in a namespace".
More
make testand all the tests passed