-
Notifications
You must be signed in to change notification settings - Fork 62
/
setup-rke-devsecops.sh
executable file
·57 lines (48 loc) · 1.8 KB
/
setup-rke-devsecops.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
#! /bin/bash -e
if [ ! -f ssh-mylab-devsecops-m1.sh ]; then
echo "Please start your lab before executing this script."
exit
fi
echo "Enter Rancher registration command for devsecops cluster: "
read RANCHER_REGCMD
# Clean up Rancher Registration Command
RANCHER_REGCMD=${RANCHER_REGCMD/--etcd/}
RANCHER_REGCMD=${RANCHER_REGCMD/--controlplane/}
RANCHER_REGCMD=${RANCHER_REGCMD/--worker/}
RANCHER_REGCMD=${RANCHER_REGCMD/--node-name */}
RANCHER_REGCMD=${RANCHER_REGCMD/--address */}
RANCHER_REGCMD=${RANCHER_REGCMD/--internal-address */}
# Obtain the IP addresses of cluster1
source ./mylab_vm_prefix.sh
if [ -f ssh-mylab-devsecops-m1.sh ]; then
VM=$VM_PREFIX-devsecops-m1
PUB_IP=`cat mylab_vm_list.txt | grep $VM | cut -d '|' -f 4 | xargs`
PRIV_IP=`cat mylab_vm_list.txt | grep $VM | cut -d '|' -f 3 | xargs`
echo
echo "Register devsecops-m1 cluster ..."
SSH_VM=$(<ssh-mylab-devsecops-m1.sh)
CMD="$RANCHER_REGCMD --node-name devsecops-m1 --address $PUB_IP --internal-address $PRIV_IP --etcd --controlplane"
echo $CMD
eval "$SSH_VM \"$CMD\""
sleep 10
fi
# Count all worker nodes
for n in 1 2
do
if [ -f ssh-mylab-devsecops-w$n.sh ]; then
VM=$VM_PREFIX-devsecops-w$n
PUB_IP=`cat mylab_vm_list.txt | grep $VM | cut -d '|' -f 4 | xargs`
PRIV_IP=`cat mylab_vm_list.txt | grep $VM | cut -d '|' -f 3 | xargs`
echo
echo "Register devsecops-w$n cluster ..."
sleep 5
SSH_VM=$(<ssh-mylab-devsecops-w$n.sh)
CMD="$RANCHER_REGCMD --node-name devsecops-w$n --address $PUB_IP --internal-address $PRIV_IP --worker"
echo $CMD
eval "$SSH_VM \"$CMD\""
fi
done
echo
echo "The devsecops cluster is now being provisioned by Rancher. It may take a few minutes to complete."
echo "Once it's ready, please install Longhorn on it and download KUBECONFIG file into your Harbor VM. Thank you!"
echo