From 5d7cc898fdadd134d108c3125c45fd93ed2d70dc Mon Sep 17 00:00:00 2001 From: Jingzhao Date: Thu, 14 Mar 2019 10:49:33 +0800 Subject: [PATCH] Add some scripts for verifing the K8s environment Some scripts was added for checking the k8s running status. 1. Add a check_k8s_status function in startup.sh for checking the k8s status. 2. Modify the path of scripts for adapting new file organization Change-Id: Icefd72b7f762fe9ccd223d4b34aac7cc97b4a234 Signed-off-by: Jingzhao --- src/foundation/scripts/startup.sh | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/foundation/scripts/startup.sh b/src/foundation/scripts/startup.sh index d660f4e..b58a43b 100755 --- a/src/foundation/scripts/startup.sh +++ b/src/foundation/scripts/startup.sh @@ -28,27 +28,39 @@ deploy_k8s () { INSTALL_SOFTWARE="sudo apt-get update && sudo apt-get install -y git &&\ sudo rm -rf ~/.kube ~/iec &&\ git clone ${REPO_URL} &&\ - cd iec/scripts/ && source k8s_common.sh" + cd iec/src/foundation/scripts/ && source k8s_common.sh" #Automatic deploy the K8s environments on Master node - SETUP_MASTER="cd iec/scripts/ && source k8s_master.sh ${K8S_MASTER_IP}" + SETUP_MASTER="cd iec/src/foundation/scripts/ && source k8s_master.sh ${K8S_MASTER_IP}" sshpass -p ${K8S_MASTERPW} ssh ${HOST_USER}@${K8S_MASTER_IP} ${INSTALL_SOFTWARE} sshpass -p ${K8S_MASTERPW} ssh ${HOST_USER}@${K8S_MASTER_IP} ${SETUP_MASTER} | tee kubeadm.log KUBEADM_JOIN_CMD=$(grep "kubeadm join " ./kubeadm.log) #Automatic deploy the K8s environments on Worker node - SETUP_WORKER="cd iec/scripts/ && source k8s_worker.sh" + SETUP_WORKER="cd iec/src/foundation/scripts/ && source k8s_worker.sh" sshpass -p ${K8S_WORKERPW} ssh ${HOST_USER}@${K8S_WORKER01_IP} ${INSTALL_SOFTWARE} - sshpass -p ${K8S_WORKERPW} ssh ${HOST_USER}@${K8S_WORKER01_IP} "echo \"sudo ${KUBEADM_JOIN_CMD}\" >> ./iec/scripts/k8s_worker.sh" + sshpass -p ${K8S_WORKERPW} ssh ${HOST_USER}@${K8S_WORKER01_IP} "echo \"sudo ${KUBEADM_JOIN_CMD}\" >> ./iec/src/foundation/scripts/k8s_worker.sh" sshpass -p ${K8S_WORKERPW} ssh ${HOST_USER}@${K8S_WORKER01_IP} ${SETUP_WORKER} #Deploy etcd & CNI from master node #There may be more options in future. e.g: Calico, Contiv-vpp, Ovn-k8s ... - SETUP_CNI="cd iec/scripts && source setup-cni.sh" + SETUP_CNI="cd iec/src/foundation/scripts && source setup-cni.sh" sshpass -p ${K8S_MASTERPW} ssh ${HOST_USER}@${K8S_MASTER_IP} ${SETUP_CNI} } +# +# Check the K8s environments +# +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 +} + PASSWD=${4:-"123456"} HOST_USER=${3:-"iec"} @@ -77,3 +89,5 @@ fi deploy_k8s + +check_k8s_status -- 2.16.6