This Dockerfile and docker-compose will run for you patroni cluster with 3 cluster. One of them is usual with 3 instances, others are needed only for specific test purposes and have specific configuration (like certs or pass). All postgres instances are configured with ssl by default, and there are different users for test purposes.
1. docker-compose build
2. docker-compose up -d
- Patroni Rest API:
localhost:[8001-8005]
(example http://patroni1:8003) - Postgres Ports:
localhost:[5001-5005]
(examplepsql --host=localhost --port=5003 --dbname=postgres --username=admin
,password=admin
) - HAProxy Statistics:
localhost:8404
(example http://localhost:8404) - Additional Patroni API
patroni[1-3,-cert,-pass]:8008
you can add them to your hosts (/etc/hosts
) these lines to the file127.0.0.1 patroni1 127.0.0.1 patroni2 127.0.0.1 patroni3 127.0.0.1 patroni-cert 127.0.0.1 patroni-pass
patroni[1-3]:[8001-8003]
- cluster is needed for general testpatroni-cert:8004
- cluster is needed to check patroni certificates and required client certificatespatroni-pass:8005
- cluster is needed to check patroni password and required password for unsafe requests
superuser
- used by patronireplicator
- used by patroni for replication set uprewind
- used by patroni for rewind set uptrust
- custom user, it doesn't have any password for connectionadmin
-custom user, it has general passwordadmin:admin
sslca
- custom user, it requiresverify-ca
connection and has passwordsslca:sslca
sslfull
- custom user, it requiresverify-full
connection and has passwordsslfull:sslfull
patroni
- it is used to connect to clusterpatroni-pass:8005
with password `patroni:patroni
In each cluster there is initial data set with tables
users
- it has 1000 rowsfilms
- it has 10000 rows
- Install Perl DBI library
apt install libdbi-perl libdbd-pg-perl
- Download pgcompacttable
curl -o /usr/bin/pgcompacttable https://raw.githubusercontent.com/dataegret/pgcompacttable/master/bin/pgcompacttable
- Make file executable
chmod +x /usr/bin/pgcompacttable
Now you can use pgcompacttable from your console, Ivory will use it as well
These certificates are only needed for testing purposes, please, don't use them in real VMs, you can follow instruction and generate them. Certificates were generated for 24855 days (End day is 4 May 2091), probably it should be enough not to keep them for some time :)
First go to the certs package cd certs
- Certificate Authority
- Private Key
openssl ecparam -name prime256v1 -genkey -noout -out ca/ca.key
- Certificate
openssl req -new -x509 -sha256 -key ca/ca.key -subj "/O=Ivory" -out ca/ca.crt -days 24855
- Private Key
- Client
- Private Key
openssl ecparam -name prime256v1 -genkey -noout -out client/client.key
- Signing Request
openssl req -new -sha256 -key client/client.key -subj "/CN=development/O=Ivory" -out client/client.csr
- Certificate
openssl x509 -req -in client/client.csr -CA ca/ca.crt -CAkey ca/ca.key -CAcreateserial -out client/client.crt -days 24855 -sha256
- Private Key
- Server
- Private Key
openssl ecparam -name prime256v1 -genkey -noout -out server/server-cert.key
- Signing Request
openssl req -new -sha256 -key server/server-cert.key -subj "/CN=server-cert/O=Ivory" -addext "subjectAltName=DNS:server-cert" -out server/server-cert.csr
- Certificate
openssl x509 -req -in server/server-cert.csr -CA ca/ca.crt -CAkey ca/ca.key -CAcreateserial -extfile <(printf "subjectAltName=DNS:server-cert") -out server/server-cert.crt -days 24855 -sha256
- Private Key
- Certificate Authority
- CRT
openssl x509 -noout -text -in ca/ca.crt
- CRT
- Client
- Verify
openssl verify -CAfile ca/ca.crt client/client.crt
- CSR
openssl req -noout -text -in client/client.csr
- CRT
openssl x509 -noout -text -in client/client.crt
- Verify
- Server
- Verify
openssl verify -CAfile ca/ca.crt server/server.crt
- CSR
openssl req -noout -text -in server/server.csr
- CRT
openssl x509 -noout -text -in server/server.crt
- Verify
certs
├── ca
│ ├── ca.key -- Certificate Authority (CA) Private Key
│ └── ca.crt -- Certificate Authority (CA) Certificate
├── client (used in ivory ui)
│ ├── client.key -- Client Certificate Private Key
│ ├── client.scr -- Client Certificate Signing Request
│ └── client.crt -- Client Certificate
└── server (used in any server postgres, patroni, etc)
├── server.key -- Server Certificate Private Key
├── server.scr -- Server Certificate Signing Request
└── server.crt -- Server Certificate