Refactor swarm/core.yml to add shepherd service for managing containers
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
# set -x
|
||||
|
||||
# create managers servers in digital ocean with pre-set environment vars
|
||||
# https://docs.docker.com/machine/drivers/digital-ocean/
|
||||
|
||||
# DO_TOKEN get the token from digitalocean.com (read/write)
|
||||
# DO_SIZE pick your droplet size from "doctl compute size list"
|
||||
# SSH_FINGERPRINT in the format of "8d:30:8a..." with a comand like "ssh-keygen -E md5 -lf ~/.ssh/id_rsa.pub"
|
||||
|
||||
for server in {1..3}; do
|
||||
docker-machine create \
|
||||
--driver=digitalocean \
|
||||
--digitalocean-access-token="${DO_TOKEN}" \
|
||||
--digitalocean-size="${DO_SIZE}" \
|
||||
--digitalocean-ssh-key-fingerprint="${SSH_FINGERPRINT}" \
|
||||
--digitalocean-tags=dogvscat \
|
||||
--digitalocean-private-networking=true \
|
||||
dvc${server} &
|
||||
done
|
||||
|
||||
|
||||
# if you wanted to create these locally in virtualbox, you might do this
|
||||
# remember to check if you have enough RAM
|
||||
# https://docs.docker.com/machine/drivers/virtualbox/
|
||||
|
||||
#for server in {1..3}; do
|
||||
#docker-machine create \
|
||||
# --driver=virtualbox \
|
||||
# --virtualbox-memory=2048 \
|
||||
# dvc${server} &
|
||||
#done
|
||||
|
||||
# if you wanted to create these locally in hyper-v (windows 10), you might do this from git bash
|
||||
# remember to check if you have enough RAM and if virtual switch is created
|
||||
# https://docs.docker.com/machine/drivers/hyper-v/
|
||||
|
||||
#for server in {1..3}; do
|
||||
#docker-machine create \
|
||||
# --driver=hyperv \
|
||||
# --hyperv-memory=2048 \
|
||||
# --hyperv-virtual-switch="Primary Virtual Swtich" \
|
||||
# dvc${server} &
|
||||
#done
|
||||
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
set -x
|
||||
|
||||
# since we created droplets with a private NIC on eth1, lets use that for swarm comms
|
||||
LEADER_IP=$(docker-machine ssh dvc1 ifconfig eth1 | grep 'inet addr' | cut -d: -f2 | awk '{print $1}')
|
||||
|
||||
# create a swarm as all managers
|
||||
docker-machine ssh dvc1 docker swarm init --advertise-addr "$LEADER_IP"
|
||||
|
||||
# note that if you use eth1 above (private network in digitalocean) it makes the below
|
||||
# a bit tricky, because docker-machine lists the public IP's but we need the
|
||||
# private IP of manager for join commands, so we can't simply envvar the token
|
||||
# like lots of scripts do... we'd need to fist get private IP of first node
|
||||
|
||||
# TODO: provide flexable numbers at cli for x managers and x workers
|
||||
JOIN_TOKEN=$(docker-machine ssh dvc1 docker swarm join-token -q manager)
|
||||
|
||||
for i in 2 3; do
|
||||
docker-machine ssh dvc$i docker swarm join --token "$JOIN_TOKEN" "$LEADER_IP":2377
|
||||
done
|
||||
|
||||
docker-machine env dvc1
|
||||
Reference in New Issue
Block a user