How to integrate with PostgreSQL

vmk8s

Integrations , also known as “relations” are connections between two applications with compatible endpoints. These connections simplify the creation and management of users, passwords, and other shared data.

Charmed PostgreSQL can be integrated with any charmed application that supports its interfaces.

If you are a charm developer who wants to implement PostgreSQL-compatible endpoints, skip ahead to Integrate with your charm.

If you are a charm user who wants to know more about integrating PostgreSQL with existing charms or applications, continue reading Integrate with a client application.

Integrate with a client application

PostgreSQL can be integrated with other charms that support the postgresql_client interface and with non-Juju applications.

Charms with the postgresql_client interface

To integrate with a charmed application that already supports the postgresql_client interface (for example, PgBouncer or Temporal K8s) run

juju integrate postgresql:database <charm>

To remove the integration, run

juju remove-relation postgresql <charm>
juju integrate postgresql-k8s:database <charm>

To remove the integration, run

juju remove-relation postgresql-k8s <charm>

See also: All compatible charms

Other applications

To integrate with a charm that doesn’t support the interface or a client application that lives outside of Juju, use the data-integrator charm to create the required credentials and endpoints.

Deploy data-integrator:

juju deploy data-integrator --config database-name=<name>

Integrate with PostgreSQL:

juju integrate data-integrator postgresql
juju integrate data-integrator postgresql-k8s

Use the get-credentials action to retrieve credentials from data-integrator:

juju run data-integrator/leader get-credentials

See also: How to manage passwords for information about credentials, such as password rotation or requesting a custom username.

Integrate with your charm

To add native support for PostgreSQL integrations in your charm, see data-platform-libs .

See also: Ops | Integrate your charm with PostgreSQL