This repository was archived by the owner on Nov 30, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 7 files changed +30
-25
lines changed
Expand file tree Collapse file tree 7 files changed +30
-25
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ SHELL := /usr/bin/env bash
1818# All is the first target in the file so it will get picked up when you just run 'make' on its own
1919linting : check_shell check_python check_golang check_terraform check_docker check_base_files check_headers check_trailing_whitespace
2020
21- SQLNAME := demo-postgres-3
21+ SQLNAME := demo-postgres-5
2222
2323# The .PHONY directive tells make that this isn't a real target and so
2424# the presence of a file named 'check_shell' won't cause this target to stop
Original file line number Diff line number Diff line change @@ -109,15 +109,21 @@ If you don't have a Google Cloud account you can sign up for a [free account](ht
109109
110110## Deployment
111111
112- Deployment is fully automated except for a few prompts for user input . In order
113- to deploy you need to run ** create.sh** and follow the prompts . The script
112+ Deployment is fully automated. In order
113+ to deploy you need to run ** create.sh** . The script
114114takes the following parameters, in order:
115115* A name for your Cloud SQL instance
116116* A username for a new Postgres user that you will use to connect to the
117117instance with
118118* A username for the pgAdmin console
119119
120- Example: ` ./create.sh INSTANCE_NAME POSTGRES_USERNAME PGADMIN_USERNAME `
120+ The script requires the following environment variables to be defined:
121+ * USER_PASSWORD - the password to login to the Postgres instance
122+ * PG_ADMIN_CONSOLE_PASSWORD - the password to login to the pgAdmin UI
123+
124+ Here is what it looks like to run ** create.sh** :
125+
126+ ``` USER_PASSWORD=password PG_ADMIN_CONSOLE_PASSWORD=password ./create.sh INSTANCE_NAME POSTGRES_USERNAME PGADMIN_USERNAME ```
121127
122128** create.sh** will run the following scripts:
1231291 . enable_apis.sh - enables the Kubernetes Engine API and Cloud SQL Admin API
Original file line number Diff line number Diff line change 1919
2020set -o errexit
2121
22- CLUSTER_NAME=postgres-demo-cluster
23- PROJECT=$( gcloud config get-value core/project)
22+ ROOT=$( dirname " ${BASH_SOURCE[0]} " )
23+ source " ${ROOT} " /constants.sh
24+
25+
2426
2527# This line is just to eliminate a warning that GKE behavior will change in the
2628# future. If we just set the new behavior now it doesn't warn us
Original file line number Diff line number Diff line change 1+ PROJECT=$( gcloud config get-value core/project)
2+
3+ CLUSTER_ZONE=$( gcloud config get-value compute/zone)
4+ CLUSTER_NAME=postgres-demo-cluster
5+
6+ INSTANCE_REGION=$( gcloud config get-value compute/region)
7+
8+ SA_NAME=postgres-demo-sa
9+ NODE_SA_NAME=postgres-demo-node-sa
10+ FULL_SA_NAME=$SA_NAME @$PROJECT .iam.gserviceaccount.com
11+ FULL_NODE_SA_NAME=$NODE_SA_NAME @$PROJECT .iam.gserviceaccount.com
Original file line number Diff line number Diff line change 1818# Cloud SQL instance takes a long time so deleting it is a separate step
1919# that includes a prompt in another script
2020
21- SA_NAME=postgres-demo-sa
22- NODE_SA_NAME=postgres-demo-node-sa
23- PROJECT=$( gcloud config get-value core/project)
24- CLUSTER_ZONE=$( gcloud config get-value compute/zone)
25-
26- FULL_SA_NAME=$SA_NAME @$PROJECT .iam.gserviceaccount.com
27- FULL_NODE_SA_NAME=$NODE_SA_NAME @$PROJECT .iam.gserviceaccount.com
21+ ROOT=$( dirname " ${BASH_SOURCE[0]} " )
22+ source " ${ROOT} " /constants.sh
2823
2924gcloud container clusters delete \
3025postgres-demo-cluster --zone " $CLUSTER_ZONE " --quiet
Original file line number Diff line number Diff line change 2020# The second is for the GKE nodes and it gets the minimal permissions needed
2121# for logging and monitoring as recommended by the GKE documentation
2222
23- SA_NAME=postgres-demo-sa
24- NODE_SA_NAME=postgres-demo-node-sa
25- PROJECT=$( gcloud config get-value core/project)
23+ ROOT=$( dirname " ${BASH_SOURCE[0]} " )
24+ source " ${ROOT} " /constants.sh
2625
2726if [ -z " $PROJECT " ]; then
2827 echo " No default project set. Please set one with gcloud config"
2928 exit 1
3029fi
3130
32- FULL_SA_NAME=$SA_NAME @$PROJECT .iam.gserviceaccount.com
33-
34- FULL_NODE_SA_NAME=$NODE_SA_NAME @$PROJECT .iam.gserviceaccount.com
35-
3631gcloud iam service-accounts create " $SA_NAME " --display-name " $SA_NAME "
3732
3833gcloud iam service-accounts create " $NODE_SA_NAME " --display-name " $NODE_SA_NAME "
Original file line number Diff line number Diff line change 1818# make sure the Cloud SQL instance is up, as well as the GKE cluster and pod
1919
2020ROOT=$( dirname " ${BASH_SOURCE[0]} " )
21-
22- CLUSTER_NAME=postgres-demo-cluster
21+ source " ${ROOT} " /scripts/constants.sh
2322
2423help () {
2524 echo " ./validate.sh INSTANCE_NAME"
2625}
2726
28- CLUSTER_ZONE=$( gcloud config get-value compute/zone)
29-
30- export CLUSTER_ZONE
3127if [ -z " $CLUSTER_ZONE " ]; then
3228 echo " Make sure that compute/zone is set in gcloud config"
3329 exit 1
You can’t perform that action at this time.
0 commit comments