https://github.com/archef2000/ha-postgres
https://github.com/archef2000/ha-postgres
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/archef2000/ha-postgres
- Owner: archef2000
- License: gpl-3.0
- Created: 2025-01-28T11:55:18.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-22T12:30:21.000Z (over 1 year ago)
- Last Synced: 2025-08-02T02:31:29.131Z (11 months ago)
- Language: Shell
- Size: 22.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ha-postgres
## deploy
1. copy the docker-compose file to the desired location
2. edit the volumes path
3. set all environment variables to random secret values
4. run `docker compose up -d`
## motivation
I wanted to have an easy way to deploy a postgres cluster that has the least amount of moving parts and has one of the latest portgres versions with a posibility to upgrade it later.
## constraints
* at least 3 etcd containers
* at lease 2 postgres containers, but 3 are recommended
* at least 1 postgres-proxy container, but 2 are recommended for less downtime between updates
## architecture
```mermaid
flowchart TD
A[App] --> proxy
subgraph proxy[proxy service]
otherProxies[...]
subgraph proxy1
:5432[Listens on port 5432 for the current primary]
:5433[Listens on port 5433 for the replicas]
end
end
:5432 --> postgres1 --> etcd
:5433 --> postgres2 --> etcd
:5433 --> postgres3 --> etcd
proxy1 --> etcd
subgraph postgres service
postgres1[primary]
subgraph replicas
postgres3["replica of primary (postgres3)"]
postgres2["replica of primary (postgres2)"]
end
end
subgraph etcd[etcd service]
etcd1
etcd2
etcd3
end
```
## Usefull commands
```bash
etcdctl endpoint status --write-out=table
etcdctl member list
patronictl list
# check if postgres1 is the master
curl http://postgres1:8008/master
# test connection to proxy
psql postgres://postgres:postgres@postgresha:5432
```