generated from mudler/gh-k8s
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelpers.sh
73 lines (60 loc) · 1.82 KB
/
helpers.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
start_vpn() {
curl https://get.mocaccino.org/luet/get_luet_root.sh | sudo sh
sudo luet install -y repository/mocaccino-extra
sudo luet install -y utils/edgevpn container/k3s container/kubectl
echo "$EDGEVPN" | base64 -d > config.yaml
sudo -E EDGEVPNCONFIG=config.yaml IFACE=edgevpn0 edgevpn > /dev/null 2>&1 &
}
wait_master() {
while ! nc -z $MASTER 6443; do
echo "K3s server not ready yet.."
sleep 1
done
}
start_server() {
while ! ip a | grep $ADDRESS ; do
echo "VPN not ready yet.."
sleep 1
done
sudo ip a
(
set +e
while true; do
sudo -E k3s server --flannel-iface=edgevpn0 --node-ip $IP --node-external-ip $IP
done
) &
while ! nc -z localhost 6443; do
echo "K3s server not ready yet.."
sleep 1
done
while [ ! -f /etc/rancher/k3s/k3s.yaml ]; do
echo "KUBECONFIG not available yet.."
sleep 1
done
sudo luet serve-repo --address $IP --dir /var/lib/rancher/k3s/server/ &
sudo luet serve-repo --address $IP --port 9091 --dir /etc/rancher/k3s
}
start_agent() {
wait_master
while ! nc -z $MASTER 9090; do
echo "certs not ready yet.."
sleep 1
done
(
set +e
while true; do
export K3S_TOKEN=$( curl --silent -L http://$MASTER:9090/node-token )
echo "Node token $K3S_TOKEN"
sudo -E k3s agent --server https://$MASTER:6443 --flannel-iface=edgevpn0 --node-ip $IP
done
)
}
start_jumpbox() {
sudo luet install -y utils/k9s container/kubectl
}
prepare_jumpbox() {
wait_master
curl http://10.1.0.20:9091/k3s.yaml | sed 's/127\.0\.0\.1/10.1.0.20/g' > k3s.yaml
KUBECONFIG=$PWD/k3s.yaml kubectl apply -f https://raw.githubusercontent.com/mudler/luet-k8s/master/hack/kube.yaml
}