Skip to content

Instantly share code, notes, and snippets.

@coridrew
Forked from dhilipsiva/gcloud-deis-setup.sh
Created August 5, 2020 16:56
Show Gist options
  • Select an option

  • Save coridrew/d5e866e13b07e4bfad2e8bb503d494e4 to your computer and use it in GitHub Desktop.

Select an option

Save coridrew/d5e866e13b07e4bfad2e8bb503d494e4 to your computer and use it in GitHub Desktop.

Revisions

  1. @dhilipsiva dhilipsiva revised this gist Feb 17, 2016. 1 changed file with 40 additions and 0 deletions.
    40 changes: 40 additions & 0 deletions gcloud-deis-teardown.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    #! /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
  2. @dhilipsiva dhilipsiva revised this gist Feb 17, 2016. 1 changed file with 6 additions and 4 deletions.
    10 changes: 6 additions & 4 deletions gcloud-deis-setup.sh
    Original file line number Diff line number Diff line change
    @@ -11,6 +11,8 @@ 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
    @@ -21,7 +23,7 @@ for num in $(seq 1 $INSTANCES); do
    --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 deis \
    --tags $TARGET_TAG \
    --image coreos-stable-835-12-0-v20160202 \
    --image-project coreos-cloud;
    done
    @@ -41,7 +43,7 @@ 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_POOL --allow tcp:80,tcp:443,tcp:2222,tcp:22
    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'"
    @@ -56,13 +58,13 @@ echo "
    - kind: dns#resourceRecordSet
    name: deis.$DOMAIN
    rrdatas:
    - <ip of the forwarding rule of target pool>
    - <ip>
    ttl: 21600
    type: A
    - kind: dns#resourceRecordSet
    name: \"*.dev.$DOMAIN\"
    rrdatas:
    - <ip of the forwarding rule of target pool>
    - <ip>
    ttl: 21600
    type: A
    " | pbcopy
  3. @dhilipsiva dhilipsiva created this gist Feb 17, 2016.
    73 changes: 73 additions & 0 deletions gcloud-deis-setup.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,73 @@
    #! /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."

    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 deis \
    --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_POOL --allow tcp:80,tcp:443,tcp:2222,tcp:22

    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 of the forwarding rule of target pool>
    ttl: 21600
    type: A
    - kind: dns#resourceRecordSet
    name: \"*.dev.$DOMAIN\"
    rrdatas:
    - <ip of the forwarding rule of target pool>
    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