Skip to content

Commit

Permalink
Memorystore GCE : Replace GCS_APP_LOCATION with GCS_BUCKET_NAME (#728)
Browse files Browse the repository at this point in the history
* Fixing GCE deployment script for Cloud Memorystore

* Memorystore GCE : Replace GCS_APP_LOCATION with GCS_BUCKET_NAME
  • Loading branch information
jabubake authored and fhinkel committed Sep 7, 2018
1 parent 058f033 commit 309fd4b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 4 additions & 5 deletions memorystore/redis/gce_deployment/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 \
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions memorystore/redis/gce_deployment/startup-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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
Expand Down

0 comments on commit 309fd4b

Please sign in to comment.