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

Integrations with charmed applications are supported via the modern postgresql_client interface, and the legacy psql interface from the original version of the charm.

Modern 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

Legacy pgsql interface

Note that this interface is deprecated. See Legacy charm.

To integrate via the legacy interface, run

juju integrate postgresql:db <charm>

Extended permissions can be requested using the db-admin endpoint:

juju integrate postgresql:db-admin <charm>

Using the mattermost-k8s charm as an example, an integration with the legacy interface could be created as follows:

juju integrate postgresql-k8s:db mattermost-k8s:db

Extended permissions can be requested using the db-admin endpoint:

juju integrate postgresql-k8s:db-admin mattermost-k8s:db

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.

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