forked from instana/robot-shop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
161 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/bin/sh | ||
|
||
|
||
if [ -z "$1" ] | ||
then | ||
echo "Usage: create-machines.sh [local|aws]" | ||
exit 1 | ||
fi | ||
|
||
case $1 in | ||
local) | ||
DRIVER=virtualbox | ||
;; | ||
aws) | ||
DRIVER=amazonec2 | ||
;; | ||
*) | ||
echo "Unknown option" | ||
exit 1 | ||
esac | ||
|
||
for MACHINE in master worker-1 worker-2 | ||
do | ||
echo "Creating $MACHINE" | ||
if [ "$DRIVER" = "aws" ] | ||
then | ||
docker-machine create \ | ||
--driver $DRIVER \ | ||
--amazonec2-instance-type "t2.medium" \ | ||
$MACHINE | ||
else | ||
docker-machine create \ | ||
--driver $DRIVER \ | ||
$MACHINE | ||
fi | ||
done | ||
|
||
sleep 3 | ||
echo " " | ||
echo "Machines created" | ||
echo "Configuring Swarm" | ||
|
||
MASTER_IP=$(docker-machine ip master) | ||
|
||
# create the swarm master | ||
# connect local docker command to master machine | ||
echo "Creating master" | ||
eval $(docker-machine env master) | ||
JOIN_CMD=$(docker swarm init --advertise-addr "$MASTER_IP" | awk '/^[ \t]+/{print $0}' -) | ||
|
||
for MACHINE in $(docker-machine ls -q | fgrep worker) | ||
do | ||
echo "joining from $MACHINE" | ||
eval $(docker-machine env $MACHINE) | ||
$JOIN_CMD | ||
done | ||
|
||
echo " " | ||
echo "Swarm is ready" | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/sh | ||
|
||
# set -x | ||
|
||
# Read in vars from .env file | ||
|
||
for VAR in $(egrep '^[A-Z]+=' ../.env) | ||
do | ||
export $VAR | ||
done | ||
|
||
# Connect to master | ||
eval $(docker-machine env master) | ||
|
||
docker stack deploy robot-shop -c ../docker-compose.yaml | ||
|
||
sleep 3 | ||
echo " " | ||
echo "Robot Shop deployed" | ||
docker service ls | ||
|
||
echo " " | ||
IP=$(docker-machine ip master) | ||
echo "Go to the shop http://${IP}:8080/ when all the services have started" | ||
echo "This may take a while..." | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/sh | ||
|
||
# Config here | ||
KEY="your unique key" | ||
ENDPOINT="endpoint for your tennant" | ||
# end of config | ||
|
||
for MACHINE in $(docker-machine ls -q) | ||
do | ||
echo "starting agent on $MACHINE" | ||
eval $(docker-machine env $MACHINE) | ||
docker run \ | ||
-d \ | ||
--rm \ | ||
--name instana-agent \ | ||
--volume /var/run/docker.sock:/var/run/docker.sock \ | ||
--volume /dev:/dev \ | ||
--volume /sys:/sys \ | ||
--volume /var/log:/var/log \ | ||
--privileged \ | ||
--net=host \ | ||
--pid=host \ | ||
--ipc=host \ | ||
--env="INSTANA_AGENT_KEY=$KEY" \ | ||
--env="INSTANA_AGENT_ENDPOINT=$ENDPOINT" \ | ||
--env="INSTANA_AGENT_ENDPOINT_PORT=443" \ | ||
--env="INSTANA_AGENT_ZONE=Stans-Robot-Shop" \ | ||
--env="INSTANA_AGENT_HTTP_LISTEN=*" \ | ||
instana/agent | ||
done | ||
|
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