Skip to content

feat(chart): allow disabling chart RBAC and scoping operator to namespaces#469

Open
stubbi wants to merge 1 commit intomainfrom
feat/rbac-customization
Open

feat(chart): allow disabling chart RBAC and scoping operator to namespaces#469
stubbi wants to merge 1 commit intomainfrom
feat/rbac-customization

Conversation

@stubbi
Copy link
Copy Markdown
Contributor

@stubbi stubbi commented Apr 28, 2026

Closes #468.

Summary

  • Add rbac.create Helm value (default true); set to false to skip chart-managed RBAC so operators can supply their own
  • Add watchNamespaces Helm value (default empty/cluster-wide); when set, the chart renders per-namespace Role/RoleBinding pairs instead of ClusterRole/ClusterRoleBinding, and the manager passes a new --watch-namespaces flag so its informer cache is scoped to that list (plus the operator's own namespace, so backup credential lookups still work)
  • Move manager RBAC rules into a single openclaw-operator.managerRules named template so the cluster-scoped and namespaced renderings stay in sync from one source of truth
  • hack/check-helm-rbac-sync.sh now parses that helper and asserts rbac.yaml still includes it, so removing the include or dropping a permission still fails CI

Test plan

  • go build ./... and go vet ./...
  • go test ./cmd/... ./internal/resources/ (new parseWatchNamespaces test added)
  • golangci-lint run ./...
  • bash hack/check-helm-rbac-sync.sh passes; verified with negative tests that it fails when the include is removed and when a permission is dropped
  • bash hack/sync-chart-crds.sh --check passes
  • helm lint charts/openclaw-operator/
  • helm template renders correctly in three modes:
    • default → ClusterRole + ClusterRoleBinding (unchanged)
    • --set 'watchNamespaces={team-a,team-b}'Role + RoleBinding per namespace, deployment receives --watch-namespaces=team-a,team-b
    • --set rbac.create=false → no RBAC objects rendered
  • e2e verification on a kind cluster (relies on existing CI matrix)

🤖 Generated with Claude Code

…paces

Adds two Helm values to address #468:

- `rbac.create` (default true) skips chart-managed RBAC when false so
  operators can supply their own (e.g. via a centrally managed policy)
- `watchNamespaces` (default empty) restricts the operator to a fixed
  list of namespaces. The chart switches from ClusterRole/ClusterRoleBinding
  to per-namespace Role/RoleBinding, and the manager passes
  `--watch-namespaces` so its informer cache only watches those namespaces
  (plus the operator's own namespace, for backup credentials).

The manager rules are now sourced from a single
`openclaw-operator.managerRules` named template so the same set is rendered
into either the ClusterRole or per-namespace Roles. The
`hack/check-helm-rbac-sync.sh` guard now parses that helper and asserts
rbac.yaml still includes it, so a stale chart still fails CI.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 48.38710% with 16 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/main.go 48.38% 16 Missing ⚠️

📢 Thoughts on this report? Let us know!

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.

Allow for Operator RBAC customization

2 participants