Skip to content

feat(rbac): ship a reviewed set of editor roles for automation - #11784

Merged
mnencia merged 9 commits into
mainfrom
dev/11685
Nov 16, 2026
Merged

mnencia merged 9 commits into
mainfrom
dev/11685

Conversation

@gbartolini

@gbartolini gbartolini commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Automation (CI/CD, GitOps) that writes CloudNativePG resources had no shipped role short of a widened cnpg-manager or cluster-admin. Add cnpg-editor-role, an aggregate role for the namespaced resources, including Cluster, Pooler and DatabaseRole, whose write access is equivalent to PostgreSQL superuser access. Add the missing ImageCatalog, ClusterImageCatalog and DatabaseRole editor roles, and ship the existing Cluster, Backup, ScheduledBackup and Pooler ones. Document the roles and the opt-in aggregation into the built-in edit and admin roles.

Closes #11685

Assisted-by: Claude

@gbartolini
gbartolini requested a review from a team as a code owner October 28, 2026 12:43
@cnpg-bot cnpg-bot added backport-requested ◀️ This pull request should be backported to all supported releases release-1.28 release-1.30 labels Oct 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

❗ By default, the pull request is configured to backport to all release branches.

  • To stop backporting this pr, remove the label: backport-requested ◀️ or add the label 'do not backport'
  • To stop backporting this pr to a certain release branch, remove the specific branch label: release-x.y

@gbartolini gbartolini added do not backport This PR must not be backported - it will be in the next minor release and removed backport-requested ◀️ This pull request should be backported to all supported releases release-1.28 release-1.30 labels Oct 28, 2026

@valeriodelsarto valeriodelsarto 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.

Nice follow-up of #11684: shipping the per-resource editor roles and keeping the aggregation opt-in looks right to me.
Inline: the overlap with DatabaseRole through inline managed roles (in the role and on the page), and the permissions some kubectl cnpg commands need.

Comment thread config/rbac/editor_role.yaml Resolved
Comment thread docs/src/rbac.md Resolved
Comment thread docs/src/rbac.md Resolved
@jmealo

jmealo commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Overall, the role separation looks reasonable. Two possible documentation gaps:

  • Catalog privileges: Both catalog editor roles deserve explicit high-privilege warnings. Editing an ImageCatalog controls the PostgreSQL image used by referencing Clusters in its namespace; editing a ClusterImageCatalog can affect referencing Clusters across namespaces. Calling out that executable-image authority would help administrators assess these grants.
  • Replica restart permissions: Restarting a single replica requires both get and delete on Pods: instanceRestart fetches the Pod before deleting it. Granting only the documented delete permission alongside cnpg-editor-role will still fail.

One additional suggestion: expand the Pooler warning beyond authQuery to mention that write access also allows configuring the pod template and selecting an existing service account in the namespace. Those capabilities can expose namespace Secrets and the selected service account’s permissions, so they’re worth making explicit when describing the role’s privileges.

AI Disclosure: I used GPT-Astra 6 Medium Reasoning and Opus 5.5 to perform blind adversarial reviews and then merged/validated their findings by hand.

@litaocdl

Copy link
Copy Markdown
Collaborator

/test

@github-actions

Copy link
Copy Markdown
Contributor

@litaocdl

Copy link
Copy Markdown
Collaborator

/test

@github-actions

Copy link
Copy Markdown
Contributor

@litaocdl

Copy link
Copy Markdown
Collaborator

ok-to-merge

@litaocdl

Copy link
Copy Markdown
Collaborator

/ok-to-merge

@cnpg-bot cnpg-bot added the ok to merge 👌 This PR can be merged label Nov 14, 2026
@mnencia mnencia changed the title docs(rbac): ship a reviewed set of editor roles for automation feat(rbac): ship a reviewed set of editor roles for automation Nov 16, 2026
gbartolini and others added 2 commits November 16, 2026 15:01
Add `cnpg-editor-role`, an aggregate role for CI/CD and GitOps tooling,
limited to the namespaced resources that are not close to PostgreSQL
superuser access. Add the missing `ImageCatalog`, `ClusterImageCatalog` and
`DatabaseRole` editor roles, and ship the existing `Cluster`, `Backup`,
`ScheduledBackup` and `Pooler` ones, keeping the high-privilege roles
separate. Document the roles and the opt-in aggregation into the
built-in edit and admin roles.

Closes #11685

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]>
gbartolini and others added 6 commits November 16, 2026 15:01
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]>
Signed-off-by: Leonardo Cecchi <[email protected]>
Write access to Cluster already gives PostgreSQL superuser access and
the ability to create arbitrary Pods, through inline managed roles and
the podPatch annotation. Keeping DatabaseRole and Pooler out of the
aggregate role did not limit anything, and it made the role look safer
than it is.

Signed-off-by: Marco Nenciarini <[email protected]>
The Database role can install any extension available in the image,
including untrusted ones, and the operator does not control the image.

Signed-off-by: Marco Nenciarini <[email protected]>
Restarting a replica needs get and delete on Pods, not only delete.
ImageCatalog and ClusterImageCatalog control the image a Cluster runs,
so their roles are high privilege.

Signed-off-by: Marco Nenciarini <[email protected]>
@mnencia

mnencia commented Nov 16, 2026

Copy link
Copy Markdown
Member

/test ft=smoke

@github-actions

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not backport This PR must not be backported - it will be in the next minor release ok to merge 👌 This PR can be merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Provide a complete, reviewed set of editor roles for the automation persona

7 participants