Interface: pgsql

Motivation

Applications often require the ability to store data persistently in relational database tables. The pgsql interface provides access to PostgreSQL instances.

Relation Data

Key Set by Example values
host provides 10.10.0.1
port provides 5000
user provides juju_abc
password provides AbCd0123
schema_user provides juju_abc
schema_password provides AbCd0123
state provides standalone
version provides 10
database requires app-db
roles requires comma,seperated,list
extensions requires comma,seperated,list

Conversation

The requires side provides a database name. The provides side provides connection info for connecting to that database. The expectation is that providing charms will create the database and user account from scratch.

User Controller postgresql unit agent postgresql charm code other charm unit agent other charm code
juju relate postgresql:db other
Creates relation record in database
Run hooks/<relation>-relation-joined relation-set version=<version> state=<state>
Run hooks/<relation>-relation-joined relation-set database=<database>
Run hooks/<relation>-relation-changed Create <database>, relation-set host=<host> port=<port> user=<user> password=<password>
Run hooks/<relation>-relation-changed Retrieve connection info via relation-get, update the application’s configuration files

Typical endpoint names

provides

  • db - postgresql
  • db-admin- postgresql (provides an administrative user)

requires

  • [todo]

Links

2 Likes

Hey, thanks for working on this. I am trying to write a charm that uses the postgresql charm and the pgsql interface and some more fleshed out docs and examples would be very helpful.

Some points:

  • The official interface docs are lacking/out of date and the only way to figure things out is by looking at requires.py which has a lot of necessary info. This bug needs some love.
  • There is a lot of info in the postgresql charm README that I feel is necessary for charm developers to know. How to balance what info a charm developer needs from the interface vs the charm to get going?
  • Most of all, it would really be helpful to have some examples and recommended patterns of basic operations, master/standby setups and failovers for charm developers.
4 Likes

Pinging @stub. Any thoughts on the comments here? What’s the workflow for accepting contributions to the docs for this package?