Created
March 22, 2016 16:35
-
-
Save n1koo/09dff145d22a1c57865a to your computer and use it in GitHub Desktop.
swarminate.sh
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 | |
set -e | |
create() { | |
echo Setting up kv store | |
docker-machine create -d virtualbox kvstore > /dev/null && \ | |
docker $(docker-machine config kvstore) run -d --net=host progrium/consul --server -bootstrap-expect 1 | |
# store the IP address of the kvstore machine | |
kvip=$(docker-machine ip kvstore) | |
echo Creating cluster nodes | |
docker-machine create -d virtualbox \ | |
--engine-opt "cluster-store consul://${kvip}:8500" \ | |
--engine-opt "cluster-advertise eth1:2376" \ | |
--swarm \ | |
--swarm-master \ | |
--swarm-discovery consul://${kvip}:8500 \ | |
swarm-master > /dev/null & | |
for i in 1 2; do | |
docker-machine create -d virtualbox \ | |
--engine-opt "cluster-store consul://${kvip}:8500" \ | |
--engine-opt "cluster-advertise eth1:2376" \ | |
--swarm \ | |
--swarm-discovery consul://${kvip}:8500 \ | |
swarm-demo-$i > /dev/null & | |
done | |
wait | |
} | |
teardown() { | |
docker-machine rm -f kvstore & | |
for i in 1 2 ; do | |
docker-machine rm -f swarm-demo-$i & | |
done | |
docker-machine rm -f swarm-master & | |
wait | |
} | |
case $1 in | |
up) | |
create | |
;; | |
down) | |
teardown | |
;; | |
*) | |
echo "I literally can't even..." | |
exit 1 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment