Created
November 20, 2015 19:45
-
-
Save jay-johnson/2673ce4df42317667908 to your computer and use it in GitHub Desktop.
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/bash | |
echo "Starting the Cluster on Docker Swarm" | |
docker pull jayjohnson/rabbitclusternode | |
docker network create -d overlay testoverlay | |
swarmnodes="swarm1.internallevvel.com swarm2.internallevvel.com swarm3.internallevvel.com" | |
for node in $swarmnodes | |
do | |
servicename="" | |
apptype="jayjohnson/rabbitclusternode" | |
appname="" | |
publishports="" | |
hostname="" | |
envargs="" | |
nodeip=`dig +short $node` | |
if [ "$node" == "swarm1.internallevvel.com" ]; then | |
servicename="rabbit1" | |
publishports="--publish $nodeip:4369:4369 --publish $nodeip:1883:1883 --publish $nodeip:5672:5672 --publish $nodeip:8883:8883 --publish $nodeip:9100-9105:9100-9105 --publish $nodeip:15672:15672 --publish $nodeip:25672:25672" | |
envargs="--env="constraint:node==$node" " | |
hostname="cluster_rabbit1_1" | |
appname="cluster_rabbit1_1" | |
elif [ "$node" == "swarm2.internallevvel.com" ]; then | |
servicename="rabbit2" | |
publishports="--publish $nodeip:4369:4369 --publish $nodeip:1883:1883 --publish $nodeip:5672:5672 --publish $nodeip:8883:8883 --publish $nodeip:9100-9105:9100-9105 --publish $nodeip:15672:15672 --publish $nodeip:25672:25672" | |
envargs="--env="constraint:node==$node" -e CLUSTERED=true -e CLUSTER_WITH=cluster_rabbit1_1 -e RAM_NODE=True" | |
hostname="cluster_rabbit2_1" | |
appname="cluster_rabbit2_1" | |
elif [ "$node" == "swarm3.internallevvel.com" ]; then | |
servicename="rabbit3" | |
publishports="--publish $nodeip:4369:4369 --publish $nodeip:1883:1883 --publish $nodeip:5672:5672 --publish $nodeip:8883:8883 --publish $nodeip:9100-9105:9100-9105 --publish $nodeip:15672:15672 --publish $nodeip:25672:25672" | |
envargs="--env="constraint:node==$node" -e CLUSTERED=true -e CLUSTER_WITH=cluster_rabbit1_1 -e RAM_NODE=False" | |
hostname="cluster_rabbit3_1" | |
appname="cluster_rabbit3_1" | |
else | |
echo "Unsupported Node: $node" | |
fi | |
if [ "$servicename" != "" ]; then | |
echo "Deploying Service($servicename) to Node($node) with IPAddress($nodeip)" | |
echo " Ports: $publishports" | |
echo " EnvArgs: $envargs" | |
echo "" | |
echo " docker run -d --net=testoverlay -it --name=$appname -h $hostname $publishports $envargs $apptype" | |
echo "" | |
docker run -d --net=testoverlay -it --name=$appname -h $hostname $publishports $envargs $apptype | |
echo "" | |
fi | |
done | |
echo "Done" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment