@kurt suggested me to post this Question here.
We are currently looking into Fly.io for our next migration of our Production Platform. Currently we are already testing apps for GraphQL and long-lived docker containers. It looks very promising for now.
We are also looking into the PostgreSQL Cluster solution, a main blocker for us ist, that we do need to use it with additional Servers and Tools outside of Fly.io, which do not have any possibility to open an Wireguard Tunnel.
As far as I could tell, the documentation only shows internal connection parameters, however we would need a public external URL or Anycast IP to connect to the PostgreSQL Cluster. It should still have the advantages of connected to the nearest read instance.
Is this even possible, planned to come or do you not suggest to use Fly’s PostgreSQL Cluster if it needs to be used with Servers outside of Fly.
This is doable! One thing to keep in mind is that our postgres clusters expose two ports:
Port 5432 is a proxy that always connects you to the primary writable node
Port 5433 is direct to postgres, and will work for read replicas
You can expose both of these publicly a couple of ways. What kind of apps are you connecting from? If it’s something like a FaaS you’ll want to do this with pgbouncer or pgpool, if it’s just external admin tools there might be a simpler way.
We do have FaaS Providers and IDE/Admin Tools running on Client Devices, but also regular VMs in the Cloud, needing to connect to the Cluster.
That said, if connecting to the read replicas on 5433, we do need to connect on the publicly always to the nearest one, without knowing the region of it.
So that must be taken in consideration for a way.
I am facing a similar scenario, where I’d like to expose a postgres database server externally to a third party reporting tool (Redash.io).
I think setting up pgpool or pgbouncer might be overkill for my use case. I wonder @kurt if you could elaborate a bit more on those simpler ways of doing it. It pretty fits the external admin tool scenario.
For context, I am helping one of my clients automating their business operations. Even though we are not going global or anything like that, it’d be just great if I didn’t had to manage all the server side configs with ansible and a VPS.
I wonder whether I should add the following section to the fly.toml in my postgres-ha clone.
handlers = ["tls"]
port = "5432"
@vicente.reig did you get anywhere with this? I’ve managed to set up external connections using the above approach but the tool we’re using (Mode) only allows encrypted connections, which I can’t seem to get working.
Did you manage anything without needing to resort to pgbouncer?
Is it possible to edit the services and ports of an automatically created postgres app (flyctl postgres create)? By default they don’t have a fly.toml and if you generate one, they don’t have an image or build. Do you have to use the github repository?
Or is there another way to edit the services/ports for the app?
By default they don’t have a fly.toml and if you generate one, they don’t have an image or build.
The image bit could certainly be better. To make this work, you will need to download the configuration file by running fly config save --app <app-name> and make your changes. To apply the changes, you will need to deploy while specifying the --image argument.
Note: Be sure to be mindful of the directory you’re in when you download the configuration file.
fly deploy . --image <repository>:<tag>
To determine what image you’re currently running, you can run the following:
That makes sense. I guess what I’m struggling with might still be related to the automatically installed Postgres. I had already saved and edited the config, but when I run fly image show I get what I assume is the special image for automatically installed Postgres.
Registry = registry-1.docker.io
Repository = flyio/postgres
I assume that’s because it’s a private repository or something? If I try to use fly-apps/postgres-ha:latest it says authentication required, but I’m not exactly sure flyio/postgres is exactly the same as fly-apps/postgres-ha.
My goal is to stay on the automatic Postgres install and just make it available to directly access the DB from the internet so I can use it with PostGIS in QGIS and QField.