postgres-operator icon indicating copy to clipboard operation
postgres-operator copied to clipboard

create namespaced role instead of using cluster role

Open FxKu opened this issue 5 years ago • 6 comments

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?

FxKu avatar Jan 09 '20 12:01 FxKu

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 avatar Jan 14 '20 15:01 FxKu

We're really interested in this feature.

Can I help somehow?

machine424 avatar Jan 18 '21 13:01 machine424

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

FxKu avatar Jan 26 '21 16:01 FxKu

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

machine424 avatar Feb 02 '21 06:02 machine424

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 :running_man:

caniko avatar Nov 24 '22 18:11 caniko

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.

rgarcia89 avatar Jan 23 '24 12:01 rgarcia89