Creating Databases, Users, Secrets for Postgres on boot using helm

I am using helm repo 1.4 for installing postgres distribution, if i want to create multiple databases and users associated with the database on pod start.
How can i configure.

I don’t find any useful document where we can customize the helm installation of postgres

Hi Satheesh,
In 1.4 you will have to manually create the users and databases after the cluster is up and running.
Starting from 2.x you can use the following:

Hi Agustin,

Now i upgraded the version 2.0 and above.

Can i use following syntax for creating users

spec:
  users:
    - name: admin
      databases:
        - pgtest
        - telemetry
      options: "CREATEDB CREATEROLE"
    - name: client
      databases:
        - pgtest
        - telemetry
        - messaging
      options: "CREATEDB CREATEROLE"
  • How to create a database, whether above mention database automatically created?
  • How can i integrate with helm
  • I f you have any saml repo. please share it with me
  • I also needed help on integrating with hasura

It auto-creates the users (passwords are in secret) and databases, but you need to patch the cluster resource PerconaPGcluster.
I tried the following

spec:
  users: 
    - name: postgres
    - name: test11
      databases:
        - test11
      options: "SUPERUSER"  

in values.yaml, but it creates nothing. I had to patch deployed custom pg cluster resource manually, and then it worked.
If I remove spec: in values, it shows an error on helm upgrade:

Error: UPGRADE FAILED: template: pg-db/templates/cluster.yaml:43:22: executing "pg-db/templates/cluster.yaml" at <.Values.users.name>: nil pointer evaluating interface {}.users

Hello all.

I fixed helm in this PR: K8SPG-406 Fixes in helm by spron-in · Pull Request #230 · percona/percona-helm-charts · GitHub

I also provide a small example in README on how to deploy a cluser with users.
Please try it out and leave comments. It will be merged soon.

1 Like

This i already fixed in my chart. you can still see issue with database init and parconi those also i have fixed. if you want me to raise a PR . i can do

1 Like

@Satheesh_Kumar please raise a PR for sure. We will review it and collaborate on merging it.

@Sergey_Pronin how can i set a password for a user by myself?
i want to set him a password that i have in my values.
i didnt see an option in the docs.
any idea?

In the 2.2.0 version, I had to connect to db as postgres user and use Postgres commands to ALTER USER passwords. Also, there is a secret for db users, but it won’t auto-change the password when changed in secret.