reactive-tech / kubegres

Kubegres is a Kubernetes operator allowing to deploy one or many clusters of PostgreSql instances and manage databases replication, failover and backup.
https://www.kubegres.io
Apache License 2.0
1.32k stars 74 forks source link

Kubegres replication can leave primary stuck in read-only mode #187

Open hach-que opened 2 weeks ago

hach-que commented 2 weeks ago

Kubegres needs to run the following command to fix up primaries after they've been promoted at the Kubernetes level:

NAMESPACE=...
KUBEGRES_NAME=...
KUBEGRES_SECRET_NAME=...
kubectl -n $NAMESPACE exec -it $(kubectl -n $NAMESPACE get pod -l replicationRole=primary,app=$KUBEGRES_NAME -o=name) -- /bin/bash -c "PGPASSWORD=$(kubectl -n $NAMESPACE get secret $KUBEGRES_SECRET_NAME --template '{{.data.superUserPassword}}' | base64 --decode) /bin/psql -U postgres -c 'SELECT pg_promote();'"