-
Notifications
You must be signed in to change notification settings - Fork 31
/
ubuntu-multi.sh
executable file
·51 lines (40 loc) · 2.07 KB
/
ubuntu-multi.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
#!/bin/bash -e
# prerequisitesSkipping phase due to missing Pipeline API endpoint credentials
jq --version || (echo "Please install jq command line tool. https://stedolan.github.io/jq/" && exit 1)
# build latest pke tool
GOOS=linux make pke
KUBERNETES_VERSION="${1:-v1.22.6}"
# install first master node
echo ""
echo "= ubuntu1 ========================================================================"
vagrant up ubuntu1
vagrant ssh ubuntu1 -c "sudo /scripts/pke-multi-master1.sh '$KUBERNETES_VERSION' '192.168.64.21:6443'"
vagrant ssh ubuntu1 -c 'sudo cat /etc/kubernetes/admin.conf' > pke-multi-config.yaml
vagrant ssh ubuntu1 -c "sudo /banzaicloud/pke token list -o json" > build/token.json
TOKEN=`jq -r '.tokens[] | select(.expired == false) | .token' build/token.json`
CERTHASH=`jq -r '.tokens[] | select(.expired == false) | .hash' build/token.json`
echo ""
echo "Using '$TOKEN' and '$CERTHASH' to join other nodes to the cluster"
# install second master node
echo ""
echo "= ubuntu2 ========================================================================"
vagrant up ubuntu2
vagrant ssh ubuntu2 -c "sudo /scripts/pke-multi-mastern.sh '$KUBERNETES_VERSION' '192.168.64.21:6443' '$TOKEN' '$CERTHASH' 192.168.64.22"
# install third master node
echo ""
echo "= ubuntu3 ========================================================================"
vagrant up ubuntu3
vagrant ssh ubuntu3 -c "sudo /scripts/pke-multi-mastern.sh '$KUBERNETES_VERSION' '192.168.64.21:6443' '$TOKEN' '$CERTHASH' 192.168.64.23"
# install worker node
echo ""
echo "= ubuntu4 ========================================================================"
vagrant up ubuntu4
vagrant ssh ubuntu4 -c "sudo /scripts/pke-multi-worker.sh '$KUBERNETES_VERSION' '192.168.64.21:6443' '$TOKEN' '$CERTHASH'"
export KUBECONFIG=$PWD/pke-multi-config.yaml
echo ""
echo "You can access your PKE cluster either:"
echo "- from your host machine accessing the cluster via kubectl. Please run:"
echo "export KUBECONFIG=$PWD/pke-multi-config.yaml"
echo ""
echo "- or starting a shell in the virtual machine. Please run:"
echo "vagrant ssh ubuntu1 -c 'sudo -s'"