Unclear how to start with postgresql charm, anyone experienced?

I found a postgresql charm, and just want to start using a single node… but unclear what are the default credentials for a first time connector… how do I open a port so I can get into the DB via pgadmin?

I see the admin_addresses , in which I can add my pgadmin4’s IP… in order to allow it to connect… when unclear what are the login credentials… is it just the default? postgres with no password? I tried that and had no luck after trying to open the server to my host.

Anyone using this charm a lot and know what I am after?

In my experience you can just ssh to the unit, switch to the postgres user, run psql and set the password

juju ssh postgresql/0
sudo su - postgres
psql
 psql (10.6 (Ubuntu 10.6-0ubuntu0.18.04.1))
 Type "help" for help.
 postgres=# \password
 Enter new password:
 Enter it again:
 postgres=# \q
1 Like

Thank you @dvnt , do you also tend to open that port I mentioned ? For PGAdmin4 for instance ?

I will run this tonight and try again. How do you automate this process, add a charm layer and roll “your own” ?

I was under the impression this would be configurable out of the box but hadn’t quite caught on here how to get going, let alone automate this deploying step

Edit : I still cannot connect from the host machine, started up with this command, after having also changed the postgres password

image

image

Edit2:

I realize now, since I am using LXD and a network bridge… it may be that postgresql is not seeing my IP from my router… but the IP from the network bridge… i then added that… and it seemed to change the behavior slightly but it kind of just hung and then timed out.

Might just have to roll my own simpler charm here until I can come back and learn how to open this up properly… but it seems it has more to do with the fact I am on LXD rather than something juju related

putting this now over in LXD discussion https://discuss.linuxcontainers.org/t/unclear-how-to-connect-to-a-postgresql-instance-over-network-bridge/8174

edit:

I spun up a plain vanilla instance of ubuntu, installed postgresql … and got connected no problem… starting to believe the problem is in fact the charm or how I am trying to use it

Sorry for the late reply. I believe this has to do with the hosts postgres will accept connections from.

If you want postgres to accept remote connections from anywhere you should be able to do this:

juju config postgresql extra_pg_auth="host all all 0.0.0.0/0 md5"
2 Likes

confirmed to work! This should definitely get on the docs or a guide

ty!

2 Likes