Zalando operator to create highly available databases
kubectl get pods -o go-template='{{range .items}} kubectl -n {{.metadata.namespace}} exec {{.metadata.name}} -- patronictl list{{"\n"}}{{end}}' -A|grep postgres-0|bash -C
- patroni manages the cluster
patronictl list
- list member and statuspatronictl reinit <cluster> <member>
- reinit broken node
- in-place upgrade:
su postgres -c "python3 /scripts/inplace_upgrade.py 2"
- cannot re-create DB cluster:
kubectl delete poddisruptionbudgets postgres-<chart name>-zalando-postgres-cluster-postgres-pdb
- apply backup:
- get into LEADER postgres node
- delete old DB:
psql -U postgres -c 'drop database "tt-rss"'
apt update && apt install -y openssh-client
rsync anunez@nas:/volume1/kubernetes/backup/db/tt-rss/backup .
psql -U postgres -f backup
- list status of all clusters:
kubectl get pods -o go-template='{{range .items}} kubectl -n {{.metadata.namespace}} exec {{.metadata.name}} -- patronictl list{{"\n"}}{{end}}' -A|grep postgres-0|bash -C
- reinit member of cluster:
- kubectl exec -ti recipes-db-zalando-postgres-cluster-postgres-0 -- patronictl reinit
Enter psql with psql -U postgres
SELECT rolpassword FROM pg_authid;
ALTER USER postgres WITH PASSWORD 'new_password';