-
Notifications
You must be signed in to change notification settings - Fork 3
/
deploy_traefik.sh
executable file
·38 lines (27 loc) · 1.17 KB
/
deploy_traefik.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
#!/bin/bash
#set -e
IFS=$'\n'
while read -r var;do
# shellcheck disable=SC2163
export "$var"
done < <(grep -Ev '^#|^$' .env)
export STACK_NAME=traefik-consul
# 3 or 5, not more. if you have a single node, set 0
export CONSUL_REPLICAS=3
# the value number is equal to the count of swarm mode managers.
# if you just have a single manager node, set 1
export TRAEFIK_REPLICAS=3
# id of the current manager node
# shellcheck disable=SC2155
export NODE_ID=$(docker info -f '{{.Swarm.NodeID}}')
docker network create --driver=overlay "$TRAEFIK_NETWORK"
docker node update --label-add ${STACK_NAME}.consul-data-leader=true "$NODE_ID"
sed -i "s/traefik-public/$TRAEFIK_NETWORK/" traefik.yml
docker stack deploy -c traefik.yml $STACK_NAME
echo "Next please put your domain certs in consul as follows:
docker container exec -it traefik-consul_consul-leader... consul kv put traefik/tls/certificates/wildcard.$UI_DOMAIN/certFile \"your cert content\"
docker container exec -it traefik-consul_consul-leader... consul kv put traefik/tls/certificates/wildcard.$UI_DOMAIN/keyFile \"your key content\"
Then access follows in browser:
https://traefik.$UI_DOMAIN
https://consul.$UI_DOMAIN
"