zalando / postgres-operator

Postgres operator creates and manages PostgreSQL clusters running in Kubernetes
https://postgres-operator.readthedocs.io/
MIT License
4.35k stars 980 forks source link

Granting (non standard) privileges to user on database creation #1727

Open ball-hayden opened 2 years ago

ball-hayden commented 2 years ago

We're considering switching to using Postgres Operator instead of managing Patroni instances directly.

Part of our current setup script for new Postgres instances includes the following (where is a non-superuser):

GRANT EXECUTE ON FUNCTION pg_switch_wal TO "<username>";

This allows us to call pg_switch_wal when we open a console, ensuring that a WAL has been generated (and therefore, theoretically, archived) before we go ahead with potentially dangerous console work.

Is there a way to achieve this same behaviour using preparedDatabases? From https://postgres-operator.readthedocs.io/en/latest/user/#manifest-roles, it looks like I can only use a limited number of privilege levels?

FxKu commented 2 years ago

In Spilo, we granted this already to admin role. But likely you are not using the teams API feature. Not sure, if the admin role is created then but I think yes. At Zalando, team members will become part of the admin role and can therefore execute pg_switch_wal in their cluster.