Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 328
itaied Avatar asked Oct 21 '25 14:10

itaied


1 Answers

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;
like image 155
Ryall Avatar answered Oct 23 '25 05:10

Ryall



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!