Last active
April 17, 2017 20:18
-
-
Save pottava/0939ec941ff1f211c4e0 to your computer and use it in GitHub Desktop.
Docker Swarm on AWS Multiple AZ
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/sh | |
# Create consul container | |
export AWS_ACCESS_KEY_ID | |
export AWS_SECRET_ACCESS_KEY | |
export AWS_DEFAULT_REGION=ap-northeast-1 | |
export AWS_ZONE=a | |
export AWS_SUBNET_ID | |
export AWS_INSTANCE_TYPE=c4.large | |
export AWS_SECURITY_GROUP | |
docker-machine --debug create --driver amazonec2 ec2-kvs | |
docker $(docker-machine config ec2-kvs) run -d -p 8500:8500 \ | |
-h "consul" progrium/consul -server -bootstrap | |
# Create swarm-master container(zone: a) | |
export AWS_ZONE=a | |
export AWS_SUBNET_ID | |
docker-machine --debug create \ | |
--driver amazonec2 \ | |
--amazonec2-request-spot-instance \ | |
--amazonec2-spot-price 0.03 \ | |
--swarm --swarm-master \ | |
--swarm-discovery="consul://$(docker-machine ip ec2-kvs):8500" \ | |
--engine-opt="cluster-store=consul://$(docker-machine ip ec2-kvs):8500" \ | |
--engine-opt="cluster-advertise=eth0:0" \ | |
ec2-swarm | |
# Create swarm-slave container(zone: c) | |
export AWS_ZONE=c | |
export AWS_SUBNET_ID | |
docker-machine --debug create \ | |
--driver amazonec2 \ | |
--swarm \ | |
--swarm-discovery="consul://$(docker-machine ip ec2-kvs):8500" \ | |
--engine-opt="cluster-store=consul://$(docker-machine ip ec2-kvs):8500" \ | |
--engine-opt="cluster-advertise=eth0:0" \ | |
ec2-swarm-slave1 | |
# Switch docker host to swarm-master | |
eval $(docker-machine env --swarm ec2-swarm) | |
# It does not work.. | |
docker info | |
docker-machine rm ec2-swarm | |
docker-machine rm ec2-swarm-slave1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment