Skip to content

📝 Support cluster-wide permissions grants in AddonTemplate - #176

Open
bhperry wants to merge 1 commit into
open-cluster-management-io:mainfrom
bhperry:addon-template-clusterrolebinding
Open

📝 Support cluster-wide permissions grants in AddonTemplate#176
bhperry wants to merge 1 commit into
open-cluster-management-io:mainfrom
bhperry:addon-template-clusterrolebinding

Conversation

@bhperry

@bhperry bhperry commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Documentation
    • Added a design document proposing support for cluster-wide role bindings for addon agent service accounts to enable permissions across all namespaces.
    • Included metadata for the enhancement (authors, reviewers, dates) and a test plan covering backward compatibility and creation of cluster-wide bindings when configured.

@openshift-ci
openshift-ci Bot requested review from deads2k and qiujian16 March 25, 2026 15:29
@openshift-ci

openshift-ci Bot commented Mar 25, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: bhperry
Once this PR has been reviewed and has the lgtm label, please assign qiujian16 for approval. For more information see the Code Review Process.

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

Details 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

@coderabbitai

coderabbitai Bot commented Mar 25, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@bhperry has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 14 minutes and 33 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 682748da-3d60-43b8-a5a1-8fc4ece76a14

📥 Commits

Reviewing files that changed from the base of the PR and between c3fedab and aa0e789.

📒 Files selected for processing (2)
  • enhancements/sig-architecture/233-addon-template-clusterrolebinding/README.md
  • enhancements/sig-architecture/233-addon-template-clusterrolebinding/metadata.yaml

Walkthrough

Adds an enhancement design and metadata for addon-template-clusterrolebinding, proposing a new AllNamespaces hub permissions binding type and associated config to enable ClusterRoleBinding creation for addon agent service accounts.

Changes

Cohort / File(s) Summary
Enhancement proposal & metadata
enhancements/sig-architecture/233-addon-template-clusterrolebinding/README.md, enhancements/sig-architecture/233-addon-template-clusterrolebinding/metadata.yaml
New design document and metadata describing the AllNamespaces binding type, AllNamespacesBindingConfig, required addon-manager controller permission changes, implementation notes for hub kubeClient registration (new ClusterRoleBinding creation path and naming convention), YAML example, and test plan.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: adding support for cluster-wide permissions grants (ClusterRoleBindings) in AddonTemplate, which matches the core purpose of the design document.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (3)
enhancements/sig-architecture/233-addon-template-clusterrolebinding/README.md (2)

77-78: Add examples or remove empty section.

The examples section is currently empty. Consider either:

  1. Adding an example showing how to configure an AddonTemplate with the new AllNamespaces binding type, or
  2. Removing this section if examples will be added later

Examples would help users understand how to use the new feature.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@enhancements/sig-architecture/233-addon-template-clusterrolebinding/README.md`
around lines 77 - 78, The README currently has an empty "#### examples" section;
either populate it with a concrete example showing how to configure an
AddonTemplate that uses the new AllNamespaces binding type (include the
AddonTemplate YAML or a minimal snippet illustrating metadata,
spec.binding.type: AllNamespaces, and any required fields), or remove the "####
examples" heading entirely if you don't want examples in this PR; update the
section to reference the AddonTemplate and AllNamespaces symbols so readers can
find the usage easily.

84-85: Consider defining graduation criteria before implementation.

While "N/A" may be acceptable for a provisional enhancement, graduation criteria should be defined before this enhancement moves to implementable status. Consider adding criteria for when this feature should be considered ready for different maturity levels (dev preview, tech preview, GA).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@enhancements/sig-architecture/233-addon-template-clusterrolebinding/README.md`
around lines 84 - 85, Replace the placeholder "N/A" under the "Graduation
Criteria" section with concrete, testable criteria for each maturity level;
update the "Graduation Criteria" section to list specific requirements for dev
preview, tech preview, and GA (e.g., stability/performance targets, API/behavior
contracts, documentation, upgrade/migration paths, and security/compliance
checks) so reviewers can verify when the enhancement is ready to advance.
enhancements/sig-architecture/233-addon-template-clusterrolebinding/metadata.yaml (1)

14-14: Consider adding references to related enhancements.

Since this enhancement extends the AddonTemplate feature, consider adding references to related enhancements in the see-also field for better documentation and traceability.

🔗 Proposed enhancement to add related references
-see-also: []
+see-also:
+  - "/enhancements/sig-architecture/82-addon-template"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@enhancements/sig-architecture/233-addon-template-clusterrolebinding/metadata.yaml`
at line 14, Update the metadata.yaml "see-also" field to list related
enhancements that this RFC extends or depends on (e.g., the AddonTemplate
enhancement and any other relevant SIG-Architecture proposals); edit the
see-also array to include those enhancement IDs/titles or links so reviewers can
trace related work and context. Ensure you modify the see-also field in
metadata.yaml (the "see-also" key) to contain a YAML array of references
(IDs/titles/URLs) and keep entries concise and consistent with other enhancement
metadata.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@enhancements/sig-architecture/233-addon-template-clusterrolebinding/metadata.yaml`:
- Around line 11-12: Update the metadata fields in metadata.yaml so the
creation-date and last-updated reflect the actual creation time of the
enhancement (change the current 2025-05-22 values to 2026-03-25 or the correct
creation date); locate and update the creation-date and last-updated keys in the
file to the accurate ISO date string, commit the change, and ensure the
metadata.yaml entry for those two fields matches the PR creation date.

In
`@enhancements/sig-architecture/233-addon-template-clusterrolebinding/README.md`:
- Around line 60-62: Fix the typo in the comment above the AllNamespaces field:
change "wwhen" to "when" in the comment that describes
AllNamespaces/AllNamespacesBindingConfig so the comment reads "It is required
when the type is AllNamespaces"; update the comment next to the AllNamespaces
*AllNamespacesBindingConfig `json:"allNamespaces,omitempty"` declaration.
- Around line 5-9: Update the Markdown checklist items that currently use "- []"
to the correct GitHub-flavored Markdown checkbox syntax "- [ ]" so each
unchecked item renders properly; specifically edit the lines starting with "- []
Enhancement is `provisional`", "- [] Design details are appropriately documented
from clear requirements", "- [] Test plan is defined", "- [] Graduation criteria
for dev preview, tech preview, GA", and "- [] User-facing documentation is
created in
[website](https://github.com/open-cluster-management-io/open-cluster-management-io.github.io/)"
to use "- [ ]" for each checkbox.
- Around line 65-71: The comment incorrectly describes the struct name instead
of the field: update the doc comment above the ClusterRoleName field in the
AllNamespacesBindingConfig struct so it documents the field (e.g.,
"ClusterRoleName is the name of the ClusterRole that the addon agent will be
bound to; a ClusterRoleBinding will be created referencing this ClusterRole with
subjects for each cluster namespace. The user must ensure the ClusterRole exists
on the hub cluster."). Keep the +kubebuilder:validation:Required tag and the
json tag `clusterRoleName` unchanged and ensure the comment is placed
immediately above the ClusterRoleName field.

---

Nitpick comments:
In
`@enhancements/sig-architecture/233-addon-template-clusterrolebinding/metadata.yaml`:
- Line 14: Update the metadata.yaml "see-also" field to list related
enhancements that this RFC extends or depends on (e.g., the AddonTemplate
enhancement and any other relevant SIG-Architecture proposals); edit the
see-also array to include those enhancement IDs/titles or links so reviewers can
trace related work and context. Ensure you modify the see-also field in
metadata.yaml (the "see-also" key) to contain a YAML array of references
(IDs/titles/URLs) and keep entries concise and consistent with other enhancement
metadata.

In
`@enhancements/sig-architecture/233-addon-template-clusterrolebinding/README.md`:
- Around line 77-78: The README currently has an empty "#### examples" section;
either populate it with a concrete example showing how to configure an
AddonTemplate that uses the new AllNamespaces binding type (include the
AddonTemplate YAML or a minimal snippet illustrating metadata,
spec.binding.type: AllNamespaces, and any required fields), or remove the "####
examples" heading entirely if you don't want examples in this PR; update the
section to reference the AddonTemplate and AllNamespaces symbols so readers can
find the usage easily.
- Around line 84-85: Replace the placeholder "N/A" under the "Graduation
Criteria" section with concrete, testable criteria for each maturity level;
update the "Graduation Criteria" section to list specific requirements for dev
preview, tech preview, and GA (e.g., stability/performance targets, API/behavior
contracts, documentation, upgrade/migration paths, and security/compliance
checks) so reviewers can verify when the enhancement is ready to advance.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3b8c51b6-a825-467a-aacf-a29febd58ad6

📥 Commits

Reviewing files that changed from the base of the PR and between 4cc505e and ad7a077.

📒 Files selected for processing (2)
  • enhancements/sig-architecture/233-addon-template-clusterrolebinding/README.md
  • enhancements/sig-architecture/233-addon-template-clusterrolebinding/metadata.yaml

Comment thread enhancements/sig-architecture/233-addon-template-clusterrolebinding/metadata.yaml Outdated
Comment thread enhancements/sig-architecture/233-addon-template-clusterrolebinding/README.md Outdated
@bhperry
bhperry force-pushed the addon-template-clusterrolebinding branch from ad7a077 to c3fedab Compare March 25, 2026 15:43
@bhperry
bhperry force-pushed the addon-template-clusterrolebinding branch from c3fedab to aa0e789 Compare March 25, 2026 15:44
@qiujian16

Copy link
Copy Markdown
Member

cc @zhujian7

@zhujian7

Copy link
Copy Markdown
Member

@bhperry thanks for the proposal. I am thinking of several things:

  1. We may need to add a section to describe the security considerations, like can the hub cluster-admin be bound, how to prevent escalation of privileges?
  2. Lifecycle management of the created clusterrolebindings.
    • When a ManagedClusterAddon is deleted, is the corresponding ClusterRoleBinding cleaned up?
    • When the AllNamespaces permission is removed from an AddonTemplate, are existing ClusterRoleBindings garbage-collected?

## Proposal
- Add "AllNamespaces" hub permission type, which references a single ClusterRole in the hub
- Addon Manager will manage ClusterRoleBindings for spoke agent addons with AllNamespaces permissions
- Each ManagedClusterAddon has its own ClusterRoleBinding named `open-cluster-management:<addon-name>:clusterrole:<cluster-name>:agent`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can multiple clusterroles be configured? How to prevent the name collision?
We may need to validate that AllNamespaces typed registration can only have 1?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Actually I recently noticed there is the same problem in general with hubPermissions. There is a single rolebinding name used. If you try to set multiple entries it causes an error.

@bhperry

bhperry commented Mar 27, 2026

Copy link
Copy Markdown
Contributor Author

We may need to add a section to describe the security considerations, like can the hub cluster-admin be bound, how to prevent escalation of privileges?

For one, privileges can only be granted up to the level granted to the addon-manager itself, it needs to have any permissions that it is trying to grant. Attempting to grant cluster-admin would fail unless it is also already bound to the addon-manager since it has permissions that are outside the scope of what is normally granted.

Definitely agree there should be clear warnings in the documentation about using AllNamespaces. I was also considering if it should be an opt-in feature flag, or have a list of allowed clusterRoles specified in the clustermanager config. Being allowed to create AddonTemplates at all already assumes a great deal of priviledge though, since with existing functionality you could grant permission to get secrets from any arbitrary namespace.

Lifecycle management of the created clusterrolebindings.

  • When a ManagedClusterAddon is deleted, is the corresponding ClusterRoleBinding cleaned up?
  • When the AllNamespaces permission is removed from an AddonTemplate, are existing ClusterRoleBindings garbage-collected?

That would need to be added. SingleNamespace has the same problem since it can't be garbage collected via ownerReference to ManagedClusterAddon like CurrentCluster does. There is a TODO comment about this here. Both could be addressed together if this is accepted.

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