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

Allow multiple databases in PostgresUser CR

Open toboshii opened this issue 3 years ago • 2 comments

First off, loving many things about this operator but one issue I ran into trying to migrate some things to it is that I have a few third party apps I run in my cluster that are designed in a way in which they need multiple Postgres databases (not schemas, completely separate databases) but only allow for a single hostname, username, password config. Afaict there's no way for ext-postgres-operator to handle this currently.

Ideally I'd like to be able to do something like this:

---
apiVersion: db.movetokube.com/v1alpha1
kind: Postgres
metadata:
  name: radarr-config-db
  namespace: media
spec:
  database: radarr-config
---
apiVersion: db.movetokube.com/v1alpha1
kind: Postgres
metadata:
  name: radarr-log-db
  namespace: media
spec:
  database: radarr-log
---
apiVersion: db.movetokube.com/v1alpha1
kind: PostgresUser
metadata:
  name: radarr-user
  namespace: media
spec:
  role: radarr
  databases:
    - name: radarr-config-db
      privileges: OWNER
    - name: radarr-log-db
      privileges: OWNER
  secretName: database
---

and would expect the database-radarr-user secret created to contain a role the has the referenced privileges on both referenced databases.

toboshii avatar Jul 20 '22 14:07 toboshii

On top of that, I'd even say it would be handy to have some sort of PostgresqlClass to run multiple instances of this operator in single cluster to handle multiple lets say RDS clusters.

michalschott avatar Aug 15 '22 15:08 michalschott

This would require changes to the secret that is created. For backward compatibility if there is just one database secret naming could remain the same. But if there are multiple databases then the secret would contain the database name in the secret name.

TheAceMan avatar Jul 07 '23 16:07 TheAceMan