This repository was archived by the owner on Nov 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-up-consul.sh
74 lines (65 loc) · 1.52 KB
/
build-up-consul.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
MASTER_NODE='deisNode0'
SLAVE_NODE='deisNode1 deisNode2'
NODE_COUNT=$(echo $MASTER_NODE $SLAVE_NODE | wc -w)
#
# Consul (bootstrap master)
#
cat > docker-compose.yml <<_EOF
consul:
restart: always
net: host
container_name: consul
image: progrium/consul
command: "-server -bootstrap-expect $NODE_COUNT"
_EOF
/opt/bin/docker-compose stop
/opt/bin/docker-compose rm -f
/opt/bin/docker-compose up -d
for node in $SLAVE_NODE; do
sleep 10
cat > docker-compose.yml <<_EOF
consul:
restart: always
net: host
container_name: consul
image: progrium/consul
command: "-server -join $MASTER_NODE"
_EOF
scp docker-compose.yml $node:
ssh $node /opt/bin/docker-compose stop
ssh $node /opt/bin/docker-compose rm -f
ssh $node /opt/bin/docker-compose up -d
ssh $node rm docker-compose.yml
done
#
# Gorb
#
cat > docker-compose.yml <<_EOF
gorb:
restart: always
net: host
privileged: true
container_name: gorb
image: monami0ya/gorb
command: "-f -i eth0 -c http://localhost:8500/"
_EOF
/opt/bin/docker-compose stop
/opt/bin/docker-compose rm -f
/opt/bin/docker-compose up -d
sleep 10
for node in $MASTER_NODE $SLAVE_NODE; do
cat > docker-compose.yml <<_EOF
gorb-link:
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
container_name: gorb-link
image: monami0ya/gorb-docker-link
command: "-r ${MASTER_NODE}:4672 -i eth0"
_EOF
scp docker-compose.yml $node:
ssh $node /opt/bin/docker-compose stop
ssh $node /opt/bin/docker-compose rm -f
ssh $node /opt/bin/docker-compose up -d
ssh $node rm docker-compose.yml
done