Skip to content

Commit 493c333

Browse files
authored
fix(manifests): fix RoleBinding subject namespace via Kustomize replacement (#1168)
## Summary Follow-up to #1167. The wired-in RBAC had two issues: 1. **Wrong subject namespace**: `subjects[0].namespace` was hardcoded to `ambient-code--runtime-int`, but the CP runs in whatever namespace the overlay deploys to. When deployed to `ambient-code--ambient-s0`, the binding was silently wrong. 2. **Duplicate ClusterRole/ClusterRoleBinding**: The overlay had its own `ClusterRole`/`ClusterRoleBinding` duplicating what `base/rbac/control-plane-clusterrole.yaml` already provides. ## Fix - Remove the duplicated `ClusterRole`/`ClusterRoleBinding` from `ambient-control-plane-rbac.yaml` - Keep only the MPP-specific `Role`/`RoleBinding` for `tenantnamespaces.tenant.paas.redhat.com` - Add a Kustomize `replacement` that sources `subjects[0].namespace` from the `ambient-control-plane` ServiceAccount's `metadata.namespace` — which Kustomize automatically rewrites to match the overlay's `namespace:` field. Any future overlay deploying to a different namespace gets the correct binding automatically, with zero duplication. ## Verification ``` kustomize build components/manifests/overlays/mpp-openshift/ # RoleBinding subjects[0].namespace == ambient-code--runtime-int ✓ ``` ## Test plan - [ ] Apply to MPP cluster and confirm no Forbidden errors on `tenantnamespaces` operations - [ ] CP pod logs show successful project namespace provisioning 🤖 Generated with [Claude Code](https://claude.ai/code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Simplified permissions by removing unused role declarations. * Improved namespace configuration synchronization for role bindings. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2 parents 0445893 + ad11f7c commit 493c333

2 files changed

Lines changed: 12 additions & 28 deletions

File tree

components/manifests/overlays/mpp-openshift/ambient-control-plane-rbac.yaml

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,4 @@
11
apiVersion: rbac.authorization.k8s.io/v1
2-
kind: ClusterRole
3-
metadata:
4-
name: ambient-control-plane-project-namespaces
5-
rules:
6-
- apiGroups: [""]
7-
resources: ["secrets", "serviceaccounts", "services"]
8-
verbs: ["get", "list", "watch", "create", "delete", "deletecollection"]
9-
- apiGroups: [""]
10-
resources: ["pods"]
11-
verbs: ["get", "list", "watch", "delete", "deletecollection"]
12-
- apiGroups: ["rbac.authorization.k8s.io"]
13-
resources: ["rolebindings"]
14-
verbs: ["get", "list", "watch", "create", "delete"]
15-
---
16-
apiVersion: rbac.authorization.k8s.io/v1
17-
kind: ClusterRoleBinding
18-
metadata:
19-
name: ambient-control-plane-project-namespaces
20-
roleRef:
21-
apiGroup: rbac.authorization.k8s.io
22-
kind: ClusterRole
23-
name: ambient-control-plane-project-namespaces
24-
subjects:
25-
- kind: ServiceAccount
26-
name: ambient-control-plane
27-
namespace: ambient-code--runtime-int
28-
---
29-
apiVersion: rbac.authorization.k8s.io/v1
302
kind: Role
313
metadata:
324
name: ambient-control-plane-tenant-namespaces

components/manifests/overlays/mpp-openshift/kustomization.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ resources:
1515
- ambient-control-plane-rbac.yaml
1616
- ambient-tenant-ingress-netpol.yaml
1717

18+
replacements:
19+
- source:
20+
kind: ServiceAccount
21+
name: ambient-control-plane
22+
fieldPath: metadata.namespace
23+
targets:
24+
- select:
25+
kind: RoleBinding
26+
name: ambient-control-plane-tenant-namespaces
27+
fieldPaths:
28+
- subjects.0.namespace
29+
1830
patches:
1931
- path: ambient-api-server-args-patch.yaml
2032
target:

0 commit comments

Comments
 (0)