forked from dsohk/rancher-devsecops-workshop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-rke-cluster1.sh
executable file
·31 lines (25 loc) · 999 Bytes
/
setup-rke-cluster1.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
#! /bin/bash -e
if [ ! -f ssh-mylab-cluster1.sh ]; then
echo "Please start your lab before executing this script."
exit
fi
echo "Enter Rancher registration command for cluster1: "
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
VM=$VM_PREFIX-cluster1
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 "Registering cluster1 as All-in-one RKE..."
SSH_VM=$(<ssh-mylab-cluster1.sh)
CMD="$RANCHER_REGCMD --node-name cluster1 --address $PUB_IP --internal-address $PRIV_IP --etcd --controlplane --worker"
echo $CMD
eval "$SSH_VM \"$CMD\""