-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-kubeadm.sh
executable file
·43 lines (35 loc) · 970 Bytes
/
update-kubeadm.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
#!/bin/bash
set -e
if [[ -f "env.sh" ]]; then
source env.sh
fi
export nodes=${nodes:-""}
nodes_array=($nodes)
num_nodes=${#nodes_array[@]}
export SUDO_PASSWD=${SUDO_PASSWD:-""}
for ((i=0; i<num_nodes; i++))
do
ssh -t ${nodes_array[$i]} "echo ${SUDO_PASSWD} | sudo -S -- /bin/bash -i -ce '
set -e
apt update && apt -y upgrade
mv /etc/apt/sources.list.d/kubernetes.list.bak /etc/apt/sources.list.d/kubernetes.list
"'proxy_on apt'"
'"
done
for ((i=0; i<num_nodes; i++))
do
ssh -t ${nodes_array[$i]} "echo ${SUDO_PASSWD} | sudo -S -- /bin/bash -i -ce '
set -e
apt update && apt -y upgrade
'"
echo "(Updated) Index: $i Node:${nodes_array[$i]}"
done
echo "=====Update finished====="
for ((i=0; i<num_nodes; i++))
do
ssh -t ${nodes_array[$i]} "echo ${SUDO_PASSWD} | sudo -S -- /bin/bash -i -ce '
set -e
mv /etc/apt/sources.list.d/kubernetes.list /etc/apt/sources.list.d/kubernetes.list.bak
"'proxy_off apt'"
'"
done