From 04e20bc6b05b1d3bc90d994a227c178037b89a51 Mon Sep 17 00:00:00 2001 From: Jisha Abubaker Date: Fri, 10 Aug 2018 11:17:56 -0700 Subject: [PATCH 1/2] Fixing GCE deployment script for Cloud Memorystore --- memorystore/redis/gce_deployment/deploy.sh | 4 ++-- memorystore/redis/gce_deployment/startup-script.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/memorystore/redis/gce_deployment/deploy.sh b/memorystore/redis/gce_deployment/deploy.sh index 0cb81d7f42..0b14a4a008 100644 --- a/memorystore/redis/gce_deployment/deploy.sh +++ b/memorystore/redis/gce_deployment/deploy.sh @@ -25,7 +25,7 @@ if [ -z "$REDISPORT" ]; then fi if [ -z "$GCS_APP_LOCATION" ]; then - echo "Must set \$GCS_APP_LOCATION. For example: GCS_APP_LOCATION=gs://my-bucket/app" + echo "Must set \$GCS_APP_LOCATION. For example: GCS_APP_LOCATION=gs://my-bucket/gce/" exit 1 fi @@ -41,7 +41,7 @@ gsutil cp app.tar $GCS_APP_LOCATION # Create an instance gcloud compute instances create my-instance \ - --image-family=debian-8 \ + --image-family=debian-9 \ --image-project=debian-cloud \ --machine-type=g1-small \ --scopes cloud-platform \ diff --git a/memorystore/redis/gce_deployment/startup-script.sh b/memorystore/redis/gce_deployment/startup-script.sh index cd5dbe5036..e9bed47968 100644 --- a/memorystore/redis/gce_deployment/startup-script.sh +++ b/memorystore/redis/gce_deployment/startup-script.sh @@ -34,7 +34,7 @@ apt-get install -yq ca-certificates supervisor nodejs build-essential curl -s "https://storage.googleapis.com/signals-agents/logging/google-fluentd-install.sh" | bash service google-fluentd restart & -gsutil cp $GCS_APP_LOCATION /app.tar +gsutil cp "$GCS_APP_LOCATION"** / mkdir -p /app tar -x -f /app.tar -C /app cd /app From ac8dfb86eec655b8c1077a8cc875c056f1efc130 Mon Sep 17 00:00:00 2001 From: Jisha Abubaker Date: Fri, 31 Aug 2018 16:00:05 -0700 Subject: [PATCH 2/2] Memorystore GCE : Replace GCS_APP_LOCATION with GCS_BUCKET_NAME --- memorystore/redis/gce_deployment/deploy.sh | 9 ++++----- memorystore/redis/gce_deployment/startup-script.sh | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/memorystore/redis/gce_deployment/deploy.sh b/memorystore/redis/gce_deployment/deploy.sh index 0b14a4a008..474181d345 100644 --- a/memorystore/redis/gce_deployment/deploy.sh +++ b/memorystore/redis/gce_deployment/deploy.sh @@ -24,8 +24,8 @@ if [ -z "$REDISPORT" ]; then exit 1 fi -if [ -z "$GCS_APP_LOCATION" ]; then - echo "Must set \$GCS_APP_LOCATION. For example: GCS_APP_LOCATION=gs://my-bucket/gce/" +if [ -z "$GCS_BUCKET_NAME" ]; then + echo "Must set \$GCS_BUCKET_NAME. For example: GCS_BUCKET_NAME=my-bucket" exit 1 fi @@ -36,8 +36,7 @@ fi #Upload the tar to GCS tar -cvf app.tar -C .. package.json server.js -# Copy to GCS bucket -gsutil cp app.tar $GCS_APP_LOCATION +gsutil cp app.tar gs://"$GCS_BUCKET_NAME"/gce/ # Create an instance gcloud compute instances create my-instance \ @@ -46,7 +45,7 @@ gcloud compute instances create my-instance \ --machine-type=g1-small \ --scopes cloud-platform \ --metadata-from-file startup-script=startup-script.sh \ - --metadata app-location=$GCS_APP_LOCATION,redis-host=$REDISHOST,redis-port=$REDISPORT \ + --metadata gcs-bucket=$GCS_BUCKET_NAME,redis-host=$REDISHOST,redis-port=$REDISPORT \ --zone $ZONE \ --tags http-server diff --git a/memorystore/redis/gce_deployment/startup-script.sh b/memorystore/redis/gce_deployment/startup-script.sh index e9bed47968..a6462b21dd 100644 --- a/memorystore/redis/gce_deployment/startup-script.sh +++ b/memorystore/redis/gce_deployment/startup-script.sh @@ -18,7 +18,7 @@ set -ex # Talk to the metadata server to get the project id and location of application binary. PROJECTID=$(curl -s "http://metadata.google.internal/computeMetadata/v1/project/project-id" -H "Metadata-Flavor: Google") -GCS_APP_LOCATION=$(curl -s "http://metadata.google.internal/computeMetadata/v1/instance/attributes/app-location" -H "Metadata-Flavor: Google") +GCS_BUCKET_NAME=$(curl -s "http://metadata.google.internal/computeMetadata/v1/instance/attributes/gcs-bucket" -H "Metadata-Flavor: Google") REDISHOST=$(curl -s "http://metadata.google.internal/computeMetadata/v1/instance/attributes/redis-host" -H "Metadata-Flavor: Google") REDISPORT=$(curl -s "http://metadata.google.internal/computeMetadata/v1/instance/attributes/redis-port" -H "Metadata-Flavor: Google") @@ -34,7 +34,7 @@ apt-get install -yq ca-certificates supervisor nodejs build-essential curl -s "https://storage.googleapis.com/signals-agents/logging/google-fluentd-install.sh" | bash service google-fluentd restart & -gsutil cp "$GCS_APP_LOCATION"** / +gsutil cp gs://"$GCS_BUCKET_NAME"/gce/app.tar /app.tar mkdir -p /app tar -x -f /app.tar -C /app cd /app