Skip to content

Add backplane RBAC for RHOBS team access to regional clusters#2708

Open
moadz wants to merge 1 commit into
openshift:masterfrom
moadz:rhobs-rbac-backplane
Open

Add backplane RBAC for RHOBS team access to regional clusters#2708
moadz wants to merge 1 commit into
openshift:masterfrom
moadz:rhobs-rbac-backplane

Conversation

@moadz
Copy link
Copy Markdown

@moadz moadz commented Apr 17, 2026

What type of PR is this?

(bug/feature/cleanup/documentation)
Adding new backplane role.

What this PR does / why we need it?

Introduces a new backplane role for the RHOBS team to get read-only
access to RHOBS regional clusters. This includes a ClusterRole scoped
to Thanos, Loki, monitoring, and core Kubernetes resources, a
SubjectPermission binding it to rhobs-prefixed namespaces, and a
SelectorSyncSet config targeting clusters labeled as RHOBS regional.

Summary by CodeRabbit

  • New Features

    • RHOBS regional cluster support added to the backplane, enabling RHOBS-specific cluster onboarding and scoped access.
  • Documentation

    • Backplane README table reformatted and updated with an RHOBS entry describing access scope.
  • Chores

    • Added manifests and RBAC/permission configurations to create RHOBS namespace, roles, and scoped bindings for RHOBS service accounts.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 17, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds RHOBS support: README table update and new rhobs directory; a Namespace openshift-backplane-rhobs; a selector-driven deployment config targeting RHOBS regional clusters; a ClusterRole granting read/list/watch on monitoring and infra resources; and a SubjectPermission binding that role to RHOBS serviceaccounts.

Changes

Cohort / File(s) Summary
Documentation
deploy/backplane/README.md
Reformatted table and added rhobs directory entry describing RBAC access for RHOBS regional clusters.
Namespace & Selector Config
deploy/backplane/rhobs/00-rhobs.namespace.yml, deploy/backplane/rhobs/config.yaml
Added openshift-backplane-rhobs Namespace and a SelectorSyncSet-style config using label match/exclude to target RHOBS regional clusters (excludes FedRAMP).
RBAC: ClusterRole
deploy/backplane/rhobs/10-rhobs-cluster-project.ClusterRole.yml
New ClusterRole backplane-rhobs-regional-cluster-project granting get,list,watch across monitoring (Thanos/Prometheus/Alertmanager), RHOBS/coreos monitoring, Loki, routes/templates, RBAC, CRDs, core resources, and controllers.
RBAC: SubjectPermission
deploy/backplane/rhobs/20-rhobs.SubjectPermission.yml
Added SubjectPermission backplane-rhobs-regional-cluster binding the ClusterRole to Group system:serviceaccounts:openshift-backplane-rhobs, with allowed/denied namespace regexes.
Managed-cluster sync templates
hack/00-osd-managed-cluster-config-integration.yaml.tmpl, hack/00-osd-managed-cluster-config-stage.yaml.tmpl, hack/00-osd-managed-cluster-config-production.yaml.tmpl
Added SelectorSyncSet (backplane-rhobs) templates to sync Namespace, ClusterRole, and SubjectPermission to eligible managed clusters.

Sequence Diagram(s)

sequenceDiagram
    participant Repo as "Backplane Repo"
    participant Hive as "Hive Controller"
    participant Cluster as "Managed Cluster"
    participant RBAC as "Cluster RBAC Controller"
    participant SA as "ServiceAccounts"

    Repo->>Hive: Apply SelectorSyncSet (backplane-rhobs)
    Hive->>Cluster: Push synced manifests (Namespace, ClusterRole, SubjectPermission)
    Cluster->>RBAC: Create Namespace `openshift-backplane-rhobs`
    Cluster->>RBAC: Create ClusterRole `backplane-rhobs-regional-cluster-project`
    Cluster->>RBAC: Create SubjectPermission binding to `system:serviceaccounts:openshift-backplane-rhobs`
    RBAC->>SA: Grant permissions to serviceaccounts in allowed namespaces
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 11 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Test Structure And Quality ❓ Inconclusive PR contains no Go test files; only Kubernetes YAML manifests and configuration templates for RHOBS infrastructure setup. Clarify if this custom check applies to this PR's Kubernetes manifests rather than Go test code, or verify test files were intended for inclusion.
✅ Passed checks (11 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly summarizes the main change: adding RBAC configuration for RHOBS team access to regional clusters, which is clearly reflected in all the modified and new files.
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.
Stable And Deterministic Test Names ✅ Passed This pull request contains no Ginkgo test files or Go test code. All modified files are YAML manifests, YAML templates, and Markdown documentation for Kubernetes RBAC configuration in the deploy/backplane/rhobs/ and hack/ directories. A repository-wide search confirms zero Go test files exist. Therefore, the custom check for stable and deterministic Ginkgo test names is not applicable to this PR.
Microshift Test Compatibility ✅ Passed This pull request does not add any new Ginkgo e2e tests. All changes are to Kubernetes manifests and deployment templates, not test code.
Single Node Openshift (Sno) Test Compatibility ✅ Passed This pull request contains only Kubernetes/OpenShift configuration files with no Ginkgo e2e tests or test code.
Topology-Aware Scheduling Compatibility ✅ Passed PR introduces only RBAC and namespace configuration resources with no workloads or scheduling constraints.
Ote Binary Stdout Contract ✅ Passed This PR modifies only Kubernetes manifests, YAML configuration files, and documentation. The OTE Binary Stdout Contract check applies to test binaries and process-level code; this PR contains none.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed This PR does not add any Ginkgo e2e tests. All changes consist of Kubernetes manifest files (YAML), configuration files, documentation (Markdown), and template files for infrastructure deployment.

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

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

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

@openshift-ci openshift-ci Bot requested review from rafael-azevedo and typeid April 17, 2026 16:22
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@deploy/backplane/rhobs/rhobs-cluster/10-srep-rhobs-cluster-project.ClusterRole.yml`:
- Around line 18-26: Update the RBAC rule block for monitoring resources: change
the apiGroups entry from "monitoring.rhobs.io" to "monitoring.rhobs" and
normalize indentation to 2 spaces for the apiGroups/resources/verbs block so it
matches other rule blocks; target the rule that lists resources
"monitoringstacks" and "thanosqueriers" and ensure the apiGroups, resources, and
verbs keys are aligned with the 2-space style used elsewhere.

In `@deploy/backplane/rhobs/rhobs-cluster/20-srep.SubjectPermission.yml`:
- Line 4: The resource metadata.name is stale: change the SubjectPermission
resource name from "backplane-srep-rhobs-regional-cluster" to
"backplane-rhobs-regional-cluster" to match the bound service-account group
"openshift-backplane-rhobs" and ClusterRole
"backplane-rhobs-regional-cluster-project"; update any internal references if
present and also consider renaming the file from "20-srep.SubjectPermission.yml"
to "20-rhobs.SubjectPermission.yml" so filename and resource name are
consistent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 2de97ae8-a176-4281-8d74-c92196a84179

📥 Commits

Reviewing files that changed from the base of the PR and between e2cf895 and d9c9b06.

📒 Files selected for processing (4)
  • deploy/backplane/README.md
  • deploy/backplane/rhobs/rhobs-cluster/10-srep-rhobs-cluster-project.ClusterRole.yml
  • deploy/backplane/rhobs/rhobs-cluster/20-srep.SubjectPermission.yml
  • deploy/backplane/rhobs/rhobs-cluster/config.yaml

Comment on lines +18 to +26
- apiGroups:
- monitoring.rhobs.io
resources:
- monitoringstacks
- thanosqueriers
verbs:
- get
- list
- watch
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot Apr 17, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Confirm the group used throughout the repo for RHOBS monitoring resources.
rg -nP --type=yaml -C1 'monitoring\.rhobs(\.io)?'

Repository: openshift/managed-cluster-config

Length of output: 4839


🏁 Script executed:

cat -n deploy/backplane/rhobs/rhobs-cluster/10-srep-rhobs-cluster-project.ClusterRole.yml

Repository: openshift/managed-cluster-config

Length of output: 2235


Fix API group and indentation in monitoring.rhobs rule block.

The API group should be monitoring.rhobs (not monitoring.rhobs.io). Throughout the repository, RHOBS resources use apiVersion: monitoring.rhobs/v*, and this incorrect API group will prevent the RBAC rule from granting access to monitoringstacks and thanosqueriers resources.

Additionally, the indentation for this rule block (4-space nested under apiGroups/resources/verbs) is inconsistent with all other rule blocks in the file, which use 2-space indentation.

🔧 Proposed fix
 - apiGroups:
-    - monitoring.rhobs.io
+  - monitoring.rhobs
   resources:
-    - monitoringstacks
-    - thanosqueriers
+  - monitoringstacks
+  - thanosqueriers
   verbs:
-    - get
-    - list
-    - watch
+  - get
+  - list
+  - watch
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@deploy/backplane/rhobs/rhobs-cluster/10-srep-rhobs-cluster-project.ClusterRole.yml`
around lines 18 - 26, Update the RBAC rule block for monitoring resources:
change the apiGroups entry from "monitoring.rhobs.io" to "monitoring.rhobs" and
normalize indentation to 2 spaces for the apiGroups/resources/verbs block so it
matches other rule blocks; target the rule that lists resources
"monitoringstacks" and "thanosqueriers" and ensure the apiGroups, resources, and
verbs keys are aligned with the 2-space style used elsewhere.

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.

It got fixed in the generated templates, but can you also fix the indents here? As coderabbit suggested

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧩 Analysis chain

Let me check the current state of the source file.


🏁 Script executed:

#!/bin/bash
cat -n deploy/backplane/rhobs/10-rhobs-cluster-project.ClusterRole.yml

Length of output: 2452


@bmeng, the API group is already fixed to monitoring.rhobs in the source file. Only the indentation (lines 19–37) still needs normalizing. Here's the fix:

 - apiGroups:
-    - monitoring.rhobs
+  - monitoring.rhobs
   resources:
-    - alertmanagerconfigs
-    - alertmanagers
-    - monitoringstacks
-    - podmonitors
-    - probes
-    - prometheusagents
-    - prometheuses
-    - prometheusrules
-    - scrapeconfigs
-    - servicemonitors
-    - thanosqueriers
-    - thanosrulers
-    - uiplugins
+  - alertmanagerconfigs
+  - alertmanagers
+  - monitoringstacks
+  - podmonitors
+  - probes
+  - prometheusagents
+  - prometheuses
+  - prometheusrules
+  - scrapeconfigs
+  - servicemonitors
+  - thanosqueriers
+  - thanosrulers
+  - uiplugins
   verbs:
-    - get
-    - list
-    - watch
+  - get
+  - list
+  - watch

This aligns the monitoring.rhobs rule block with the 2-space style used by all other rule blocks in the file.

apiVersion: managed.openshift.io/v1alpha1
kind: SubjectPermission
metadata:
name: backplane-srep-rhobs-regional-cluster
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Stale srep in resource name; rename for consistency with the new RHOBS subject.

metadata.name is backplane-srep-rhobs-regional-cluster, but this SubjectPermission binds the openshift-backplane-rhobs service-account group (not srep) to the backplane-rhobs-regional-cluster-project ClusterRole. Keeping srep in the name looks like a copy-paste leftover from deploy/backplane/srep/hypershift/rhobs-cluster/20-srep.SubjectPermission.yml and will likely collide conceptually with that existing resource. Consider renaming to match.

🧹 Proposed fix
 metadata:
-  name: backplane-srep-rhobs-regional-cluster
+  name: backplane-rhobs-regional-cluster
   namespace: openshift-rbac-permissions

Consider also renaming the file from 20-srep.SubjectPermission.yml to 20-rhobs.SubjectPermission.yml for the same reason.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
name: backplane-srep-rhobs-regional-cluster
metadata:
name: backplane-rhobs-regional-cluster
namespace: openshift-rbac-permissions
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@deploy/backplane/rhobs/rhobs-cluster/20-srep.SubjectPermission.yml` at line
4, The resource metadata.name is stale: change the SubjectPermission resource
name from "backplane-srep-rhobs-regional-cluster" to
"backplane-rhobs-regional-cluster" to match the bound service-account group
"openshift-backplane-rhobs" and ClusterRole
"backplane-rhobs-regional-cluster-project"; update any internal references if
present and also consider renaming the file from "20-srep.SubjectPermission.yml"
to "20-rhobs.SubjectPermission.yml" so filename and resource name are
consistent.

@moadz moadz force-pushed the rhobs-rbac-backplane branch 2 times, most recently from 0a598dc to 37addfb Compare April 17, 2026 18:54
Comment thread deploy/backplane/rhobs/00-rhobs.namespace.yml Outdated
Comment thread deploy/backplane/srep/00-srep.namespace.yml Outdated
Copy link
Copy Markdown
Member

@typeid typeid left a comment

Choose a reason for hiding this comment

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

Let's fix the file and namespace names as commented, then this looks good to me.

Comment thread deploy/backplane/rhobs/00-rhobs.namespace.yml Outdated
@moadz moadz force-pushed the rhobs-rbac-backplane branch from 37addfb to 1512070 Compare April 20, 2026 09:07
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@deploy/backplane/rhobs/10-rhobs-cluster-project.ClusterRole.yml`:
- Around line 75-88: The ClusterRole in this file mixes cluster-scoped rules
(resources: clusterroles, clusterrolebindings, customresourcedefinitions) with a
namespaced SubjectPermission that uses namespacesAllowedRegex, which is invalid;
split out a new ClusterRole containing only the cluster-scoped resources
(clusterroles, clusterrolebindings, customresourcedefinitions) and remove those
resources from the existing ClusterRole, then bind the new ClusterRole via an
explicit clusterPermissions entry on the SubjectPermission (follow the binding
pattern used in 50-dedicated-admins.SubjectPermission.yaml) so namespace
restrictions remain on the remaining namespaced rules and cluster-scoped rules
are granted at cluster scope.
- Around line 18-49: The RBAC rules currently mix Prometheus Operator resources
into the monitoring.rhobs apiGroup; update the ClusterRole so Prometheus
Operator-owned resources (alertmanagers, podmonitors, prometheuses,
prometheusrules, servicemonitors) are listed under apiGroups:
["monitoring.coreos.com"] and RHOBS-specific resources (monitoringstacks,
uiplugins and any RHOBS-owned variants) remain under apiGroups:
["monitoring.rhobs"]; remove resources that are not actually deployed here
(alertmanagerconfigs, probes, prometheusagents, scrapeconfigs, thanosrulers) and
verify which apiGroup owns thanosqueriers in your environment before assigning
it (leave it in monitoring.rhobs only if RHOBS owns it).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 967858b9-6fe6-4d5c-9a90-a62b202a06a8

📥 Commits

Reviewing files that changed from the base of the PR and between 0a598dc and 1512070.

📒 Files selected for processing (5)
  • deploy/backplane/README.md
  • deploy/backplane/rhobs/00-rhobs.namespace.yml
  • deploy/backplane/rhobs/10-rhobs-cluster-project.ClusterRole.yml
  • deploy/backplane/rhobs/20-rhobs.SubjectPermission.yml
  • deploy/backplane/rhobs/config.yaml
✅ Files skipped from review due to trivial changes (4)
  • deploy/backplane/README.md
  • deploy/backplane/rhobs/00-rhobs.namespace.yml
  • deploy/backplane/rhobs/config.yaml
  • deploy/backplane/rhobs/20-rhobs.SubjectPermission.yml

Comment thread deploy/backplane/rhobs/10-rhobs-cluster.ClusterRole.yml
Comment on lines +75 to +88
- rbac.authorization.k8s.io
resources:
- clusterroles
- clusterrolebindings
- roles
- rolebindings
verbs:
- get
- list
- watch
- apiGroups:
- apiextensions.k8s.io
resources:
- customresourcedefinitions
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Find how SubjectPermission models cluster-scoped access elsewhere.
# Expectation: Cluster-scoped resources should use a distinct cluster-wide permission mechanism, not only namespace regex bindings.

rg -nP --type=yaml -C6 \
  'kind:\s*SubjectPermission|clusterPermissions|namespacesAllowedRegex|clusterroles|clusterrolebindings|customresourcedefinitions'

Repository: openshift/managed-cluster-config

Length of output: 50389


🏁 Script executed:

# Find the RHOBS ClusterRole file
fd -t f "rhobs" | head -20

Repository: openshift/managed-cluster-config

Length of output: 394


🏁 Script executed:

# Look for the actual file and RHOBS SubjectPermission
rg -l "rhobs" --type=yaml | grep -i subject

Repository: openshift/managed-cluster-config

Length of output: 206


🏁 Script executed:

# Search for references to "rhobs-cluster-project" ClusterRole
rg "rhobs-cluster-project" --type=yaml -A5 -B5

Repository: openshift/managed-cluster-config

Length of output: 58


🏁 Script executed:

# View the RHOBS SubjectPermission to see how rhobs ClusterRole is used
cat deploy/backplane/rhobs/20-rhobs.SubjectPermission.yml

Repository: openshift/managed-cluster-config

Length of output: 502


🏁 Script executed:

# View the complete RHOBS ClusterRole to see all rules
cat deploy/backplane/rhobs/10-rhobs-cluster-project.ClusterRole.yml

Repository: openshift/managed-cluster-config

Length of output: 1750


Cluster-scoped resources must not be mixed with namespace-scoped access rules in this ClusterRole.

The ClusterRole includes clusterroles, clusterrolebindings, and customresourcedefinitions—all cluster-scoped resources—yet the SubjectPermission binding restricts access using namespacesAllowedRegex: "(^rhobs.*)". This creates an unresolvable RBAC conflict: either the binding becomes a RoleBinding (rendering cluster-scoped rules inaccessible) or a ClusterRoleBinding (making the namespace restriction meaningless).

Separate these cluster-scoped resources into a distinct ClusterRole bound through an explicit clusterPermissions field, following the pattern used elsewhere in the codebase (e.g., 50-dedicated-admins.SubjectPermission.yaml).

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

In `@deploy/backplane/rhobs/10-rhobs-cluster-project.ClusterRole.yml` around lines
75 - 88, The ClusterRole in this file mixes cluster-scoped rules (resources:
clusterroles, clusterrolebindings, customresourcedefinitions) with a namespaced
SubjectPermission that uses namespacesAllowedRegex, which is invalid; split out
a new ClusterRole containing only the cluster-scoped resources (clusterroles,
clusterrolebindings, customresourcedefinitions) and remove those resources from
the existing ClusterRole, then bind the new ClusterRole via an explicit
clusterPermissions entry on the SubjectPermission (follow the binding pattern
used in 50-dedicated-admins.SubjectPermission.yaml) so namespace restrictions
remain on the remaining namespaced rules and cluster-scoped rules are granted at
cluster scope.

@moadz moadz requested review from bmeng and typeid April 20, 2026 09:19
@bmeng
Copy link
Copy Markdown
Contributor

bmeng commented Apr 21, 2026

@moadz can you help check the pre-sumbit job failure?
You can run the make locally to see if it is working for you

@moadz moadz force-pushed the rhobs-rbac-backplane branch from 1512070 to 25c30a0 Compare April 22, 2026 15:58
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (2)
deploy/backplane/rhobs/10-rhobs-cluster-project.ClusterRole.yml (2)

18-49: ⚠️ Potential issue | 🟠 Major

Finish separating Prometheus Operator resources from RHOBS resources.

This still mixes likely monitoring.coreos.com resources into the monitoring.rhobs rule, while the monitoring.coreos.com rule omits common Prometheus Operator resources such as podmonitors, alertmanagerconfigs, probes, prometheusagents, scrapeconfigs, and thanosrulers. RBAC requires the exact API group/resource pair, so these entries can silently fail to grant the intended read access.

Keep RHOBS-owned resources under monitoring.rhobs, and put Prometheus Operator resources under monitoring.coreos.com; verify thanosqueriers before leaving it in either group.

#!/bin/bash
# Description: Verify API group ownership for the monitoring resources referenced by this ClusterRole.
# Expectation: Resources served by monitoring.coreos.com should be granted under monitoring.coreos.com;
# RHOBS-specific resources should remain under monitoring.rhobs.

rg -nP --type=yaml -C3 \
  'apiVersion:\s*(monitoring\.coreos\.com|monitoring\.rhobs|monitoring\.thanos\.io)/|kind:\s*(AlertmanagerConfig|Alertmanager|MonitoringStack|PodMonitor|Probe|PrometheusAgent|Prometheus|PrometheusRule|ScrapeConfig|ServiceMonitor|ThanosQuerier|ThanosRuler|UIPlugin)\b'
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@deploy/backplane/rhobs/10-rhobs-cluster-project.ClusterRole.yml` around lines
18 - 49, The ClusterRole currently mixes apiGroups; split the resource lists so
that resources owned by RHOBS remain under apiGroup "monitoring.rhobs" and
Prometheus Operator resources are under "monitoring.coreos.com": in the
ClusterRole resource block, ensure "monitoring.rhobs" contains RHOBS-specific
entries (e.g., alertmanagerconfigs, monitoringstacks, prometheusagents,
uiplugins and any RHOBS-only scrapeconfigs/probes if applicable) and that
"monitoring.coreos.com" contains Prometheus Operator entries (e.g.,
alertmanagers, prometheuses, prometheusrules, servicemonitors, podmonitors,
probes, scrapeconfigs, thanosrulers as appropriate); verify ownership of
thanosqueriers and place it under the correct apiGroup, then keep verbs
(get/list/watch) the same for each apiGroup block.

75-88: ⚠️ Potential issue | 🟠 Major

Split cluster-scoped resources out of the namespace-scoped role.

clusterroles, clusterrolebindings, and customresourcedefinitions are cluster-scoped, but deploy/backplane/rhobs/20-rhobs.SubjectPermission.yml binds this role through namespace-scoped permissions with namespacesAllowedRegex. Those cluster-scoped rules will not be granted by namespace RoleBindings.

Move these resources to a separate ClusterRole bound via a cluster-scoped SubjectPermission mechanism, or remove them if RHOBS only needs namespace-scoped access.

#!/bin/bash
# Description: Confirm this ClusterRole is only referenced by namespace-scoped SubjectPermission permissions,
# and inspect existing cluster-scoped SubjectPermission patterns in the repo.

cat deploy/backplane/rhobs/20-rhobs.SubjectPermission.yml

rg -nP --type=yaml -C8 \
  'clusterPermissions:|namespacesAllowedRegex:|clusterRoleName:\s*backplane-rhobs-regional-cluster-project|kind:\s*SubjectPermission'
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@deploy/backplane/rhobs/10-rhobs-cluster-project.ClusterRole.yml` around lines
75 - 88, The ClusterRole currently lists cluster-scoped rules (resources:
clusterroles, clusterrolebindings, customresourcedefinitions) which cannot be
granted via namespace RoleBindings; extract those rules into a separate
ClusterRole (e.g., create a new ClusterRole containing only resources:
clusterroles, clusterrolebindings, customresourcedefinitions) and remove them
from the namespace-scoped role (the existing role name referenced as
backplane-rhobs-regional-cluster-project), then bind that new ClusterRole with a
cluster-scoped SubjectPermission (or remove the cluster-scoped rules if RHOBS
only needs namespace access); also update or verify the SubjectPermission that
currently references the namespace-scoped binding (the file that defines the
permissions bound via namespacesAllowedRegex) to point to the new ClusterRole or
to no longer reference cluster-scoped rules.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@deploy/backplane/rhobs/10-rhobs-cluster-project.ClusterRole.yml`:
- Around line 18-49: The ClusterRole currently mixes apiGroups; split the
resource lists so that resources owned by RHOBS remain under apiGroup
"monitoring.rhobs" and Prometheus Operator resources are under
"monitoring.coreos.com": in the ClusterRole resource block, ensure
"monitoring.rhobs" contains RHOBS-specific entries (e.g., alertmanagerconfigs,
monitoringstacks, prometheusagents, uiplugins and any RHOBS-only
scrapeconfigs/probes if applicable) and that "monitoring.coreos.com" contains
Prometheus Operator entries (e.g., alertmanagers, prometheuses, prometheusrules,
servicemonitors, podmonitors, probes, scrapeconfigs, thanosrulers as
appropriate); verify ownership of thanosqueriers and place it under the correct
apiGroup, then keep verbs (get/list/watch) the same for each apiGroup block.
- Around line 75-88: The ClusterRole currently lists cluster-scoped rules
(resources: clusterroles, clusterrolebindings, customresourcedefinitions) which
cannot be granted via namespace RoleBindings; extract those rules into a
separate ClusterRole (e.g., create a new ClusterRole containing only resources:
clusterroles, clusterrolebindings, customresourcedefinitions) and remove them
from the namespace-scoped role (the existing role name referenced as
backplane-rhobs-regional-cluster-project), then bind that new ClusterRole with a
cluster-scoped SubjectPermission (or remove the cluster-scoped rules if RHOBS
only needs namespace access); also update or verify the SubjectPermission that
currently references the namespace-scoped binding (the file that defines the
permissions bound via namespacesAllowedRegex) to point to the new ClusterRole or
to no longer reference cluster-scoped rules.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 05e38e1a-a2b5-440f-9335-cc4d96750def

📥 Commits

Reviewing files that changed from the base of the PR and between 1512070 and 25c30a0.

📒 Files selected for processing (5)
  • deploy/backplane/README.md
  • deploy/backplane/rhobs/00-rhobs.namespace.yml
  • deploy/backplane/rhobs/10-rhobs-cluster-project.ClusterRole.yml
  • deploy/backplane/rhobs/20-rhobs.SubjectPermission.yml
  • deploy/backplane/rhobs/config.yaml
✅ Files skipped from review due to trivial changes (2)
  • deploy/backplane/rhobs/config.yaml
  • deploy/backplane/rhobs/20-rhobs.SubjectPermission.yml
🚧 Files skipped from review as they are similar to previous changes (2)
  • deploy/backplane/README.md
  • deploy/backplane/rhobs/00-rhobs.namespace.yml

@moadz
Copy link
Copy Markdown
Author

moadz commented Apr 22, 2026

@bmeng

Successfully installed oyaml-1.0 pyyaml-6.0.3
+ scripts/enforce-backplane-rules.py
Backplane Rules: PASSED

Succeeds locally - i've rebased to try rerunning it.

@moadz moadz force-pushed the rhobs-rbac-backplane branch from 25c30a0 to ea6736d Compare April 27, 2026 15:03
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Apr 27, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: moadz
Once this PR has been reviewed and has the lgtm label, please assign bmeng 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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@hack/00-osd-managed-cluster-config-integration.yaml.tmpl`:
- Around line 30198-30199: Update the SubjectPermission's namespace regexes:
change namespacesAllowedRegex from (^rhobs.*) to a stricter ^rhobs-.* to only
match namespaces prefixed with "rhobs-"; then remove or replace the redundant
namespacesDeniedRegex (currently set to openshift-backplane-cluster-admin) since
it cannot match anything allowed by the tightened allowed regex—either drop that
denied entry or replace it with a meaningful exclusion if a specific sensitive
rhobs-* sub-namespace must be denied.

In `@hack/00-osd-managed-cluster-config-production.yaml.tmpl`:
- Around line 30197-30199: The namespacesAllowedRegex currently uses
'(^rhobs.*)' which also matches names like 'rhobsfoo' and includes unnecessary
parentheses; update the source template
deploy/backplane/rhobs/20-rhobs.SubjectPermission.yml to use a stricter anchored
pattern such as '^rhobs-' (or '^rhobs-.*' if a trailing match is desired) for
the namespacesAllowedRegex field so only namespaces with the 'rhobs-' prefix are
permitted; verify the change near the SubjectPermission that references
clusterRoleName backplane-rhobs-regional-cluster-project and ensure the
generated hack/00-osd-managed-cluster-config-production.yaml.tmpl reflects the
updated regex after regeneration.
- Around line 30116-30127: The rule block under apiGroup "monitoring.coreos.com"
incorrectly includes the resource "thanosqueriers"; remove "thanosqueriers" from
the resources list in the ClusterRole entry so that the monitoring.coreos.com
block only contains valid resources (alertmanagers, prometheuses,
prometheusrules, servicemonitors), and instead ensure "thanosqueriers" remains
only under the monitoring.rhobs block; make this change in the source
ClusterRole template
(deploy/backplane/rhobs/10-rhobs-cluster-project.ClusterRole.yml) so it
propagates to hack/00-osd-managed-cluster-config-*.yaml.tmpl on re-render.

In `@hack/00-osd-managed-cluster-config-stage.yaml.tmpl`:
- Around line 30079-30201: The ClusterRole contains cluster-scoped rules that
won't be granted by the SubjectPermission's namespace-scoped permissions and the
namespacesAllowedRegex is too broad; update
deploy/backplane/rhobs/20-rhobs.SubjectPermission.yml to either add a
clusterPermissions block that grants the ClusterRole's cluster-scoped read
rights (for rbac.authorization.k8s.io clusterroles/clusterrolebindings and
apiextensions.k8s.io/customresourcedefinitions) or remove those cluster-scoped
rules from deploy/backplane/rhobs/10-rhobs-cluster-project.ClusterRole.yml so
the ClusterRole only contains namespace-scoped rules, and change
namespacesAllowedRegex from (^rhobs.*) to (^rhobs-.*) to strictly match rhobs-
prefixed namespaces.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: dd3f1ea8-13b2-43e6-a9b2-c6b1435bbee5

📥 Commits

Reviewing files that changed from the base of the PR and between 25c30a0 and ea6736d.

📒 Files selected for processing (8)
  • deploy/backplane/README.md
  • deploy/backplane/rhobs/00-rhobs.namespace.yml
  • deploy/backplane/rhobs/10-rhobs-cluster-project.ClusterRole.yml
  • deploy/backplane/rhobs/20-rhobs.SubjectPermission.yml
  • deploy/backplane/rhobs/config.yaml
  • hack/00-osd-managed-cluster-config-integration.yaml.tmpl
  • hack/00-osd-managed-cluster-config-production.yaml.tmpl
  • hack/00-osd-managed-cluster-config-stage.yaml.tmpl
✅ Files skipped from review due to trivial changes (4)
  • deploy/backplane/rhobs/config.yaml
  • deploy/backplane/README.md
  • deploy/backplane/rhobs/10-rhobs-cluster-project.ClusterRole.yml
  • deploy/backplane/rhobs/20-rhobs.SubjectPermission.yml
🚧 Files skipped from review as they are similar to previous changes (1)
  • deploy/backplane/rhobs/00-rhobs.namespace.yml

Comment on lines +30198 to +30199
namespacesAllowedRegex: (^rhobs.*)
namespacesDeniedRegex: openshift-backplane-cluster-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.

⚠️ Potential issue | 🟡 Minor

Tighten namespacesAllowedRegex and reconsider the redundant namespacesDeniedRegex.

Two minor concerns on the SubjectPermission:

  1. namespacesAllowedRegex: (^rhobs.*) is only anchored at the start with no separator after rhobs, so it would also match unintended names like rhobsomething or rhobsystem. Per the PR description ("namespaces prefixed with rhobs-"), consider ^rhobs-.* to bind the role only to the intended RHOBS namespaces.
  2. namespacesDeniedRegex: openshift-backplane-cluster-admin cannot match anything already restricted by the allowed regex (no namespace can both start with rhobs and be openshift-backplane-cluster-admin), so it's effectively a no-op. It looks copy-pasted from the ODF SubjectPermission directly above (line 30049). Either drop it or replace it with something meaningful (e.g., explicitly excluding any sensitive sub-namespace, if applicable).

Note: this template is generated; the root-cause edit should land in deploy/backplane/rhobs/20-rhobs.SubjectPermission.yml and the template can then be regenerated.

📝 Proposed fix (apply at the source manifest)
       permissions:
       - clusterRoleName: backplane-rhobs-regional-cluster-project
-        namespacesAllowedRegex: (^rhobs.*)
-        namespacesDeniedRegex: openshift-backplane-cluster-admin
+        namespacesAllowedRegex: ^rhobs-.*
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
namespacesAllowedRegex: (^rhobs.*)
namespacesDeniedRegex: openshift-backplane-cluster-admin
namespacesAllowedRegex: ^rhobs-.*
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@hack/00-osd-managed-cluster-config-integration.yaml.tmpl` around lines 30198
- 30199, Update the SubjectPermission's namespace regexes: change
namespacesAllowedRegex from (^rhobs.*) to a stricter ^rhobs-.* to only match
namespaces prefixed with "rhobs-"; then remove or replace the redundant
namespacesDeniedRegex (currently set to openshift-backplane-cluster-admin) since
it cannot match anything allowed by the tightened allowed regex—either drop that
denied entry or replace it with a meaningful exclusion if a specific sensitive
rhobs-* sub-namespace must be denied.

Comment on lines +30116 to +30127
- apiGroups:
- monitoring.coreos.com
resources:
- alertmanagers
- prometheuses
- prometheusrules
- thanosqueriers
- servicemonitors
verbs:
- get
- list
- watch
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Confirm that thanosqueriers does NOT appear under monitoring.coreos.com in any source manifest,
# and confirm where the rule originates so the fix can be applied at the root cause.
fd -t f -e yml -e yaml . deploy/backplane/rhobs
echo "---- ClusterRole source ----"
cat deploy/backplane/rhobs/10-rhobs-cluster-project.ClusterRole.yml 2>/dev/null

echo "---- Search for thanosqueriers occurrences across templates and source ----"
rg -n --type=yaml -C2 'thanosqueriers'

echo "---- Verify parallel stage/integration templates contain the same dead rule ----"
rg -nP -C2 '\bthanosqueriers\b' hack/00-osd-managed-cluster-config-stage.yaml.tmpl hack/00-osd-managed-cluster-config-integration.yaml.tmpl 2>/dev/null

Repository: openshift/managed-cluster-config

Length of output: 40812


Remove thanosqueriers from the monitoring.coreos.com rule — it does not exist in that API group.

The resource thanosqueriers is not part of the monitoring.coreos.com API group (per Prometheus Operator). It is correctly listed under monitoring.rhobs at lines 30108–30111, but its presence in the monitoring.coreos.com block below is a copy-paste error and authorizes nothing.

This file is generated from deploy/backplane/rhobs/10-rhobs-cluster-project.ClusterRole.yml. The source must be corrected, and the same fix will propagate to hack/00-osd-managed-cluster-config-integration.yaml.tmpl and hack/00-osd-managed-cluster-config-stage.yaml.tmpl on re-render.

Suggested fix
       - apiGroups:
         - monitoring.coreos.com
         resources:
         - alertmanagers
         - prometheuses
         - prometheusrules
-        - thanosqueriers
         - servicemonitors
         verbs:
         - get
         - list
         - watch

Do not add thanosrulers unless confirmed with RHOBS — it lives under monitoring.thanos.io, not monitoring.coreos.com.

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

In `@hack/00-osd-managed-cluster-config-production.yaml.tmpl` around lines 30116 -
30127, The rule block under apiGroup "monitoring.coreos.com" incorrectly
includes the resource "thanosqueriers"; remove "thanosqueriers" from the
resources list in the ClusterRole entry so that the monitoring.coreos.com block
only contains valid resources (alertmanagers, prometheuses, prometheusrules,
servicemonitors), and instead ensure "thanosqueriers" remains only under the
monitoring.rhobs block; make this change in the source ClusterRole template
(deploy/backplane/rhobs/10-rhobs-cluster-project.ClusterRole.yml) so it
propagates to hack/00-osd-managed-cluster-config-*.yaml.tmpl on re-render.

Comment on lines +30197 to +30199
- clusterRoleName: backplane-rhobs-regional-cluster-project
namespacesAllowedRegex: (^rhobs.*)
namespacesDeniedRegex: openshift-backplane-cluster-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.

⚠️ Potential issue | 🟡 Minor

Tighten namespacesAllowedRegex to a strict rhobs- prefix.

(^rhobs.*) matches any namespace whose name simply starts with the literal rhobs — e.g., rhobs, rhobsfoo, rhobsy-test — not just the rhobs--prefixed namespaces described in the PR description. The outer parentheses are also unnecessary. Recommend anchoring on the hyphen so unintended namespaces created on a managed cluster cannot inherit these permissions.

This file is generated; apply the fix in deploy/backplane/rhobs/20-rhobs.SubjectPermission.yml so it propagates to the integration/stage/production templates consistently.

🛠️ Proposed fix
         - clusterRoleName: backplane-rhobs-regional-cluster-project
-          namespacesAllowedRegex: (^rhobs.*)
+          namespacesAllowedRegex: ^rhobs-.*
           namespacesDeniedRegex: openshift-backplane-cluster-admin
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- clusterRoleName: backplane-rhobs-regional-cluster-project
namespacesAllowedRegex: (^rhobs.*)
namespacesDeniedRegex: openshift-backplane-cluster-admin
- clusterRoleName: backplane-rhobs-regional-cluster-project
namespacesAllowedRegex: ^rhobs-.*
namespacesDeniedRegex: openshift-backplane-cluster-admin
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@hack/00-osd-managed-cluster-config-production.yaml.tmpl` around lines 30197 -
30199, The namespacesAllowedRegex currently uses '(^rhobs.*)' which also matches
names like 'rhobsfoo' and includes unnecessary parentheses; update the source
template deploy/backplane/rhobs/20-rhobs.SubjectPermission.yml to use a stricter
anchored pattern such as '^rhobs-' (or '^rhobs-.*' if a trailing match is
desired) for the namespacesAllowedRegex field so only namespaces with the
'rhobs-' prefix are permitted; verify the change near the SubjectPermission that
references clusterRoleName backplane-rhobs-regional-cluster-project and ensure
the generated hack/00-osd-managed-cluster-config-production.yaml.tmpl reflects
the updated regex after regeneration.

Comment on lines +30079 to +30201
- apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: backplane-rhobs-regional-cluster-project
rules:
- apiGroups:
- monitoring.thanos.io
resources:
- thanoscompacts
- thanosqueries
- thanosreceives
- thanosrulers
- thanosstores
verbs:
- get
- list
- watch
- apiGroups:
- monitoring.rhobs
resources:
- alertmanagerconfigs
- alertmanagers
- monitoringstacks
- podmonitors
- probes
- prometheusagents
- prometheuses
- prometheusrules
- scrapeconfigs
- servicemonitors
- thanosqueriers
- thanosrulers
- uiplugins
verbs:
- get
- list
- watch
- apiGroups:
- monitoring.coreos.com
resources:
- alertmanagers
- prometheuses
- prometheusrules
- thanosqueriers
- servicemonitors
verbs:
- get
- list
- watch
- apiGroups:
- loki.grafana.com
resources:
- lokistacks
verbs:
- get
- list
- watch
- apiGroups:
- route.openshift.io
resources:
- routes
verbs:
- get
- list
- watch
- apiGroups:
- template.openshift.io
resources:
- templates
verbs:
- get
- list
- watch
- apiGroups:
- rbac.authorization.k8s.io
resources:
- clusterroles
- clusterrolebindings
- roles
- rolebindings
verbs:
- get
- list
- watch
- apiGroups:
- apiextensions.k8s.io
resources:
- customresourcedefinitions
verbs:
- get
- list
- watch
- apiGroups:
- ''
resources:
- configmaps
- services
- serviceaccounts
verbs:
- get
- list
- watch
- apiGroups:
- apps
resources:
- deployments
- statefulsets
verbs:
- get
- list
- watch
- apiVersion: managed.openshift.io/v1alpha1
kind: SubjectPermission
metadata:
name: backplane-rhobs-regional-cluster
namespace: openshift-rbac-permissions
spec:
permissions:
- clusterRoleName: backplane-rhobs-regional-cluster-project
namespacesAllowedRegex: (^rhobs.*)
namespacesDeniedRegex: openshift-backplane-cluster-admin
subjectKind: Group
subjectName: system:serviceaccounts:openshift-backplane-rhobs
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Confirm SubjectPermission semantics: does `permissions` create RoleBindings only?
# And does `clusterPermissions` exist on the CRD as the way to grant cluster-scoped access?
fd -t f 'subjectpermission' -i
rg -nP -C3 '\b(permissions|clusterPermissions)\b' --iglob '*.yaml' --iglob '*.yml' -g 'deploy/**'
# Sanity-check other SubjectPermission definitions in this repo for prior art on cluster-scoped grants.
rg -nP -C2 '^\s*clusterPermissions:' --iglob '*.yml' --iglob '*.yaml'
# Inspect any vendored/operator type definitions if present.
rg -nP -C3 'type\s+SubjectPermissionSpec\b'

Repository: openshift/managed-cluster-config

Length of output: 50389


🌐 Web query:

openshift rbac-permissions-operator SubjectPermission permissions vs clusterPermissions semantics

💡 Result:

In the OpenShift RBAC Permissions Operator (rbac-permissions-operator), the SubjectPermission custom resource (CR) defines two distinct fields for granting permissions to a subject (specified by subjectKind and subjectName, e.g., a Group): - clusterPermissions: A list of cluster role names. These result in the creation of ClusterRoleBindings, granting the specified ClusterRoles to the subject cluster-wide (across all namespaces). This provides cluster-scoped or non-namespaced permissions. - permissions: A list of objects, each specifying a clusterRoleName along with optional namespacesAllowedRegex and namespacesDeniedRegex. These result in the creation of RoleBindings in matching namespaces (filtered by the regexes), granting the specified ClusterRole only within those specific namespaces. The key semantic difference is scope: clusterPermissions apply globally via ClusterRoleBindings, while permissions apply selectively to namespaces via RoleBindings. This allows fine-grained control, e.g., granting cluster-wide access for administrative tasks but restricting project-level access to user namespaces (excluding system ones like openshift-). Example from official operator docs: spec: subjectKind: Group subjectName: dedicated-admins clusterPermissions: - dedicated-admins-cluster # -> ClusterRoleBinding permissions: - clusterRoleName: dedicated-admins-project namespacesAllowedRegex: "." namespacesDeniedRegex: "(^kube-.|^openshift.|...)" # -> RoleBindings in allowed NS only The operator's SubjectPermission controller watches for changes to these CRs and reconciles the corresponding bindings accordingly.

Citations:


🏁 Script executed:

#!/bin/bash
# Inspect the source SubjectPermission file for rhobs
cat -n deploy/backplane/rhobs/20-rhobs.SubjectPermission.yml

echo "---"
echo "Searching for actual rhobs* namespace definitions in the repo:"
rg -nP 'name:\s+(rhobs|rhobs-)' --iglob '*.yml' --iglob '*.yaml' | head -20

Repository: openshift/managed-cluster-config

Length of output: 654


🏁 Script executed:

#!/bin/bash
# Check other SubjectPermission patterns for how regex is used elsewhere
echo "=== Sample of namespacesAllowedRegex patterns from repo ==="
rg -nP 'namespacesAllowedRegex:' --iglob '*.yml' --iglob '*.yaml' -A 1 | head -40

Repository: openshift/managed-cluster-config

Length of output: 4306


Cluster-scoped rules in ClusterRole won't be effective via this SubjectPermission, and the namespace regex is broader than the stated intent.

Two RBAC concerns in this generated template. Fixes must be applied to the source manifests under deploy/backplane/rhobs/ and the template regenerated.

  1. Cluster-scoped rules have no effect here.
    The SubjectPermission declares only permissions (lines 30196–30199), which the rbac-permissions-operator translates into RoleBindings—namespace-scoped only. Rules in the ClusterRole targeting cluster-scoped resources (rbac.authorization.k8s.io/{clusterroles,clusterrolebindings} and apiextensions.k8s.io/customresourcedefinitions) cannot be granted through RoleBindings and will be silently ineffective. To grant cluster-scoped read access, add a clusterPermissions block to the SubjectPermission (in deploy/backplane/rhobs/20-rhobs.SubjectPermission.yml); otherwise, remove these cluster-scoped rules from the ClusterRole (deploy/backplane/rhobs/10-rhobs-cluster-project.ClusterRole.yml) to avoid misleading authors.

  2. namespacesAllowedRegex: (^rhobs.*) matches more than "rhobs-" prefixed namespaces.
    This pattern matches "rhobs", "rhobsfoo", "rhobs-anything"—any string starting with "rhobs". If the intent is strictly namespaces with the rhobs- prefix, use (^rhobs-.*). Change this in deploy/backplane/rhobs/20-rhobs.SubjectPermission.yml.

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

In `@hack/00-osd-managed-cluster-config-stage.yaml.tmpl` around lines 30079 -
30201, The ClusterRole contains cluster-scoped rules that won't be granted by
the SubjectPermission's namespace-scoped permissions and the
namespacesAllowedRegex is too broad; update
deploy/backplane/rhobs/20-rhobs.SubjectPermission.yml to either add a
clusterPermissions block that grants the ClusterRole's cluster-scoped read
rights (for rbac.authorization.k8s.io clusterroles/clusterrolebindings and
apiextensions.k8s.io/customresourcedefinitions) or remove those cluster-scoped
rules from deploy/backplane/rhobs/10-rhobs-cluster-project.ClusterRole.yml so
the ClusterRole only contains namespace-scoped rules, and change
namespacesAllowedRegex from (^rhobs.*) to (^rhobs-.*) to strictly match rhobs-
prefixed namespaces.

@moadz
Copy link
Copy Markdown
Author

moadz commented Apr 28, 2026

@bmeng just resurrecting this PR, CI is green now.

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: backplane-rhobs-regional-cluster-project
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.

The suffix project is a bit misleading, can we just change the role name to backplane-rhobs-regional-cluster or backplane-rhobs-regional-cluster-role?

namespace: openshift-rbac-permissions
spec:
permissions:
- clusterRoleName: backplane-rhobs-regional-cluster-project
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.

same here

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed. :)

permissions:
- clusterRoleName: backplane-rhobs-regional-cluster-project
namespacesAllowedRegex: "(^rhobs.*)"
namespacesDeniedRegex: openshift-backplane-cluster-admin
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.

This namespacesDeniedRegex is not needed actually, as the above allowedRegex only includes the rhobs* namespaces

Copy link
Copy Markdown
Author

@moadz moadz May 1, 2026

Choose a reason for hiding this comment

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

I agree :) but it's a backplane-rule:

cluster-role-suffix: deploy/backplane/rhobs/10-rhobs-cluster-project.ClusterRole.yml: ClusterRole 'backplane-rhobs-regional-cluster-role' has suffix different from its containing file
subject-permission-deny-cluster-admin: deploy/backplane/rhobs/20-rhobs.SubjectPermission.yml: SubjectPermission 'backplane-rhobs-regional-role' has permission(s) which do not explicitly deny clusterRole(s) 'backplane-rhobs-regional-cluster-project' access to 'openshift-backplane-cluster-admin'

Comment on lines +18 to +26
- apiGroups:
- monitoring.rhobs.io
resources:
- monitoringstacks
- thanosqueriers
verbs:
- get
- list
- watch
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.

It got fixed in the generated templates, but can you also fix the indents here? As coderabbit suggested

@moadz moadz force-pushed the rhobs-rbac-backplane branch from ea6736d to 8d44256 Compare May 1, 2026 10:25
@moadz moadz requested a review from bmeng May 1, 2026 10:28
Comment thread deploy/backplane/rhobs/20-rhobs.SubjectPermission.yml Outdated
  Introduces a new backplane role for the RHOBS team to get read-only
  access to RHOBS regional clusters. This includes a ClusterRole scoped
  to Thanos, Loki, monitoring, and core Kubernetes resources, a
  SubjectPermission binding it to rhobs-prefixed namespaces, and a
  SelectorSyncSet config targeting clusters labeled as RHOBS regional.
@moadz moadz force-pushed the rhobs-rbac-backplane branch from 8d44256 to 3ea12a0 Compare May 6, 2026 13:08
@moadz moadz requested a review from bmeng May 6, 2026 13:08
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 6, 2026

@moadz: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/pr-check 3ea12a0 link true /test pr-check

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

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