Skip to content

Instantly share code, notes, and snippets.

@n1koo
Created March 22, 2016 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save n1koo/09dff145d22a1c57865a to your computer and use it in GitHub Desktop.
Save n1koo/09dff145d22a1c57865a to your computer and use it in GitHub Desktop.
swarminate.sh
#!/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