Skip to content

create namespaced role instead of using cluster role#786

Open
FxKu wants to merge 9 commits into
masterfrom
spilo-service-account
Open

create namespaced role instead of using cluster role#786
FxKu wants to merge 9 commits into
masterfrom
spilo-service-account

Conversation

@FxKu

@FxKu FxKu commented Jan 9, 2020

Copy link
Copy Markdown
Contributor

In each namespace operator currently creates an additional ServiceAccount and binds it to the postgres-pod ClusterRole. This PR adds code to create a Role instead and let the RoleBinding reference it.

Next to pod_service_account_definition and pod_service_account_role_binding_definition, a third configuration parameter is added to allow users to configure the role definition as well.

Yet, this PR has now sync strategy for roles. What if you want to change the role's privileges? With one ClusterRole it's easy. Just edit it. But how to sync all roles the operator would create?

Comment thread docs/administrator.md Outdated
Comment thread pkg/controller/controller.go
@FxKu

FxKu commented Jan 14, 2020

Copy link
Copy Markdown
Contributor Author

Please tell, if the default name postgres-operator-patroni for ServiceAccount, RoleBinding and Role is fine for you. I could also think of postgres-operator-db-pods, postgres-operator-spilo ...

EDIT: postgres-pod it is now

@FxKu FxKu force-pushed the spilo-service-account branch 3 times, most recently from 9b3dcc8 to e40f714 Compare January 20, 2020 10:18
changed the default name, updated helm chart and docs
allow role to use privileged podsecurtitypolicies
@FxKu FxKu force-pushed the spilo-service-account branch from d30092c to cb96454 Compare February 17, 2020 10:38
@FxKu FxKu changed the title improve RBAC setup for postgres pods create namespaced role instead of using cluster role Feb 18, 2020
@FxKu FxKu mentioned this pull request Feb 18, 2020
@FxKu FxKu removed this from the 1.4 milestone Feb 18, 2020
@machine424

machine424 commented Jan 18, 2021

Copy link
Copy Markdown
Contributor

We're really interested in this feature.

Can I help somehow?

@FxKu

FxKu commented Jan 26, 2021

Copy link
Copy Markdown
Contributor Author

@machine424 thanks for your interest. I've rebased the branch now, so that you can continue working on it. The big open TODO here is the syncing part. What if you want to change the role? How are the existing roles updated then? That's why we went with another clusterrole instead, because it's one edit there and you are done. At some point we should also revisit the hard coded definitions for service account, role bindings (and roles what this PR adds).

@machine424

Copy link
Copy Markdown
Contributor

Ok, I'll give it a try, thanks.

@caniko

caniko commented Nov 24, 2022

Copy link
Copy Markdown

I really need this, it won't happen any time soon, right?

However, I am guessing that it is not possible to use the enable_cross_namespace_secret feature in this mode, correct? RBAC is a nightmare sometimes 🏃‍♂️

@rgarcia89

rgarcia89 commented Jan 23, 2024

Copy link
Copy Markdown

I would be interested in a namespaced deployment way too. I do have some use-cases where I do not have permission to create clusterroles due to policy. Roles and RoleBindings however would work to at least deploy the clusters into the same cluster or the namespace.

@FxKu FxKu added this to the wishlist milestone Jun 3, 2026
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.

6 participants