For the complete documentation index, see llms.txt. This page is also available as Markdown.

Postgres Init Helm Chart

About Postgres Init Helm Chart

Context

The postgres-init Helm Chart was created to conveniently create a database on an existing PostgreSQL installation. Important to note that the Chart here assumes that PostgreSQL server is already available. The motivation to create this chart were the following:

  • In new OpenG2P deployment model, there is only one instance PostgreSQL server for a given sandbox/deployment/namespace. All databases are created within this server. In previous installations of Registry and PBMS, the Odoo chart would create its own instance of PostgreSQL running as a Pod on cluster. Now that we have externalized the databases, we needed a script to create database aprioriy and then install the respective modules.

  • Harmonising database creation across all modules such that there is a uniform way of creating datasbases.

Functionality

Following functionality is supported:

  • Creation of one or more databases (DB) on an existing PostgreSQL server

  • Creation of one DB user

  • Creation of DB user secret with password on Kuberenetes cluster.

  • Installation of any database extensions like pg_trgm.

The script is idempotent - which means if we run the init again, and if the database, user exist, it won't touch anything and just exit.

For multiple databases the same need to be specified as list item in values.yaml.

The database user secret created by this chart is set to 'keep' mode such that it doesn't get deleted if the Helm is uninstalled. This is important 'cause even if the Helm chart is uninstalled the database still exists, and therefore the secret must also exist. If you would like to tear down entire module clean, refer to the tear down instructions below.

Source code

Code of the script, Docker and Helm chart are available here.

Run

Instructions here pertain to running the Helm chart on command line.

Note that you generally will not need to run this Helm from command line as it is alreay embedded in the deployment Helm charts of respective modules.

  • Update / override following params in values.yaml

In production the PostgreSQL server is the external host instance on the Storage node, so set host to that node's address rather than an in-cluster service name. The commons-postgresql secret (created by the environment stage) holds the superuser credentials the init Job uses to create databases and roles.

  • Add list of databases you wish to create:

  • You may add extensions as list like:

  • Run

  • Verify that the database, users, extensions and secrets mentioned in values.yaml have been created,

Tear down

  • Uninstall the Helm chart

  • The above does not delete the database, users and secrets. Delete all these manually:

    • database (via psql)

    • db user (via psql)

    • secret on cluster (via kubectl or Rancher)

Versions

Helm Chart Version
Image version
Last modified
Contents

1.2.0

23-Jun-2026

Stable version

  • Job name truncated to ≤63 chars (k8s job-name label limit). See G2P-5186.

  • init-db.sh now re-syncs the DB user password on every run → idempotent; fixes auth failures after secret regeneration.

  • Job kept as a regular resource (not a Helm hook) — avoids deadlock when PostgreSQL is in the same release.

  • CI workflows for Docker build & Helm publish.

1.1.0

07-Apri-2026

Stable version

  • Added feature to optionally install Postgres extensions like pg_trgm .

  • Bug related to running as an upgrade fixed (in secrets.yaml)

1.0.0

09-Jan-2026

Stable version with following base features:

  • Creation of one or more databases (DB) on an existing Postgres server

  • Creation of DB user

  • Creation of DB user secret with password

Last updated

Was this helpful?