X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;f=scripts%2Fsetup.sh;h=069262258e53971e64b444bcd57b55ab7df54a77;hb=ffa5b6d0720bd369eb4aaad581c26fabae025102;hp=9efe5477017cd1e8d25c18194c1c5afd9d765d3b;hpb=895474a9c22bb0cf3fdcc0714b6ce6694c0f1dd8;p=eliot.git diff --git a/scripts/setup.sh b/scripts/setup.sh index 9efe547..0692622 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -18,6 +18,11 @@ # sshpass needs to be installed before executing this script. # ######################################################################################## +# constants + +OSPLATFORM=$(awk -F= '/^NAME/{print $2}' /etc/os-release) +ELIOT_REPO="https://gerrit.akraino.org/r/eliot" + show_help() { echo "The script helps in setting up the ELIOT Toplogy Infrastrucutre" @@ -36,12 +41,12 @@ show_help() # Installing Docker, K8S and Initializing K8S Master setup_k8smaster() { - set -o xtrace + #set -o xtrace sudo rm -rf ~/.kube source common.sh | tee eliotcommon.log source k8smaster.sh | tee kubeadm.log # Setup ELIOT Node - setup_k8sworkers + oscheck_edge } setup_k8sworkers() @@ -49,14 +54,13 @@ setup_k8sworkers() set -o xtrace # Install Docker on ELIOT Node - ELIOT_REPO="https://gerrit.akraino.org/r/eliot" SETUP_WORKER_COMMON="sudo rm -rf ~/eliot &&\ git clone ${ELIOT_REPO} &&\ - cd eliot/scripts && source common.sh" - #SETUP_WORKER_COMMON="cd eliot/scripts && source common.sh" + cd eliot/scripts/ && source common.sh" + #SETUP_WORKER_COMMON="cd eliot/scripts/ && source common.sh" SETUP_WORKER="cd eliot/scripts/ && source k8sworker.sh" - KUBEADM_JOIN=$(grep "kubeadm join " ./kubeadm.log) + KUBEADM_JOIN=$(grep "kubeadm join" ./kubeadm.log) KUBEADM_JOIN="sudo ${KUBEADM_JOIN}" # Read all the Worker Node details from nodelist file. @@ -69,12 +73,68 @@ setup_k8sworkers() sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} ${SETUP_WORKER_COMMON} < /dev/null sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} ${SETUP_WORKER} < /dev/null sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} ${KUBEADM_JOIN} < /dev/null - done < nodelist + done < nodelist > /dev/null 2>&1 + +} + +setup_k8smaster_centos() +{ + set -o xtrace + sudo rm -rf ~/.kube + source common_centos.sh | tee eliotcommon_centos.log + source k8smaster_centos.sh | tee kubeadm_centos.log + + # Setup ELIOT Node + oscheck_edge +} + + +setup_k8sworkers_centos() +{ + set -o xtrace + # Install Docker on ELIOT Node + + SETUP_WORKER_COMMON_CENTOS="sudo rm -rf ~/eliot &&\ + git clone ${ELIOT_REPO} &&\ + cd eliot/scripts/ && source common_centos.sh" + + # SETUP_WORKER_COMMON_CENTOS="cd /root/eliot/scripts/ && source common_centos.sh" + + KUBEADM_TOKEN=$(sudo kubeadm token create --print-join-command) + KUBEADM_JOIN_CENTOS="sudo ${KUBEADM_TOKEN}" + # Read all the Worker Node details from nodelist file. + while read line + do + nodeinfo="${line}" < /dev/null 2>&1 + nodeusr=$(echo ${nodeinfo} | cut -d"|" -f1) < /dev/null + nodeip=$(echo ${nodeinfo} | cut -d"|" -f2) < /dev/null + nodepaswd=$(echo ${nodeinfo} | cut -d"|" -f3) < /dev/null + sudo sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} ${SETUP_WORKER_COMMON_CENTOS} < /dev/null + sudo sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} ${KUBEADM_JOIN_CENTOS} < /dev/null + done < nodelist > /dev/null 2>&1 } +# ELIOT edgenode os check and setup edge node +oscheck_edge() +{ + while read line + do + nodeinfo="${line}" + nodeusr=$(echo ${nodeinfo} | cut -d"|" -f1) + nodeip=$(echo ${nodeinfo} | cut -d"|" -f2) + nodepaswd=$(echo ${nodeinfo} | cut -d"|" -f3) + if sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} [ $OSPLATFORM="*Ubuntu*" ]; then + setup_k8sworkers + elif sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} [ $OSPLATFORM="*CentOS*" ]; then + setup_k8sworkers_centos + kubectl apply -f cni/calico/rbac.yaml + kubectl apply -f cni/calico/calico.yaml + fi + done < nodelist > /dev/null 2>&1 +} -#verify kubernetes setup by deploying nginx server. +# verify kubernetes setup by deploying nginx server. verify_k8s_status(){ set -o xtrace @@ -83,7 +143,7 @@ verify_k8s_status(){ install_cadvisor_edge(){ set -o xtrace - SETUP_CADVISOR_ATEDGE="cd AfterRelease1/eliot/scripts/ && source cadvisorsetup.sh" + SETUP_CADVISOR_ATEDGE="cd eliot/scripts/ && source cadvisorsetup.sh" while read line do nodeinfo="${line}" @@ -91,7 +151,7 @@ install_cadvisor_edge(){ nodeip=$(echo ${nodeinfo} | cut -d"|" -f2) nodepaswd=$(echo ${nodeinfo} | cut -d"|" -f3) sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} ${SETUP_CADVISOR_ATEDGE} < /dev/null - done < nodelist + done < nodelist > /dev/null 2>&1 } install_prometheus(){ @@ -108,13 +168,16 @@ then exit 0 fi +if [[ $OSPLATFORM = *CentOS* ]]; then + setup_k8smaster_centos +else + setup_k8smaster +fi -setup_k8smaster sleep 20 verify_k8s_status - install_cadvisor_edge sleep 10 install_prometheus -sleep 5 +sleep 5 sudo docker ps | grep prometheus