简体   繁体   中英

how to use postgres.db.name for multiple databases in kubernetes configMaps

So I want to create multiple postgresql databases in the kubernetes deployment. I tried with the below configMaps configuration but the databases are not being created. I tried to log into the postgres db pod with one of the database names I used in the configMaps but it say's the databse doesn't exist.

method 1:

apiVersion: v1
kind: ConfigMap
metadata:
  name: hydra-kratos-postgres-config
  labels:
    app: hydra-kratos-db
data:
  postgres.db.user: pguser
  postgres.db.password: secret
  postgres.db.name: 
    - postgredb1
    - postgredb2
    - postgredb3

method 2:

apiVersion: v1
kind: ConfigMap
metadata:
  name: hydra-kratos-postgres-config
  labels:
    app: hydra-kratos-db
data:
  POSTGRES_USER: pguser
  POSTGRES_PASSWORD: secret
  POSTGRES_MULTIPLE_DATABASES:
    - kratos
    - hydra


Would appreciate any suggestions on this. Thank you.

I assume you are using official Postgres image - by default it doesn't support multiple databases declaration on init. You could try building your own Postgres image like in this repo . If you create k8s deployment based on such image, I think there is a chance that your variable POSTGRES_MULTIPLE_DATABASES could work.

Let me know if you decide to try this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM