Created
November 24, 2018 16:11
-
-
Save dalmarcogd/249de4514bb0244e84a82f7532653ba3 to your computer and use it in GitHub Desktop.
Configure Cloud Sql Proxy in GKE - 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
# How to user | |
# configure_proxy_postgres_gke.sh <PATH_TO_KEY_FILE> <INSTANCE_CONNECTION_NAME> | |
if [$1 == ""] | |
then | |
echo "<PATH_TO_KEY_FILE required>!" | |
echo "configure_proxy_postgres_gke.sh <PATH_TO_KEY_FILE> <INSTANCE_CONNECTION_NAME>" | |
exit | |
fi | |
if [$2 == ""] | |
then | |
echo "<INSTANCE_CONNECTION_NAME required>!" | |
echo "configure_proxy_postgres_gke.sh <PATH_TO_KEY_FILE> <INSTANCE_CONNECTION_NAME>" | |
exit | |
fi | |
# Update OS and install dependencies | |
sudo apt-get update | |
sudo apt-get install postgresql-client | |
# Update Docker and change permission of user | |
curl https://get.docker.com | sh | |
sudo usermod -aG docker $USER | |
# Uploda the image | |
docker pull gcr.io/cloudsql-docker/gce-proxy:1.12 | |
# Run image | |
docker run -d -v /cloudsql:/cloudsql \ | |
-v $1:/config \ | |
-p 127.0.0.1:5432:5432 \ | |
gcr.io/cloudsql-docker/gce-proxy:1.12 /cloud_sql_proxy \ | |
-instances=$2=tcp:0.0.0.0:5432 -credential_file=/config |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment