From cf0f46af320cc9cf41efb6edad7afbe94dd5e1b6 Mon Sep 17 00:00:00 2001 From: "Jingzhao.Ni" Date: Wed, 22 May 2019 16:45:14 +0800 Subject: [PATCH] Install an essential software & Fix some bugs The software-properties-common software is essential for add-apt-repository. Add it into k8s_common.sh file. Fix bugs when running sshpass Signed-off-by: Jingzhao.Ni Change-Id: I651dbee12177db72bd69708355250c0b005d347d --- src/foundation/scripts/k8s_common.sh | 7 +++++-- src/foundation/scripts/k8s_master.sh | 2 ++ src/foundation/scripts/startup.sh | 35 +++++++++++++++++++++-------------- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/foundation/scripts/k8s_common.sh b/src/foundation/scripts/k8s_common.sh index 0e9de86..06d2d0d 100755 --- a/src/foundation/scripts/k8s_common.sh +++ b/src/foundation/scripts/k8s_common.sh @@ -4,6 +4,10 @@ DOCKER_VERSION=18.06.1~ce~3-0~ubuntu KUBE_VERSION=1.13.0-00 K8S_CNI_VERSION=0.6.0-00 +# Install basic software +sudo apt update +sudo apt install -y software-properties-common apt-transport-https curl + # Install Docker as Prerequisite curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - sudo apt-key fingerprint 0EBFCD88 @@ -18,8 +22,6 @@ sudo apt install -y docker-ce=${DOCKER_VERSION} sudo swapoff -a # Install Kubernetes with Kubeadm -sudo apt update -sudo apt install -y apt-transport-https curl curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - cat <> ./iec/src/foundation/scripts/k8s_worker.sh" - sshpass -p ${passwd} ssh ${HOST_USER}@${ip_addr} ${SETUP_WORKER} + sshpass -p ${passwd} ssh -o StrictHostKeyChecking=no ${HOST_USER}@${ip_addr} ${INSTALL_SOFTWARE} + sshpass -p ${passwd} ssh -o StrictHostKeyChecking=no ${HOST_USER}@${ip_addr} "echo \"sudo ${KUBEADM_JOIN_CMD}\" >> ./iec/src/foundation/scripts/k8s_worker.sh" + sleep 2 + sshpass -p ${passwd} ssh -o StrictHostKeyChecking=no ${HOST_USER}@${ip_addr} "swapon -a" + sshpass -p ${passwd} ssh -o StrictHostKeyChecking=no ${HOST_USER}@${ip_addr} ${SETUP_WORKER} done #Deploy etcd & CNI from master node #There may be more options in future. e.g: Calico, Contiv-vpp, Ovn-k8s ... - SETUP_CNI="cd iec/src/foundation/scripts && source setup-cni.sh" - sshpass -p ${K8S_MASTERPW} ssh ${HOST_USER}@${K8S_MASTER_IP} ${SETUP_CNI} + SETUP_CNI="KUBECONFIG=/etc/kubernetes/admin.conf && cd iec/src/foundation/scripts && source setup-cni.sh" + sshpass -p ${K8S_MASTERPW} ssh -o StrictHostKeyChecking=no ${HOST_USER}@${K8S_MASTER_IP} ${SETUP_CNI} + SETUP_HELM="KUBECONFIG=/etc/kubernetes/admin.conf && cd iec/src/foundation/scripts && source helm.sh" + sshpass -p ${K8S_MASTERPW} ssh -o StrictHostKeyChecking=no ${HOST_USER}@${K8S_MASTER_IP} ${SETUP_HELM} + } # @@ -73,22 +78,22 @@ check_k8s_status(){ set -o xtrace VERIFY_K8S="cd iec/src/foundation/scripts/ && source nginx.sh" - sshpass -p ${K8S_MASTERPW} ssh ${HOST_USER}@${K8S_MASTER_IP} ${VERIFY_K8S} - - sleep 30 + sshpass -p ${K8S_MASTERPW} ssh -o StrictHostKeyChecking=no ${HOST_USER}@${K8S_MASTER_IP} ${VERIFY_K8S} } # # Init # -if [ $1 == "--help" ] || [ $1 == "-h" ]; +if [ -n "$1" ]; then - display_help - exit 0 + if [ $1 == "--help" ] || [ $1 == "-h" ]; + then + display_help + exit 0 + fi fi - # Read the configuration file source config @@ -98,4 +103,6 @@ rm -f "${LOG_FILE}" deploy_k8s +sleep 20 + check_k8s_status -- 2.16.6