zalando / postgres-operator

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

Adding extensions to databases not only to preparedDatabases #1472

Open memogarcia opened 3 years ago

memogarcia commented 3 years ago

Please, answer some short questions which should help us to understand your problem / question better?

Is it possible to allow the configuration of extensions in databases? At this moment I can only configure extensions on preparedDatabases because preparedDatabases doesn't allow to set users defined in users section to be the owners of that database (or at least the docs doesn't specify how to do this)

What I'm looking to do is one of the following:

  users:
    gitlab:
      - superuser
      - createdb
  databases:
    gitlabhq_production:
      owner: gitlab
      extensions:
        pg_trgm: public
        btree_gist: public

Or

  users:
    gitlab:
      - superuser
      - createdb
  preparedDatabases:
    gitlabhq_production:
      owner: gitlab
      extensions:
        pg_trgm: public
        btree_gist: public

Is this possible?

FxKu commented 3 years ago

The latter seems more doable because PreparedDatabase is a struct whereas Databases is of type map[string]string. You could also GRANT gitlabhq_production_owner TO gitlab (I know, not from the manifest). Not sure if specifying an alternate owner should replace the default owner role or if that should still be there. Then there are also default privileges - for which owner roles should it be defined?

weeix commented 8 months ago

This would indeed increase flexibility for infrastructure automation. Currently, AFAIK, if one needs to choose the username and install extensions at the same time, they either have to: