Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/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
You can’t perform that action at this time.