2 #Install the k8s-master & k8s-worker node from Mgnt node
7 # Displays the help menu.
12 echo "This script can help you to deploy a simple iec testing"
14 echo "Firstly, the master node and worker node information must"
15 echo "be added into config file which will be used for deployment."
17 echo "Secondly, there should be an user on each node which will be"
18 echo "used to install the corresponding software on master and"
19 echo "worker nodes. At the same time, this user should be enable to"
20 echo "run the sudo command without input password on the hosts."
22 echo "Example usages:"
29 # Deploy k8s with calico.
34 INSTALL_SOFTWARE="sudo apt-get update && sudo apt-get install -y git &&\
35 sudo rm -rf ~/.kube ~/iec &&\
36 git clone ${REPO_URL} &&\
37 cd iec/src/foundation/scripts/ && source k8s_common.sh"
39 #Automatic deploy the K8s environments on Master node
40 SETUP_MASTER="cd iec/src/foundation/scripts/ && source k8s_master.sh ${K8S_MASTER_IP}"
41 sshpass -p ${K8S_MASTERPW} ssh ${HOST_USER}@${K8S_MASTER_IP} ${INSTALL_SOFTWARE}
42 sshpass -p ${K8S_MASTERPW} ssh ${HOST_USER}@${K8S_MASTER_IP} ${SETUP_MASTER} | tee ${LOG_FILE}
44 KUBEADM_JOIN_CMD=$(grep "kubeadm join " ./${LOG_FILE})
47 #Automatic deploy the K8s environments on each worker-node
48 SETUP_WORKER="cd iec/src/foundation/scripts/ && source k8s_worker.sh"
50 for worker in "${K8S_WORKER_GROUP[@]}"
52 ip_addr="$(cut -d',' -f1 <<<${worker})"
53 passwd="$(cut -d',' -f2 <<<${worker})"
54 echo "Install & Deploy on ${ip_addr}. password:${passwd}"
56 sshpass -p ${passwd} ssh ${HOST_USER}@${ip_addr} ${INSTALL_SOFTWARE}
57 sshpass -p ${passwd} ssh ${HOST_USER}@${ip_addr} "echo \"sudo ${KUBEADM_JOIN_CMD}\" >> ./iec/src/foundation/scripts/k8s_worker.sh"
58 sshpass -p ${passwd} ssh ${HOST_USER}@${ip_addr} ${SETUP_WORKER}
63 #Deploy etcd & CNI from master node
64 #There may be more options in future. e.g: Calico, Contiv-vpp, Ovn-k8s ...
65 SETUP_CNI="cd iec/src/foundation/scripts && source setup-cni.sh"
66 sshpass -p ${K8S_MASTERPW} ssh ${HOST_USER}@${K8S_MASTER_IP} ${SETUP_CNI}
70 # Check the K8s environments
75 VERIFY_K8S="cd iec/src/foundation/scripts/ && source nginx.sh"
76 sshpass -p ${K8S_MASTERPW} ssh ${HOST_USER}@${K8S_MASTER_IP} ${VERIFY_K8S}
85 if [ $1 == "--help" ] || [ $1 == "-h" ];
92 # Read the configuration file
95 echo "The number of K8s-Workers:${#K8S_WORKER_GROUP[@]}"