Skip to content

helm: use namespaced Role for manager-role when restrictWatchNamespaces is set#450

Open
aldredb wants to merge 5 commits into
temporalio:mainfrom
aldredb:helm/namespaced-manager-role
Open

helm: use namespaced Role for manager-role when restrictWatchNamespaces is set#450
aldredb wants to merge 5 commits into
temporalio:mainfrom
aldredb:helm/namespaced-manager-role

Conversation

@aldredb

@aldredb aldredb commented Jul 23, 2026

Copy link
Copy Markdown

Summary

When rbac.restrictWatchNamespaces is configured, the manager-role is currently emitted as a
ClusterRole — only the binding is namespace-scoped (via RoleBinding). Organizations with strict
RBAC policies push back on ClusterRoles even when they're only bound via RoleBinding, because
ClusterRoles are visible cluster-wide and can be bound by anyone with bind permissions.

This PR changes the chart so that when restrictWatchNamespaces is set:

  • The manager-role is emitted as a namespaced Role (one per watched namespace) instead of a ClusterRole
  • The per-namespace RoleBinding references kind: Role instead of kind: ClusterRole
  • The two inherently cluster-scoped rules (namespaces get, subjectaccessreviews create) remain in the separate manager-cluster-role ClusterRole, which is unchanged

Default behavior (empty restrictWatchNamespaces) is unchanged — still ClusterRole + ClusterRoleBinding.

What was verified

  • helm template renders correctly for both default and restricted modes
  • helm lint passes
  • Multi-namespace restrictWatchNamespaces produces one Role + one RoleBinding per namespace
  • Controller source code never references RBAC resources by name/kind at runtime
  • All temporal.io CRDs are namespace-scoped, so namespaced Roles can grant permissions on them
  • Rules completeness: only namespaces get and subjectaccessreviews create excluded from the namespaced Role (both covered by manager-cluster-role)
  • Also tested that it works in my local environment

…es is set

When restrictWatchNamespaces is configured, the manager-role is now
emitted as a namespace-scoped Role (one per watched namespace) instead
of a ClusterRole. The RoleBinding references kind: Role accordingly.

The two inherently cluster-scoped rules (namespaces get,
subjectaccessreviews create) remain in the separate manager-cluster-role
ClusterRole, which is unchanged.

This eliminates the broad ClusterRole that customers with strict RBAC
policies object to, while preserving identical effective permissions
within the watched namespaces.

Default behavior (empty restrictWatchNamespaces) is unchanged.
@aldredb
aldredb requested review from a team and jlegrone as code owners July 23, 2026 09:27
@jaypipes
jaypipes self-requested a review July 23, 2026 09:52
@jaypipes jaypipes added the rbac Access control for the controller and credentials for Temporal connections label Jul 23, 2026

@jaypipes jaypipes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Mostly excellent, but see inline for one issue to address. Thank you for the submission @aldredb!

Comment thread helm/temporal-worker-controller/templates/rbac.yaml Outdated
Comment thread helm/temporal-worker-controller/templates/rbac.yaml Outdated
The namespace field already differentiates, so the release namespace
prefix is redundant for namespace-scoped resources.

Addresses review feedback.
@CLAassistant

CLAassistant commented Jul 23, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@aldredb
aldredb requested a review from jaypipes July 23, 2026 11:55
@aldredb

aldredb commented Jul 23, 2026

Copy link
Copy Markdown
Author

@jaypipes I addressed your comments

@jaypipes jaypipes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍 thank you @aldredb! changes look good to me. I'd like one more contributor to review before merging, though.

@jaypipes jaypipes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@aldredb OK, so there's an issue uncovered by the excellent @Shivs11.

We have this hack/sync-rbac-rules.py script that is intended to keep the different RBAC rules that are specified with kubebuilder code markers in sync with the helm/temporal-worker-controller/templates/rbac.yaml file's contents. As far as we can tell, that script will be broken by this PR -- or the script may end up just overwriting the changes manually introduced in this PR.

So, I'm going to put a hold on merging this particular PR until we can figure out a way forward on this. I suspect we may want to have this PR update the hack/sync-rbac-roles.py script to generate the Role (not ClusterRole) rules entries. For now, though, unfortunately this PR isn't going to make it into the v1.8.1 (chart 0.28.0) release series, sorry!

aldredb added 2 commits July 25, 2026 06:18
The Helm template now has two marker pairs:
- GENERATED RULES BEGIN/END — full rules for the ClusterRole (default mode)
- GENERATED RULES (NAMESPACED) BEGIN/END — rules minus cluster-scoped
  entries (namespaces, subjectaccessreviews) for the namespaced Role

The sync script parses config/rbac/role.yaml, filters out cluster-scoped
rules for the namespaced block, and updates both marker pairs.

Addresses review feedback about hack/sync-rbac-rules.py compatibility.
Add support for the GENERATED RULES (NAMESPACED) BEGIN/END marker pair.
The script now updates both blocks: full rules for the ClusterRole, and
filtered rules (excluding namespaces and subjectaccessreviews) for the
namespaced Role. No external dependencies — stdlib only.
@aldredb

aldredb commented Jul 24, 2026

Copy link
Copy Markdown
Author

@aldredb OK, so there's an issue uncovered by the excellent @Shivs11.

We have this hack/sync-rbac-rules.py script that is intended to keep the different RBAC rules that are specified with kubebuilder code markers in sync with the helm/temporal-worker-controller/templates/rbac.yaml file's contents. As far as we can tell, that script will be broken by this PR -- or the script may end up just overwriting the changes manually introduced in this PR.

So, I'm going to put a hold on merging this particular PR until we can figure out a way forward on this. I suspect we may want to have this PR update the hack/sync-rbac-roles.py script to generate the Role (not ClusterRole) rules entries. For now, though, unfortunately this PR isn't going to make it into the v1.8.1 (chart 0.28.0) release series, sorry!

hack/sync-rbac-roles.py is adjusted accordingly.

Tested with

make manifests
git diff helm/temporal-worker-controller/templates/rbac.yaml # no drift

Kindly need your review. Hope this PR can still make it to the 0.28.0 chart release

@aldredb
aldredb requested a review from jaypipes July 25, 2026 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rbac Access control for the controller and credentials for Temporal connections

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants