-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-stack-redeploy
More file actions
executable file
·89 lines (72 loc) · 2.03 KB
/
docker-stack-redeploy
File metadata and controls
executable file
·89 lines (72 loc) · 2.03 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env bash
usage="
NAME
docker-stack-redeploy
SYNOPSIS
docker-stack-redeploy [-h] [-c compose-file name] -n name
(re)deploys stack to the swarm, will keep trying with backoff until successful.
ARGUMENTS
-n name (required)
Name of the stack in the Swarm.
Example:
docker-stack-redeploy -n my-application-stack
[-f compose-file name] (optional)
name of the compose file. Defaults to compose-stack.yaml
Example:
docker-stack-redeploy -f my-file.yaml -n my-application-stack
INSTALLATION:
Assuming you have the following in your ~/.ssh/config file
Host {my-swarm-manager-host}
User {some-user}
HostName {manager-node-public-ip}
IdentityFile ~/.ssh/{my-private-key-or-pem}
Copy this script to a location in your swarm manager nodes $PATH for the user you're sshing into:
Example: scp docker-stack-redeploy my-swarm-manager-server-host:/dir/in/$PATH/
You can then call the script in the directory where your .yaml stack file is.
"
while test $# -gt 0; do
case "$1" in
-h|--help|-\?)
echo "$usage" >&2
exit
;;
-n|--name|-\?)
name=$2
shift
;;
-f|--file)
file=$2
shift
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
*)
break
esac
shift
done
if [ -z ${name} ]; then
echo "name must be set using -n or --name"
exit 1
fi
if [ -z ${file} ]; then
echo "NOTICE: -f not set, compose stack file defaulted to compose-stack.yaml"
file="compose-stack.yaml"
fi
k=1
i=0
while [ $k == 1 ]
do
i=$((i+1))
echo attempt $i
sudo docker stack rm $name && sudo docker stack deploy -c $file --with-registry-auth $name
k=$?
if [[ $k == 0 ]]; then
echo "finished!"
exit 0
fi
echo "waiting for $((i+i+1)) seconds"
sleep $((i+i+1))
done