2 ##############################################################################
3 # Copyright (c) 2019 Huawei Tech and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
11 ########################################################################################
13 # The script is to setup the ELIOT Manager and ELIOT nodes. #
14 # It installs Docker in both ELIOT Manager and ELIOT node. #
15 # It installs Kubernetes. In the ELIOT Manager kubeadm, kubelet, kubectl is installed. #
16 # In ELIOT Edge Node it will install kubeadn, kubelet. #
17 # Script is tested in Ubuntu 16.04 version. #
18 # sshpass needs to be installed before executing this script. #
19 ########################################################################################
23 OSPLATFORM=$(awk -F= '/^NAME/{print $2}' /etc/os-release)
24 ELIOT_REPO="https://gerrit.akraino.org/r/eliot"
28 echo "The script helps in setting up the ELIOT Toplogy Infrastrucutre"
29 echo "The setup installs Docker, K8S Master and K8S worker nodes in "
30 echo "ELIOT Manager and ELIOT Workder Nodes respectively "
31 echo "After completion of script execution execute command: "
32 echo "kubectl get nodes to check whether the connection between "
33 echo "ELIOT Manager and ELIOT Nodes are established"
35 echo "Nodelist file should have the details of Worker Nodes in the format of:"
36 echo "EliotNodeUserName|EliotNodeIP|EliotNodePasswor"
37 echo "Each line should have detail of one ELIOT Node only"
40 # Setting up ELIOT Manager Node.
41 # Installing Docker, K8S and Initializing K8S Master
46 source common.sh | tee eliotcommon.log
47 source k8smaster.sh | tee kubeadm.log
56 # Install Docker on ELIOT Node
57 SETUP_WORKER_COMMON="sudo rm -rf ~/eliot &&\
58 git clone ${ELIOT_REPO} &&\
59 cd eliot/scripts/ && source common.sh"
60 #SETUP_WORKER_COMMON="cd eliot/scripts/ && source common.sh"
61 SETUP_WORKER="cd eliot/scripts/ && source k8sworker.sh"
63 KUBEADM_JOIN=$(grep "kubeadm join" ./kubeadm.log)
64 KUBEADM_JOIN="sudo ${KUBEADM_JOIN}"
66 # Read all the Worker Node details from nodelist file.
70 nodeusr=$(echo ${nodeinfo} | cut -d"|" -f1)
71 nodeip=$(echo ${nodeinfo} | cut -d"|" -f2)
72 nodepaswd=$(echo ${nodeinfo} | cut -d"|" -f3)
73 sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} ${SETUP_WORKER_COMMON} < /dev/null
74 sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} ${SETUP_WORKER} < /dev/null
75 sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} ${KUBEADM_JOIN} < /dev/null
76 done < nodelist > /dev/null 2>&1
80 setup_k8smaster_centos()
84 source common_centos.sh | tee eliotcommon_centos.log
85 source k8smaster_centos.sh | tee kubeadm_centos.log
88 setup_k8sworkers_centos
90 kubectl apply -f cni/calico/rbac.yaml
91 kubectl apply -f cni/calico/calico.yaml
96 setup_k8sworkers_centos()
99 # Install Docker on ELIOT Node
101 SETUP_WORKER_COMMON_CENTOS="sudo rm -rf ~/eliot &&\
102 git clone ${ELIOT_REPO} &&\
103 cd eliot/scripts/ && source common_centos.sh"
105 # SETUP_WORKER_COMMON_CENTOS="cd /root/eliot/scripts/ && source common_centos.sh"
107 KUBEADM_TOKEN=$(sudo kubeadm token create --print-join-command)
108 KUBEADM_JOIN_CENTOS="sudo ${KUBEADM_TOKEN}"
109 # Read all the Worker Node details from nodelist file.
112 nodeinfo="${line}" < /dev/null 2>&1
113 nodeusr=$(echo ${nodeinfo} | cut -d"|" -f1) < /dev/null
114 nodeip=$(echo ${nodeinfo} | cut -d"|" -f2) < /dev/null
115 nodepaswd=$(echo ${nodeinfo} | cut -d"|" -f3) < /dev/null
116 sudo sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} ${SETUP_WORKER_COMMON_CENTOS} < /dev/null
117 sudo sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} ${KUBEADM_JOIN_CENTOS} < /dev/null
118 done < nodelist > /dev/null 2>&1
122 # verify kubernetes setup by deploying nginx server.
126 source verifyk8s.sh | tee verifyk8s.log
129 install_cadvisor_edge(){
131 SETUP_CADVISOR_ATEDGE="cd eliot/scripts/ && source cadvisorsetup.sh"
135 nodeusr=$(echo ${nodeinfo} | cut -d"|" -f1)
136 nodeip=$(echo ${nodeinfo} | cut -d"|" -f2)
137 nodepaswd=$(echo ${nodeinfo} | cut -d"|" -f3)
138 sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} ${SETUP_CADVISOR_ATEDGE} < /dev/null
139 done < nodelist > /dev/null 2>&1
142 install_prometheus(){
144 source prometheus.sh | tee install_prometheus.log
150 if [ $1 == "--help" ] || [ $1 == "-h" ];
156 if [[ $OSPLATFORM = *CentOS* ]]; then
157 setup_k8smaster_centos
164 install_cadvisor_edge
168 sudo docker ps | grep prometheus