简体   繁体   中英

Postgresql helm chart with initdbScripts

I have the following template:

image:
  tag: "13"
postgresqlUsername: postgres
postgresqlPassword: "12345678"
postgresqlDatabase: postgres
initdbScripts:
  init: |
    CREATE USER my_app WITH PASSWORD '12345678';
    CREATE DATABASE my_db;
    GRANT ALL PRIVILEGES ON DATABASE my_db TO my_app;

Running helm install postgresql bitnami/postgresql -f conf/postgresql/postgresql.yaml
spins up the deployment with the configmap correctly, but the database "my_db" and the user "my_app" were not created.

I need to use this setup to create multiple databases and users (hence postgresqlDatabase is not enough).

How should I work with the initdbScripts or what am I doing wrong?

The script needs a file extension so it knows how to run.

Add .sql to init :

image:
  tag: "13"
postgresqlUsername: postgres
postgresqlPassword: "12345678"
postgresqlDatabase: postgres
initdbScripts:
  init.sql: | # <-- Here
    CREATE USER my_app WITH PASSWORD '12345678';
    CREATE DATABASE my_db;
    GRANT ALL PRIVILEGES ON DATABASE my_db TO my_app;

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