Skip to content

Use specified ServiceAccountName in RoleBinding - #869

Open
toomasp wants to merge 5 commits into
cloudnative-pg:mainfrom
toomasp:correct-cluster-serviceaccount
Open

toomasp wants to merge 5 commits into
cloudnative-pg:mainfrom
toomasp:correct-cluster-serviceaccount

Conversation

@toomasp

@toomasp toomasp commented Apr 22, 2026

Copy link
Copy Markdown

Currently backup fails due to incorrect serviceAccount being used in the rolebinding, ie:

rpc error: code = Unknown desc = objectstores.barmancloud.cnpg.io "test123-postgresql-objectstore" is forbidden: User "system:serviceaccount:test123:custom-sa" cannot get resource "objectstores" in API group "barmancloud.cnpg.io" in the namespace "test123"

The cluster was created with spec.serviceAccountName set.

Signed-off-by: Toomas Pelberg <toomasp@gmx.net>
@toomasp
toomasp requested a review from a team April 22, 2026 12:43
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels Apr 22, 2026
@b4stien

b4stien commented Sep 2, 2026

Copy link
Copy Markdown

Is there a blocker here? @toomasp could you update this branch? @mnencia @leonardoce @fcanovai what is the process to get this merged?

(Just hit this issue in production)

@toomasp
toomasp requested a review from a team as a code owner September 3, 2026 20:38
@toomasp

toomasp commented Sep 3, 2026

Copy link
Copy Markdown
Author

Is there a blocker here? @toomasp could you update this branch? @mnencia @leonardoce @fcanovai what is the process to get this merged?

(Just hit this issue in production)

Did, can you proceed with the merge? it's such a simple change tbh.

@taherbert

Copy link
Copy Markdown

We hit this bug in production with v0.15.1. Our Clusters set spec.serviceAccountName to one shared ServiceAccount in each namespace, because EKS Pod Identity gives that account access to the backup bucket. The plugin's RoleBinding named the Cluster's name instead, so the sidecar got forbidden on its ObjectStore and ContinuousArchiving stayed False.

We applied this change to v0.15.1, and unit tests of BuildRoleBinding pass for both cases. From the code, EnsureRoleBinding also updates the subject of a RoleBinding that is already there, so current Clusters get the fix too. At this time, we add our own Role and RoleBinding for the shared account in each namespace, as #1117 describes. Please merge and release this fix.

This branch has not been deployed

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

Labels

bug Something isn't working size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants