Repository navigation
docs(rbac): add read-only DBA persona samples and viewer role - #11684
Merged
Merged
Conversation
gbartolini
marked this pull request as draft
October 17, 2026 13:50
gbartolini
force-pushed
the
dev/11519
branch
6 times, most recently
from
October 19, 2026 08:53
1aeab8b to
9d7c4d5
Compare
gbartolini
marked this pull request as ready for review
October 19, 2026 08:53
valeriodelsarto
left a comment
Contributor
There was a problem hiding this comment.
Thanks Gabriele, the split between a standing read-only persona and the opt-in port-forward and Secret roles reads well. I checked the kubectl cnpg table against the plugin code: two rows need fixing, plus a question on Helm installs and a few nits inline.
gbartolini
force-pushed
the
dev/11519
branch
2 times, most recently
from
October 20, 2026 06:41
4efccac to
b714f2a
Compare
armru
approved these changes
Oct 22, 2026
Document how to give a human DBA read-only operational access without resorting to cluster-admin, and ship a CloudNativePG-only viewer role.
Add a new manifest, `cnpg-viewer-role`, a ClusterRole with read-only access to the whole postgresql.cnpg.io group, as well as barmancloud.cnpg.io and klio.cnpg.io API groups (CNPG projects).
Add a few samples in `docs/src/samples`, each with an example RoleBinding:
- rbac-dba-viewer.yaml: cnpg-dba-viewer, a self-contained read-only role covering all CloudNativePG resources, the Barman Cloud and Klio plugin resources, and the Kubernetes objects needed to diagnose a Cluster (pods, pod logs, events, services, configmaps, PVCs, jobs, PDBs, StatefulSets, VolumeSnapshots, leases). It also grants get on pods/proxy, which `kubectl cnpg status` needs. It grants no access to Secrets, pods/exec, pods/attach or pods/portforward.
- rbac-dba-portforward.yaml: optional, separate role for port-forward.
- rbac-dba-app-secret.yaml: optional namespaced Role granting `get` on a single named application Secret.
Add a new `rbac.md` page ("RBAC for Users") describing the available roles, which kubectl-cnpg commands work with cnpg-dba-viewer (derived from the API calls each command makes), the namespace-wide scope of these roles, the split between Kubernetes RBAC and PostgreSQL authentication, and how to aggregate `cnpg-viewer-role` into the built-in `view` role. It is a separate page so that `security.md`, which already covers the operator's own RBAC, does not grow further; `security.md` keeps a short pointer and its cross-references are updated.
Closes #11519
Assisted-by: Claude
Signed-off-by: Gabriele Bartolini <[email protected]>
Co-authored-by: Valerio Del Sarto <[email protected]> Signed-off-by: Gabriele Bartolini <[email protected]>
Co-authored-by: Valerio Del Sarto <[email protected]> Signed-off-by: Gabriele Bartolini <[email protected]>
Co-authored-by: Valerio Del Sarto <[email protected]> Signed-off-by: Gabriele Bartolini <[email protected]>
Co-authored-by: Valerio Del Sarto <[email protected]> Signed-off-by: Gabriele Bartolini <[email protected]>
Co-authored-by: Valerio Del Sarto <[email protected]> Signed-off-by: Gabriele Bartolini <[email protected]>
Helm installs do not get `cnpg-viewer-role`: the chart renders its own `<release>-view` ClusterRole, aggregated into `view`, `edit` and `admin` by `rbac.aggregateClusterRoles`. Say so where the roles are introduced and in the aggregation section. Assisted-by: Claude Signed-off-by: Gabriele Bartolini <[email protected]>
`kubectl auth can-i create pods/exec` reads `pods/exec` as the Pod named `exec`, so it checks `create` on Pods and answers `no` for the wrong reason: a user allowed to create Pods but not to exec gets `yes`, and a user allowed to port-forward gets `no` from the same form. Use `--subresource=exec` and say why. `kubectl cnpg psql` runs `kubectl exec` without the impersonation flags, and `kubectl cnpg report --logs` streams logs with a client built from the plain kubeconfig, so under `--as` both run with the caller's own identity and succeed even when the role forbids them. Warn against using them to try a role. The chart names its view role after its full name, which is `cnpg-cloudnative-pg-view` for a release named `cnpg`, not `<release>-view`. Its `rbac.aggregateClusterRoles` value also aggregates the chart's edit role into `edit` and `admin`, granting write access to CloudNativePG resources: say so where the value is recommended. Since #11687, `kubectl cnpg status` reports a missing `pods/exec` permission instead of failing those parts with an error: update the command table accordingly. Signed-off-by: Armando Ruocco <[email protected]>
leonardoce
approved these changes
Oct 26, 2026
Contributor
|
/ok-to-merge no code change |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Document how to give a human DBA read-only operational access without resorting to cluster-admin, and ship a CloudNativePG-only viewer role.
Add a new manifest,
cnpg-viewer-role, a ClusterRole with read-only access to the whole postgresql.cnpg.io group, as well as barmancloud.cnpg.io and klio.cnpg.io API groups (CNPG projects).Add a few samples in
docs/src/samples, each with an example RoleBinding:kubectl cnpg statusneeds. It grants no access to Secrets, pods/exec, pods/attach or pods/portforward.geton a single named application Secret.Add a new
rbac.mdpage ("RBAC for Users") describing the available roles, which kubectl-cnpg commands work with cnpg-dba-viewer (derived from the API calls each command makes), the namespace-wide scope of these roles, the split between Kubernetes RBAC and PostgreSQL authentication, and how to aggregatecnpg-viewer-roleinto the built-inviewrole. It is a separate page so thatsecurity.md, which already covers the operator's own RBAC, does not grow further;security.mdkeeps a short pointer and its cross-references are updated.Closes #11519
Assisted-by: Claude