Add some scripts for verifing the K8s environment 69/469/1
authorJingzhao <Jingzhao.Ni@arm.com>
Thu, 14 Mar 2019 02:49:33 +0000 (10:49 +0800)
committerJingzhao <Jingzhao.Ni@arm.com>
Thu, 14 Mar 2019 02:49:33 +0000 (10:49 +0800)
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 <Jingzhao.Ni@arm.com>
src/foundation/scripts/startup.sh

index d660f4e..b58a43b 100755 (executable)
@@ -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} &&\
   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
 
   #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
   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} ${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 ...
   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}
 }
 
   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"}
 
 PASSWD=${4:-"123456"}
 HOST_USER=${3:-"iec"}
@@ -77,3 +89,5 @@ fi
 
 
 deploy_k8s
 
 
 deploy_k8s
+
+check_k8s_status