Mattermost Documentation Database Relations

The charm will not function without a database, so you will need to deploy the PostgreSQL charm somewhere.

Deploying PostgreSQL to the same model on Kubernetes

To deploy PostgreSQL to the same kubernetes model as Mattermost:

juju deploy cs:~postgresql-charmers/postgresql-k8s postgresql

Then simply use juju relate mattermost postgresql:db. This deployment style is recommended for testing purposes only.

Deploying PostgreSQL to another Juju model on IaaS

Cross-model relations are also supported. Create a suitable model on a different cloud, for example, LXD or OpenStack.

juju switch database
juju deploy cs:postgresql
juju offer postgresql:db

In most k8s deployments, traffic to external services from worker pods will be SNATed by some part of the infrastructure. You will need to know what the source addresses or address range is for the next step.

juju switch mattermost-test
juju find-offers  # note down offer URL; example used below:

It’s also possible you’ll need to grant specific access to the user you want to join the relation from. If you don’t see any output from the find-offers command, and run juju whoami to confirm your account name and then from the PostgreSQL model run juju grant ${user} consume ${offer-url}. Once you have something showing up in the output of juju find-offers you can proceed to the next step.

juju relate mattermost admin/database.postgresql --via

(In the case of postgresql, --via is needed so that the charm can configure pga_hba.conf to let the k8s pods connect to the database.)