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

**URL:** https://forums.percona.com/t/creating-databases-users-secrets-for-postgres-on-boot-using-helm/23187
**Category:** Percona Distribution for PostgreSQL
**Tags:** percona, postgres
**Created:** [June 28, 2023, 4:45pm UTC](https://forums.percona.com/t/creating-databases-users-secrets-for-postgres-on-boot-using-helm/23187 "2023-06-28T16:45:10Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Satheesh\_Kumar](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/satheesh_kumar/32/11357_2.png) [@Satheesh\_Kumar](https://forums.percona.com/u/Satheesh_Kumar)
#### Post date: [June 28, 2023, 4:45pm UTC](https://forums.percona.com/t/creating-databases-users-secrets-for-postgres-on-boot-using-helm/23187/1 "2023-06-28T16:45:10Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Agustin\_G](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/agustin_g/32/14111_2.png) [@Agustin\_G](https://forums.percona.com/u/Agustin_G)
#### Post date: [July 5, 2023, 7:14pm UTC](https://forums.percona.com/t/creating-databases-users-secrets-for-postgres-on-boot-using-helm/23187/2 "2023-07-05T19:14:53Z")

</div>

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:

> **[Percona Operator for PostgreSQL - Application and system users](https://docs.percona.com/percona-operator-for-postgresql/2.0/users.html#custom-users-and-databases)**
>
> User accounts within the Cluster can be divided into two different groups:

---

<div class="post-metadata">

### Author: ![Satheesh\_Kumar](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/satheesh_kumar/32/11357_2.png) [@Satheesh\_Kumar](https://forums.percona.com/u/Satheesh_Kumar)
#### Post date: [July 6, 2023, 2:13pm UTC](https://forums.percona.com/t/creating-databases-users-secrets-for-postgres-on-boot-using-helm/23187/3 "2023-07-06T14:13:45Z")

</div>

Hi Agustin,

Now i upgraded the version 2.0 and above.

Can i use following syntax for creating users

```auto
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

---

<div class="post-metadata">

### Author: ![Slavisa\_Milojkovic](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/slavisa_milojkovic/32/7097_2.png) [@Slavisa\_Milojkovic](https://forums.percona.com/u/Slavisa_Milojkovic)
#### Post date: [July 7, 2023, 2:14pm UTC](https://forums.percona.com/t/creating-databases-users-secrets-for-postgres-on-boot-using-helm/23187/4 "2023-07-07T14:14:30Z")

</div>

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

```auto
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:

```auto
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

```

---

<div class="post-metadata">

### Author: ![Sergey\_Pronin](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/sergey_pronin/32/14887_2.png) [@Sergey\_Pronin](https://forums.percona.com/u/Sergey_Pronin)
#### Post date: [July 16, 2023, 1:08pm UTC](https://forums.percona.com/t/creating-databases-users-secrets-for-postgres-on-boot-using-helm/23187/5 "2023-07-16T13:08:47Z")

</div>

Hello all.

I fixed helm in this PR: [K8SPG-406 Fixes in helm by spron-in · Pull Request #230 · percona/percona-helm-charts · GitHub](https://github.com/percona/percona-helm-charts/pull/230/files)

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.

---

<div class="post-metadata">

### Author: ![Satheesh\_Kumar](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/satheesh_kumar/32/11357_2.png) [@Satheesh\_Kumar](https://forums.percona.com/u/Satheesh_Kumar)
#### Post date: [July 16, 2023, 1:29pm UTC](https://forums.percona.com/t/creating-databases-users-secrets-for-postgres-on-boot-using-helm/23187/6 "2023-07-16T13:29:51Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Sergey\_Pronin](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/sergey_pronin/32/14887_2.png) [@Sergey\_Pronin](https://forums.percona.com/u/Sergey_Pronin)
#### Post date: [July 16, 2023, 2:10pm UTC](https://forums.percona.com/t/creating-databases-users-secrets-for-postgres-on-boot-using-helm/23187/7 "2023-07-16T14:10:44Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ben\_goldenberg](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/ben_goldenberg/32/11503_2.png) [@ben\_goldenberg](https://forums.percona.com/u/ben_goldenberg)
#### Post date: [July 25, 2023, 9:25am UTC](https://forums.percona.com/t/creating-databases-users-secrets-for-postgres-on-boot-using-helm/23187/8 "2023-07-25T09:25:37Z")

</div>

@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?

---

<div class="post-metadata">

### Author: ![Slavisa\_Milojkovic](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/slavisa_milojkovic/32/7097_2.png) [@Slavisa\_Milojkovic](https://forums.percona.com/u/Slavisa_Milojkovic)
#### Post date: [July 27, 2023, 9:40am UTC](https://forums.percona.com/t/creating-databases-users-secrets-for-postgres-on-boot-using-helm/23187/9 "2023-07-27T09:40:42Z")

</div>

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.
