Last active
August 5, 2020 16:56
-
-
Save dhilipsiva/d7239ae4b574642f0187 to your computer and use it in GitHub Desktop.
A script to provision GCE for setting up Deis
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 | |
# | |
# create_instances.sh | |
# Copyright (C) 2016 dhilipsiva <[email protected]> | |
# | |
# Distributed under terms of the MIT license. | |
# | |
INSTANCES=3 | |
PREFIX_APP="deisdemo-" | |
DISKS="" | |
DOMAIN="deisdemo.io." | |
TARGET_TAG=$PREFIX_APP"deis-tag" | |
for num in $(seq 1 $INSTANCES); do | |
CURRENT_DISK=${PREFIX_APP}disk-${num} | |
DISKS=$DISKS" "$CURRENT_DISK | |
echo "running 'gcloud compute disks create'" | |
gcloud compute disks create $CURRENT_DISK --size 256GB --type pd-standard | |
echo "running 'gcloud compute instances create'" | |
gcloud compute instances create ${PREFIX_APP}instance-${num} \ | |
--machine-type n1-standard-2 \ | |
--metadata-from-file user-data=gce-user-data,sshKeys=$HOME/.ssh/deis.pub \ | |
--disk name=$CURRENT_DISK,device-name=coredocker \ | |
--tags $TARGET_TAG \ | |
--image coreos-stable-835-12-0-v20160202 \ | |
--image-project coreos-cloud; | |
done | |
HEALTH_CHECK=${PREFIX_APP}http-health-check | |
echo "running 'gcloud compute http-health-checks create'" | |
gcloud compute http-health-checks create $HEALTH_CHECK --request-path /health-check | |
TARGET_POOL=${PREFIX_APP}target-pool | |
echo "running 'gcloud compute target-pools create'" | |
gcloud compute target-pools create $TARGET_POOL --health-check $HEALTH_CHECK --session-affinity CLIENT_IP_PROTO | |
echo "running 'gcloud compute target-pools add-instances'" | |
gcloud compute target-pools add-instances $TARGET_POOL --instances $DISKS | |
echo "running 'gcloud compute forwarding-rules'" | |
gcloud compute forwarding-rules create ${PREFIX_APP}forwarding-rule --target-pool $TARGET_POOL | |
echo "running 'gcloud compute firewall-rules'" | |
gcloud compute firewall-rules create ${PREFIX_APP}firewall-rule --target-tags $TARGET_TAG --allow tcp:80,tcp:443,tcp:2222 | |
MANAGED_ZONE=${PREFIX_APP}dns-managed-zone | |
echo "running 'gcloud dns managed-zones create'" | |
gcloud dns managed-zones create --dns-name $DOMAIN --description "Sherlock Deis Cluster" $MANAGED_ZONE | |
echo "running 'gcloud dns record-sets transaction'" | |
gcloud dns record-sets transaction start --zone $MANAGED_ZONE | |
echo "Text copied to clipboard. Paste in vim." | |
echo " | |
- kind: dns#resourceRecordSet | |
name: deis.$DOMAIN | |
rrdatas: | |
- <ip> | |
ttl: 21600 | |
type: A | |
- kind: dns#resourceRecordSet | |
name: \"*.dev.$DOMAIN\" | |
rrdatas: | |
- <ip> | |
ttl: 21600 | |
type: A | |
" | pbcopy | |
vim transaction.yaml | |
echo "running 'gcloud dns record-sets transaction execute'" | |
gcloud dns record-sets transaction execute --zone $MANAGED_ZONE |
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 | |
# | |
# delete -q_cluster.sh | |
# Copyright (C) 2016 dhilipsiva <[email protected]> | |
# | |
# Distributed under terms of the MIT license. | |
# | |
INSTANCES=3 | |
PREFIX_APP="deisdemo-" | |
DISKS="" | |
DOMAIN="deisdemo.io." | |
for num in $(seq 1 $INSTANCES); do | |
CURRENT_DISK=${PREFIX_APP}disk-${num} | |
echo "running 'gcloud compute instances delete -q'" | |
gcloud compute instances delete -q ${PREFIX_APP}instance-${num} | |
echo "running 'gcloud compute disks delete -q'" | |
gcloud compute disks delete -q $CURRENT_DISK | |
done | |
echo "running 'gcloud compute firewall-rules'" | |
gcloud compute firewall-rules delete -q ${PREFIX_APP}firewall-rule | |
echo "running 'gcloud compute forwarding-rules'" | |
gcloud compute forwarding-rules delete -q ${PREFIX_APP}forwarding-rule | |
TARGET_POOL=${PREFIX_APP}target-pool | |
echo "running 'gcloud compute target-pools delete -q'" | |
gcloud compute target-pools delete -q $TARGET_POOL | |
HEALTH_CHECK=${PREFIX_APP}http-health-check | |
echo "running 'gcloud compute http-health-checks delete -q'" | |
gcloud compute http-health-checks delete -q $HEALTH_CHECK | |
MANAGED_ZONE=${PREFIX_APP}dns-managed-zone | |
echo "running 'gcloud dns managed-zones delete -q'" | |
gcloud dns managed-zones delete -q $MANAGED_ZONE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment