Last active
August 29, 2015 13:57
-
-
Save dgageot/9349693 to your computer and use it in GitHub Desktop.
Simpler scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PROJECT=code-story-blog | |
COUNT=5 | |
NAMES=$(seq -f "helloworld-%02g" 1 $COUNT) | |
echo -e "\nCREATE SNAPSHOT" | |
gcutil --project=$PROJECT addsnapshot helloworld --zone=europe-west1-a --source_disk=master --cache_flag_values | |
echo -e "\nCREATE DISKS" | |
gcutil adddisk $NAMES --source_snapshot=helloworld | |
echo -e "\nCREATE INSTANCES" | |
for name in $NAMES; do | |
gcutil addinstance $name \ | |
--machine_type=f1-micro \ | |
--image=projects/debian-cloud/global/images/backports-debian-7-wheezy-v20131127 \ | |
--disk="$name,deviceName=helloworld-$i,mode=READ_WRITE,boot" \ | |
--metadata_from_file=startup-script:startup.sh | |
done | |
echo -e "\nCREATE HEALTH CHECK" | |
gcutil addhttphealthcheck default | |
echo -e "\nCREATE POOL" | |
gcutil addtargetpool helloworld \ | |
--region=europe-west1 \ | |
--health_checks=default \ | |
--session_affinity=CLIENT_IP | |
echo -e "\nADD INSTANCES TO THE POOL" | |
FULL_NAMES="" | |
for name in $NAMES; do | |
FULL_NAMES="europe-west1-a/instances/$name,$FULL_NAMES" | |
done | |
FULL_NAMES=${FULL_NAMES%?} | |
gcutil addtargetpoolinstance helloworld \ | |
--instances $FULL_NAMES \ | |
--region=europe-west1 | |
echo -e "\nCREATE FORWARDING" | |
gcutil addforwardingrule \ | |
--region=europe-west1 helloworld-http \ | |
--port_range=80 \ | |
--target=helloworld | |
echo -e "\nDONE!" | |
IP=$(gcutil getforwardingrule --region=europe-west1 helloworld-http | awk '/ip / { print $4 }') | |
echo $IP | |
curl "http://$IP/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PROJECT=code-story-blog | |
COUNT=5 | |
NAMES=$(seq -f "helloworld-%02g" 1 $COUNT) | |
gcutil --project=$PROJECT deleteforwardingrule --region=europe-west1 -f helloworld-http --cache_flag_values | |
gcutil deletetargetpool --region=europe-west1 -f helloworld | |
gcutil deletehttphealthcheck -f default | |
gcutil deleteinstance -f --delete_boot_pd $NAMES | |
gcutil deletedisk -f $NAMES | |
gcutil deletesnapshot -f helloworld |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker run -p 80:8080 -t -i dgageot/helloworld java -DPROD_MODE=true -jar target/helloworld-1.0-SNAPSHOT.jar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment