I’ve put together a PostgreSQL Charm for Kubernetes that is ready for wider testing and feedback.
Here is an example deploying PostgreSQL and Mattermost into a k8s model:
juju deploy -n3 cs:~postgresql-charmers/postgresql-k8s postgresql
juju deploy cs:~mattermost-charmers/mattermost --config juju-external-hostname=foo.internal
juju add-relation mattermost postgresql:db
juju expose mattermost
The postgresql-k8s charm deploys PostgreSQL 12, in a high availability configuration (automatic failover requires 3 or more units). The deployment uses repmgr & repmgrd to manage replication and failover, and the charm sets up Kubernetes Service endpoints to route connections through to the current master or load balance to the available standby databases.
postgresql-k8s is a drop in replacement for the IaaS PostgreSQL Charm. It supports cross model relations and may be used as a server for both k8s and IaaS client charms. However, it is not (yet) configurable, and does not provide many features available in the IaaS PostgreSQL Charm. I hope that, if possible, new features are in the form of separate charms which can be related to the PostgreSQL k8s charm, rather than bloating the core charm with options and features that are not always necessary. For example, a pgbackup charm to make logical dumps and exfiltrate to bulk storage, rather than embed this and several variations in the charm. I expect the IaaS charm to take a similar approach over time.
Code is available in git at Git : Code : charm-k8s-postgresql or
git clone git+ssh://git.launchpad.net/charm-k8s-postgresql postgresql-k8s.