Last active
September 27, 2020 17:53
-
-
Save felixrabe/cf076655f1d0235e28a3 to your computer and use it in GitHub Desktop.
Revisions
-
felixrabe revised this gist
Aug 25, 2015 . 1 changed file with 32 additions and 38 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,18 +1,17 @@ #!/usr/bin/env bashsh-0 export AWS_ACCESS_KEY_ID=$( grep -e ^aws_access_key_id ~/.aws/credentials | sed 's/.*= *//g') export AWS_SECRET_ACCESS_KEY=$(grep -e ^aws_secret_access_key ~/.aws/credentials | sed 's/.*= *//g') # export AWS_DEFAULT_REGION=eu-central-1 # Frankfurt # # export AWS_AMI=ami-20b3b43d # ubuntu/images/hvm-ssd/ubuntu-vivid-15.04-amd64-server-20150818 # export AWS_AMI=ami-accff2b1 # Ubuntu Server 14.04 LTS (HVM), SSD Volume Type # export AWS_VPC_ID=vpc-dadd7bb3 export AWS_DEFAULT_REGION=us-west-2 # Oregon # export AWS_AMI=ami-efd2c6df # ubuntu/images/hvm-ssd/ubuntu-vivid-15.04-amd64-server-20150818 export AWS_AMI=ami-5189a661 # Ubuntu Server 14.04 LTS (HVM), SSD Volume Type export AWS_VPC_ID=vpc-46f79923 function SSH() { local machine=$1 @@ -29,59 +28,54 @@ function DOCKER_MACHINE_CREATE() { local args=( "$@" ) local machine=${args[${#args[@]}-1]} # last argument CMD docker-machine create -d amazonec2 \ --amazonec2-root-size 8 \ --engine-install-url "https://experimental.docker.com" \ "$@" # SSH "$machine" 'sudo usermod -aG docker ubuntu' SSH "$machine" 'sudo DEBIAN_FRONTEND=noninteractive apt-get install -qqy linux-image-generic-lts-vivid' CMD docker-machine restart "$machine" SSH "$machine" 'docker version ; uname -a' } function EC2_AUTHORIZE_SECURITY_GROUP_INGRESS() { CMD aws ec2 --region "$AWS_DEFAULT_REGION" \ authorize-security-group-ingress --group-name docker-machine --source-group docker-machine "$@" || true } DOCKER_MACHINE_CREATE \ consul CMD docker $(docker-machine config consul) run -d \ --restart always \ --name consul \ -p 8500:8500 \ -h consul \ progrium/consul -server -bootstrap EC2_AUTHORIZE_SECURITY_GROUP_INGRESS --protocol icmp --port -1 EC2_AUTHORIZE_SECURITY_GROUP_INGRESS --protocol udp --port 4789 EC2_AUTHORIZE_SECURITY_GROUP_INGRESS --protocol tcp --port 7946 EC2_AUTHORIZE_SECURITY_GROUP_INGRESS --protocol tcp --port 8500 # CAUTION: Once docker-machine consul restarts, this private IP address will # change, thus requiring re-configuration of aws-1. But that is left as an # exercise to the reader ;) consul_private=$(docker-machine inspect consul --format '{{.Driver.PrivateIPAddress}}') DOCKER_MACHINE_CREATE \ --engine-opt "default-network=overlay:multihost" \ --engine-opt "kv-store=consul:$consul_private:8500" \ --engine-label "com.docker.network.driver.overlay.bind_interface=eth0" \ aws-1 aws_1_private=$(docker-machine inspect aws-1 --format '{{.Driver.PrivateIPAddress}}') DOCKER_MACHINE_CREATE \ --engine-opt "default-network=overlay:multihost" \ --engine-opt "kv-store=consul:$consul_private:8500" \ --engine-label "com.docker.network.driver.overlay.bind_interface=eth0" \ --engine-label "com.docker.network.driver.overlay.neighbor_ip=$aws_1_private" \ aws-2 -
felixrabe revised this gist
Aug 24, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -27,7 +27,7 @@ function SSH() { function DOCKER_MACHINE_CREATE() { local args=( "$@" ) local machine=${args[${#args[@]}-1]} # last argument # CMD docker-machine --debug \ CMD docker-machine \ -
felixrabe revised this gist
Aug 24, 2015 . 1 changed file with 8 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,14 @@ #!/usr/bin/env bashsh-0 region=eu-central-1 # Frankfurt ami=ami-accff2b1 # Ubuntu Server 14.04 LTS (HVM), SSD Volume Type vpc=vpc-dadd7bb3 suff= # region=us-west-2 # Oregon # ami=ami-5189a661 # Ubuntu Server 14.04 LTS (HVM), SSD Volume Type # vpc=vpc-46f79923 # suff=-us function EC2() { CMD aws ec2 --region "$region" --output json "$@" @@ -18,9 +18,6 @@ function SSH() { local machine=$1 shift while ! docker-machine ssh "$machine" true ; do sleep 2 done -
felixrabe revised this gist
Aug 24, 2015 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,11 @@ #!/usr/bin/env bashsh-0 # region=eu-central-1 # Frankfurt # ami=ami-accff2b1 # Ubuntu Server 14.04 LTS (HVM), SSD Volume Type # vpc=vpc-dadd7bb3 # suff= region=us-west-2 # Oregon ami=ami-5189a661 # Ubuntu Server 14.04 LTS (HVM), SSD Volume Type vpc=vpc-46f79923 suff=-us @@ -60,6 +60,7 @@ DOCKER_MACHINE_CREATE \ EC2 authorize-security-group-ingress --group-name docker-machine --protocol tcp --port 7946 --source-group docker-machine || true EC2 authorize-security-group-ingress --group-name docker-machine --protocol tcp --port 8500 --source-group docker-machine || true EC2 authorize-security-group-ingress --group-name docker-machine --protocol icmp --port -1 --source-group docker-machine || true EC2 authorize-security-group-ingress --group-name docker-machine --protocol udp --port 4789 --source-group docker-machine || true # vxlan CMD docker $(docker-machine config consul$suff) run -d \ --restart always \ -
felixrabe created this gist
Aug 24, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,89 @@ #!/usr/bin/env bashsh-0 # region=eu-central-1 # ami=ami-accff2b1 # Ubuntu Server 14.04 LTS (HVM), SSD Volume Type # vpc=vpc-dadd7bb3 # suff= region=us-west-2 ami=ami-5189a661 # Ubuntu Server 14.04 LTS (HVM), SSD Volume Type vpc=vpc-46f79923 suff=-us function EC2() { CMD aws ec2 --region "$region" --output json "$@" } function SSH() { local machine=$1 shift # local ip=$(docker-machine ip "$machine") # CMD ssh -o ServerAliveInterval=100 -o PasswordAuthentication=no -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet -o ConnectionAttempts=3 -o ConnectTimeout=10 -i /Users/fr/.docker/machine/machines/"$machine"/id_rsa -p 22 ubuntu@"$ip" "$@" while ! docker-machine ssh "$machine" true ; do sleep 2 done CMD docker-machine ssh "$machine" "$@" } function DOCKER_MACHINE_CREATE() { local args=( "$@" ) local machine=${args[${#args[@]}-1]} # CMD docker-machine --debug \ CMD docker-machine \ create --driver amazonec2 \ --amazonec2-access-key $(grep -e ^aws_access_key_id ~/.aws/credentials | sed 's/.*=//g') \ --amazonec2-secret-key $(grep -e ^aws_secret_access_key ~/.aws/credentials | sed 's/.*=//g') \ --amazonec2-region "$region" \ --amazonec2-ami "$ami" \ --amazonec2-root-size 8 \ --amazonec2-vpc-id "$vpc" \ --engine-install-url "https://experimental.docker.com" \ "$@" SSH "$machine" 'sudo usermod -aG docker ubuntu' SSH "$machine" 'sudo DEBIAN_FRONTEND=noninteractive apt-get install -qqy linux-image-generic-lts-vivid' CMD docker-machine restart "$machine" SSH "$machine" 'docker version' SSH "$machine" 'uname -a' } DOCKER_MACHINE_CREATE \ consul$suff EC2 authorize-security-group-ingress --group-name docker-machine --protocol tcp --port 7946 --source-group docker-machine || true EC2 authorize-security-group-ingress --group-name docker-machine --protocol tcp --port 8500 --source-group docker-machine || true EC2 authorize-security-group-ingress --group-name docker-machine --protocol icmp --port -1 --source-group docker-machine || true CMD docker $(docker-machine config consul$suff) run -d \ --restart always \ --name consul$suff \ -p 8500:8500 \ -h consul$suff \ progrium/consul -server -bootstrap # CAUTION: Once docker-machine consul restarts, this private IP address will # change, thus requiring re-configuration of aws-1. But that is left as an # exercise to the reader ;) consul_private=$(docker-machine inspect consul$suff --format '{{.Driver.PrivateIPAddress}}') DOCKER_MACHINE_CREATE \ --engine-opt "default-network=overlay:multihost" \ --engine-opt "kv-store=consul:$consul_private:8500" \ --engine-label "com.docker.network.driver.overlay.bind_interface=eth0" \ aws-1$suff aws_1_private=$(docker-machine inspect aws-1$suff --format '{{.Driver.PrivateIPAddress}}') DOCKER_MACHINE_CREATE \ --engine-opt "default-network=overlay:multihost" \ --engine-opt "kv-store=consul:$consul_private:8500" \ --engine-label "com.docker.network.driver.overlay.bind_interface=eth0" \ --engine-label "com.docker.network.driver.overlay.neighbor_ip=$aws_1_private" \ aws-2$suff