Skip to content

feat(dashboard): add cluster-usage RBAC for the new admin page - #2743

Merged
Aleksei Sviridkin (lexfrei) merged 1 commit into
mainfrom
feat/dashboard-cluster-usage-rbac
May 27, 2026
Merged

Aleksei Sviridkin (lexfrei) merged 1 commit into
mainfrom
feat/dashboard-cluster-usage-rbac

Conversation

@lexfrei

@lexfrei Aleksei Sviridkin (lexfrei) commented May 26, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does

Adds a new ClusterRole cozystack-dashboard-cluster-usage and its ClusterRoleBinding under packages/system/dashboard/templates/, plus the matching helm-unittest fixture. The role grants the cozystack-cluster-admin group cluster-wide read on nodes, pods (get/list/watch) and on metrics.k8s.io nodes (get/list).

Companion to the upcoming UI work in cozystack/cozystack-ui#15 — a new admin page Console → Administration → Cluster Usage that renders cluster-scoped resource utilisation and a per-node table including arbitrary extended resources (GPUs and other accelerators). The page-side sidebar item is gated by a SelfSubjectAccessReview on nodes list; without this binding the gate fails closed and the entry stays invisible, which is the desired fallback for clusters that have not adopted the new RBAC yet.

The built-in edit ClusterRole already bound to cozystack-cluster-admin via cozystack-dashboard-cluster-admin does not grant cluster-wide pod read or any access to nodes, so an explicit grant is required for the page to render anything beyond an error.

This chart intentionally does not add permissions for deeper sources (Prometheus, DCGM, HAMi). Those belong in their respective packages or in operator-provided RBAC; the page detects them via discovery and gates each section with its own per-source review.

Screenshots

No UI in this PR — RBAC only.

Release note

feat(dashboard): grant cluster-admin read access to nodes, pods and metrics.k8s.io for the new Cluster Usage admin page

Summary by CodeRabbit

  • New Features

    • Dashboard cluster usage monitoring now includes configured role-based access control with appropriate read permissions for nodes, pods, and metrics data.
  • Tests

    • Added comprehensive test suite to validate the dashboard's role-based access control configuration, including verification of proper permission bindings and authorization rules.

Review Change Stack

The cluster-usage admin page in the dashboard reads cluster-scoped
resources (nodes, pods, metrics.k8s.io) to render aggregate utilisation
and a per-node table that includes arbitrary extended resources such as
GPUs. The built-in 'edit' ClusterRole already bound to
cozystack-cluster-admin via cozystack-dashboard-cluster-admin does not
grant cluster-wide pod read or any access to 'nodes', so the dashboard
needs an explicit grant for the page to render anything beyond an error.

The page-side sidebar item is gated by SelfSubjectAccessReview on
'nodes list' — without this binding the gate fails closed and the entry
stays invisible, which is the desired fallback for clusters that have
not adopted the new RBAC yet.

The chart intentionally does not add permissions for deeper sources
(Prometheus, DCGM, HAMi). Those belong in their respective packages or
operator-provided RBAC; the page detects them via discovery and gates
each section with its own per-source review.

Assisted-By: Claude <[email protected]>
Signed-off-by: Aleksei Sviridkin <[email protected]>
@coderabbitai

coderabbitai Bot commented May 26, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a3c90977-6811-4a99-868c-d8a3073626d8

📥 Commits

Reviewing files that changed from the base of the PR and between 2fa15ce and adddd4f.

📒 Files selected for processing (3)
  • packages/system/dashboard/templates/clusterrole-cluster-usage.yaml
  • packages/system/dashboard/templates/clusterrolebinding-cluster-usage.yaml
  • packages/system/dashboard/tests/cluster_usage_rbac_test.yaml

📝 Walkthrough

Walkthrough

This PR adds Kubernetes RBAC resources and tests for dashboard cluster usage monitoring. It defines a ClusterRole with read-only access to nodes, pods, and metrics, binds it to the cozystack-cluster-admin group via ClusterRoleBinding, and validates both resources with a comprehensive Helm unittest suite.

Changes

Dashboard Cluster Usage RBAC

Layer / File(s) Summary
RBAC Role and Binding Definitions
packages/system/dashboard/templates/clusterrole-cluster-usage.yaml, packages/system/dashboard/templates/clusterrolebinding-cluster-usage.yaml
ClusterRole named cozystack-dashboard-cluster-usage grants get/list/watch on core API nodes and pods, plus get/list on metrics.k8s.io nodes. ClusterRoleBinding binds this role to the cozystack-cluster-admin group.
RBAC Test Suite
packages/system/dashboard/tests/cluster_usage_rbac_test.yaml
Helm unittest verifies ClusterRole and ClusterRoleBinding resource names, API versions, permission rules, and group binding; confirms each template renders exactly one document.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

Poem

🐰 A dashboard now watches the nodes with care,
With metrics and roles to monitor and share.
Read-only permissions, so safe and so fair,
The cluster admin group has access to spare! 📊✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding RBAC resources (ClusterRole and ClusterRoleBinding) for dashboard cluster-usage, which is directly reflected in the file additions and test suite.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/dashboard-cluster-usage-rbac

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.

@github-actions github-actions Bot added area/dashboard Issues or PRs related to the dashboard / UI kind/feature Categorizes issue or PR as related to a new feature size/L This PR changes 100-499 lines, ignoring generated files labels May 26, 2026
@lexfrei
Aleksei Sviridkin (lexfrei) marked this pull request as ready for review May 26, 2026 15:45
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces the necessary RBAC permissions to support an upcoming dashboard feature for monitoring cluster-wide resource utilization. By granting specific read access to nodes, pods, and metrics, the changes ensure that administrators can view detailed cluster usage data without over-privileging the dashboard service.

Highlights

  • RBAC Configuration: Added a new ClusterRole and ClusterRoleBinding to grant the cozystack-cluster-admin group read access to nodes, pods, and metrics.k8s.io.
  • Testing: Included a new helm-unittest fixture to verify the correctness of the newly created RBAC resources.
New Features

🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment Gemini (@gemini-code-assist) Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on Gemini (@gemini-code-assist) comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces a new ClusterRole and ClusterRoleBinding to grant the cozystack-dashboard-cluster-usage role read access to cluster-scoped resources (nodes, pods, and metrics.k8s.io) for the dashboard's cluster-usage admin page. It also adds a comprehensive suite of Helm unit tests to verify the correct creation and binding of these RBAC resources. The reviewer suggested adding standard Helm labels to the metadata of both the ClusterRole and ClusterRoleBinding templates to align with best practices for resource tracking and management.

Comment thread packages/system/dashboard/templates/clusterrole-cluster-usage.yaml
@lexfrei
Aleksei Sviridkin (lexfrei) merged commit 78b9740 into main May 27, 2026
19 of 22 checks passed
@lexfrei
Aleksei Sviridkin (lexfrei) deleted the feat/dashboard-cluster-usage-rbac branch May 27, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/dashboard Issues or PRs related to the dashboard / UI kind/feature Categorizes issue or PR as related to a new feature size/L This PR changes 100-499 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants