-
Notifications
You must be signed in to change notification settings - Fork 1
/
worker.sh
60 lines (46 loc) · 876 Bytes
/
worker.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
#!/bin/bash
# utilities functions (logging)
log() {
echo "$(date "+%F %T.%2N")|$(hostname)|${*}"
}
debug() {
log "DEBUG|${*}"
}
info() {
log "INFO|${*}"
}
warn() {
log "WARN|${*}"
}
error() {
log "ERROR|${*}"
}
#default peering subnet for the cluster
PEER_SUBNET="192.168.66.0"
wrong_arg(){
error "Invalid parameter for $1"
exit "1"
}
while [ $# -gt 0 ]; do
case "$1" in
-s|--subnet)
PEER_SUBNET="$2"
shift 2
;;
*)
wrong_arg "$1"
break
;;
esac
done
info "Getting private ip address"
_SUBNET=$(echo $PEER_SUBNET|cut -d "." -f1-3)
PEER_ADDRESS=$(ip -4 a |grep $_SUBNET |awk -F "inet |/" '{ print $2 }')
info "Peering address for master is: "$PEER_ADDRESS
info "Initializing kubeadm by joining master"
while [ ! -f /vagrant/join.txt ]; do
sleep 5
done
JOIN_COMMAND=$(cat /vagrant/join.txt)
$JOIN_COMMAND
info "joined cluster!"