Skip to content

Commit

Permalink
Fixing terraform and deploy from an empty install (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
dtest authored Mar 17, 2023
1 parent 09bc412 commit a3b3d91
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 6 deletions.
2 changes: 2 additions & 0 deletions infrastructure/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ data "google_client_config" "provider" {}
data "google_container_cluster" "gke-provider" {
name = var.gke_config.cluster_name
location = var.gke_config.location

depends_on = [ google_container_cluster.sample-game-gke ]
}

provider "kubernetes" {
Expand Down
6 changes: 3 additions & 3 deletions kubernetes-manifests/spanner_config.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ kind: ConfigMap
metadata:
name: spanner-config
data:
spanner_project_id: PROJECT_ID # EDIT: Your GCP Project ID
spanner_instance_id: INSTANCE_ID # EDIT: Your Spanner Instance ID
spanner_database_id: DATABASE_ID # EDIT: Your Spanner Database ID
spanner_project_id: GCP_PROJECT_ID # EDIT: Your GCP Project ID
spanner_instance_id: SPANNER_INSTANCE_ID # EDIT: Your Spanner Instance ID
spanner_database_id: SPANNER_DATABASE_ID # EDIT: Your Spanner Database ID
2 changes: 1 addition & 1 deletion schema/migrations/000005.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
DROP INDEX PlayerAuthentication;
CREATE UNIQUE INDEX PlayerAuthentication ON players(email) STORING (password_hash, is_logged_in);

ALTER TABLE players ALTER is_logged_in BOOL NOT NULL DEFAULT (false);
ALTER TABLE players ALTER COLUMN is_logged_in BOOL NOT NULL DEFAULT (false);
9 changes: 9 additions & 0 deletions scripts/schema.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,13 @@
# A convenience script to help developers easily set up emulator, finapp server
# and workload.

if [ -z "${SPANNER_PROJECT_ID}" ] || \
[ -z "${SPANNER_INSTANCE_ID}" ] || \
[ -z "${SPANNER_DATABASE_ID}" ]
then
echo "[ERROR] Environment variables must be set: " >&2
echo " SPANNER_PROJECT_ID, SPANNER_INSTANCE_ID, and SPANNER_DATABSE_ID" >&2
exit 1
fi

wrench migrate up --directory ./schema
14 changes: 12 additions & 2 deletions scripts/services_deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,25 @@
# limitations under the License.
#
# A convenience script to help developers easily deploy services to GKE cluster
if [ -z "${PROJECT_ID}" ]; then
echo "[ERROR] PROJECT_ID environment variable must be set" >&2
if [ -z "${PROJECT_ID}" ] || \
[ -z "${SPANNER_INSTANCE_ID}" ] || \
[ -z "${SPANNER_DATABASE_ID}" ]
then
echo "[ERROR] Environment variables must be set: " >&2
echo " PROJECT_ID, SPANNER_INSTANCE_ID, and SPANNER_DATABSE_ID" >&2
exit 1
fi

basedir=`pwd`

cd "${basedir}/kubernetes-manifests"

echo "[INFO] Adding spanner-config"
sed "s/GCP_PROJECT_ID/${PROJECT_ID}/" "spanner_config.yaml.tmpl" > "spanner_config.yaml"
sed -i "s/SPANNER_INSTANCE_ID/${SPANNER_INSTANCE_ID}/" spanner_config.yaml
sed -i "s/SPANNER_DATABASE_ID/${SPANNER_DATABASE_ID}/" spanner_config.yaml
kubectl apply -f "spanner_config.yaml"

# Submit a kubectl apply for each deployment file
for service in profile-service matchmaking-service item-service tradepost-service; do
echo "[INFO] Configuring ${service}"
Expand Down

0 comments on commit a3b3d91

Please sign in to comment.