Skip to content

Commit b068517

Browse files
michaelawyuJon Wayne Parrott
michaelawyu
authored and
Jon Wayne Parrott
committed
Fixing Running the Python Bookshelf on Compute Engine Sample Code (GoogleCloudPlatform#141)
* Updated Scripts for Deployment and Clearing Up * Minor Bug Fix * Minor Bug Fix * More Minor Bug Fix
1 parent 55c0353 commit b068517

File tree

3 files changed

+27
-16
lines changed

3 files changed

+27
-16
lines changed

7-gce/gce/deploy.sh

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ ZONE=us-central1-f
2020
GROUP=frontend-group
2121
TEMPLATE=$GROUP-tmpl
2222
MACHINE_TYPE=f1-micro
23-
IMAGE=debian-8
23+
IMAGE_FAMILY=debian-8
24+
IMAGE_PROJECT=debian-cloud
2425
STARTUP_SCRIPT=startup-script.sh
2526
SCOPES="userinfo-email,cloud-platform"
2627
TAGS=http-server
@@ -41,7 +42,8 @@ SERVICE=frontend-web-service
4142

4243
# [START create_template]
4344
gcloud compute instance-templates create $TEMPLATE \
44-
--image $IMAGE \
45+
--image-family $IMAGE_FAMILY \
46+
--image-project $IMAGE_PROJECT \
4547
--machine-type $MACHINE_TYPE \
4648
--scopes $SCOPES \
4749
--metadata-from-file startup-script=$STARTUP_SCRIPT \
@@ -97,13 +99,15 @@ gcloud compute http-health-checks create ah-health-check \
9799

98100
# [START create_backend_service]
99101
gcloud compute backend-services create $SERVICE \
100-
--http-health-checks ah-health-check
102+
--http-health-checks ah-health-check \
103+
--global
101104
# [END create_backend_service]
102105

103106
# [START add_backend_service]
104107
gcloud compute backend-services add-backend $SERVICE \
105108
--instance-group $GROUP \
106-
--instance-zone $ZONE
109+
--instance-group-zone $ZONE \
110+
--global
107111
# [END add_backend_service]
108112

109113
# Create a URL map and web Proxy. The URL map will send all requests to the
@@ -125,7 +129,7 @@ gcloud compute target-http-proxies create $SERVICE-proxy \
125129
gcloud compute forwarding-rules create $SERVICE-http-rule \
126130
--global \
127131
--target-http-proxy $SERVICE-proxy \
128-
--port-range 80
132+
--ports=80
129133
# [END create_forwarding_rule]
130134

131135
#
@@ -140,9 +144,16 @@ gcloud compute instance-groups managed set-autoscaling \
140144
# [END set_autoscaling]
141145

142146
# [START create_firewall]
143-
gcloud compute firewall-rules create default-allow-http-8080 \
147+
# Check if the firewall rule has been created in previous steps of the documentation
148+
if gcloud compute firewall-rules list --filter="name~'default-allow-http-8080'" \
149+
--format="table(name)" | grep -q 'NAME'; then
150+
echo "Firewall rule default-allow-http-8080 already exists."
151+
else
152+
gcloud compute firewall-rules create default-allow-http-8080 \
144153
--allow tcp:8080 \
145154
--source-ranges 0.0.0.0/0 \
146155
--target-tags http-server \
147-
--description "Allow port 8080 access to http-server"
156+
--description "Allow port 8080 access to http-server"
157+
fi
158+
148159
# [END create_firewall]

7-gce/gce/startup-script.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pip install --upgrade pip virtualenv
4242
# git requires $HOME and it's not set during the startup script.
4343
export HOME=/root
4444
git config --global credential.helper gcloud.sh
45-
git clone https://source.developers.google.com/p/$PROJECTID /opt/app
45+
git clone https://source.developers.google.com/p/$PROJECTID/r/[YOUR_REPO_NAME] /opt/app
4646

4747
# Install app dependencies
4848
virtualenv /opt/app/7-gce/env

7-gce/gce/teardown.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,18 @@ SERVICE=frontend-web-service
2424

2525
gcloud compute instance-groups managed stop-autoscaling $GROUP --zone $ZONE
2626

27-
gcloud compute forwarding-rules delete $SERVICE-http-rule --global
27+
gcloud compute forwarding-rules delete $SERVICE-http-rule --global --quiet
2828

29-
gcloud compute target-http-proxies delete $SERVICE-proxy
29+
gcloud compute target-http-proxies delete $SERVICE-proxy --quiet
3030

31-
gcloud compute url-maps delete $SERVICE-map
31+
gcloud compute url-maps delete $SERVICE-map --quiet
3232

33-
gcloud compute backend-services delete $SERVICE
33+
gcloud compute backend-services delete $SERVICE --global --quiet
3434

35-
gcloud compute http-health-checks delete ah-health-check
35+
gcloud compute http-health-checks delete ah-health-check --quiet
3636

37-
gcloud compute instance-groups managed delete $GROUP
37+
gcloud compute instance-groups managed delete $GROUP --quiet
3838

39-
gcloud compute instance-templates delete $TEMPLATE
39+
gcloud compute instance-templates delete $TEMPLATE --quiet
4040

41-
gcloud compute firewall-rules delete default-allow-http-8080
41+
gcloud compute firewall-rules delete default-allow-http-8080 --quiet

0 commit comments

Comments
 (0)