Skip to content

feat: Improve user facing roles with dedicated roles#1555

Open
remyj38 wants to merge 1 commit into
traefik:masterfrom
remyj38:feat/user-facing-roles
Open

feat: Improve user facing roles with dedicated roles#1555
remyj38 wants to merge 1 commit into
traefik:masterfrom
remyj38:feat/user-facing-roles

Conversation

@remyj38
Copy link
Copy Markdown
Contributor

@remyj38 remyj38 commented Nov 7, 2025

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

  • Yes, I updated the tests accordingly
  • Yes, I updated the schema accordingly
  • Yes, I ran make test and all the tests passed

@remyj38 remyj38 changed the title feat: Improve user facing roles with specific roles feat: Improve user facing roles with dedicated roles Nov 7, 2025
@remyj38 remyj38 force-pushed the feat/user-facing-roles branch 4 times, most recently from 7fca278 to 9b90297 Compare November 7, 2025 08:19
@mloiseleur mloiseleur added kind/proposal a proposal that needs to be discussed. kind/enhancement New feature or request labels Nov 10, 2025
@mloiseleur
Copy link
Copy Markdown
Member

Hello @remyj38 ,

Thank you for your interest.
For the use case, we’re unsure about this need and the traction it will receive. We are going to leave the status as kind/proposal to give the community time to let us know if they would like this idea.

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.
🤔 So why adding a duplicate rbac file instead of adding write access in the existing rbac when this feature is enabled ?

@remyj38
Copy link
Copy Markdown
Contributor Author

remyj38 commented Nov 11, 2025

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.

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.

I think it can be possible to merge both to one file. I'll check and do a PR if it possible

So why adding a duplicate rbac file instead of adding write access in the existing rbac when this feature is enabled ?

Because of least privileges rule. Traefik don't need to edit the objects

@rmoreas
Copy link
Copy Markdown

rmoreas commented Feb 15, 2026

+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.

@rmoreas
Copy link
Copy Markdown

rmoreas commented Feb 17, 2026

Here an example on how these user cluster roles *-edit and *-view are setup by CloudNativePG Operator: https://github.com/cloudnative-pg/charts/blob/main/charts/cloudnative-pg/templates/rbac.yaml#L117

@mloiseleur
Copy link
Copy Markdown
Member

mloiseleur commented Mar 4, 2026

I'll check and do a PR if it possible

@remyj38 Do you think you can rebase and update this PR?

@remyj38
Copy link
Copy Markdown
Contributor Author

remyj38 commented Mar 6, 2026

I'll check and do a PR if it possible

@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>
@remyj38 remyj38 force-pushed the feat/user-facing-roles branch from 9b90297 to 2fa103b Compare March 13, 2026 15:58
@remyj38
Copy link
Copy Markdown
Contributor Author

remyj38 commented Mar 13, 2026

I'll check and do a PR if it possible

@remyj38 Do you think you can rebase and update this PR?

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...

@mloiseleur
Copy link
Copy Markdown
Member

@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 _podtemplate.tpl and _service.tpl, that are after called (respectively) by daemonset.yaml & deployment.yaml?

You are welcome to explore other patterns, too, if you find a better one.
As you can imagine, we clearly need simplicity and reliability in this chart.

Copy link
Copy Markdown

@rmoreas rmoreas left a comment

Choose a reason for hiding this comment

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

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 }}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Aggregation is not supported on namespace-scoped Role objects

kind: Role
{{- end }}
metadata:
name: {{ template "traefik.clusterRoleName" . }}-admin
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Two user-facing cluster roles are probably sufficient with the names:

  • {{ template "traefik.clusterRoleName" . }}-edit
  • {{ template "traefik.clusterRoleName" . }}-view

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement New feature or request kind/proposal a proposal that needs to be discussed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants