Created
March 29, 2020 17:00
-
-
Save jirfag/c689fb133315c311843d716d444de8b7 to your computer and use it in GitHub Desktop.
Kubernetes connect to PostgreSQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -ue | |
PGPASSWORD=$(kubectl get secret -n postgres pg-su -o jsonpath="{.data.password}" | base64 --decode) | |
PGUSER=$(kubectl get secret -n postgres pg-su -o jsonpath="{.data.username}" | base64 --decode) | |
BASH_CMD="PGPASSWORD=${PGPASSWORD} psql -h pg-stolon-proxy.postgres -U ${PGUSER} -d api_prod" | |
kubectl -n postgres exec -ti pg-stolon-keeper-0 -- bash -c "${BASH_CMD}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment