-
Notifications
You must be signed in to change notification settings - Fork 21
/
start_stop_cluster.sh
executable file
·47 lines (37 loc) · 1.14 KB
/
start_stop_cluster.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
#!/bin/bash
#####################################################################
## Start and stop K8S cluster
#####################################################################
input=$1
function read_properties() {
while IFS== read -r KEY VALUE
do
if [[ "${KEY:0:1}" =~ ^[A-Z]$ ]]; then
export "$KEY=$VALUE"
fi
done < ./install.properties
}
function invalid_command(){
echo "This script will start, stop or restart Docker and Kubelet on cluster nodes."
echo "Usage: start_stop_cluster.sh <start|stop|restart>"
exit
}
function start_stop_cluster(){
local vms=($(lxc list ${ICP_ENV_NAME_SHORT}- -c n --format=csv))
if [[ $input =~ ^(start|stop|restart)$ ]]; then
for vm in ${vms[*]}
do
echo "Changing server $vm Docker state to: $input"
lxc exec $vm -- sh -c "systemctl $input docker"
echo "Changing server $vm Kubelet state to: $input"
lxc exec $vm -- sh -c "systemctl $input kubelet"
done
else
invalid_command
fi
}
if [[ -z "$input" ]]; then
invalid_command
fi
start_stop_cluster