Merge "Bug Fix and Enhancement of setup.sh"
authorkhemendra kumar <khemendra.kumar13@gmail.com>
Tue, 12 Nov 2019 08:32:55 +0000 (08:32 +0000)
committerGerrit Code Review <gerrit@akraino.org>
Tue, 12 Nov 2019 08:32:55 +0000 (08:32 +0000)
blueprints/uCPE/scripts/setup.sh
scripts/ci_management/cleanup_centos.sh [new file with mode: 0755]
scripts/ci_management/cleanup_centos_control.sh [new file with mode: 0755]
scripts/setup.sh

index a4b0b1d..ca0cc66 100755 (executable)
@@ -87,8 +87,7 @@ setup_k8smaster_centos()
   # Setup ELIOT Node
   setup_k8sworkers_centos
 
-  kubectl apply -f cni/calico/rbac.yaml
-  kubectl apply -f cni/calico/calico.yaml
+  kubectl apply -f cni/calico/v38/calico.yaml
 
 }
 
diff --git a/scripts/ci_management/cleanup_centos.sh b/scripts/ci_management/cleanup_centos.sh
new file mode 100755 (executable)
index 0000000..9ddb210
--- /dev/null
@@ -0,0 +1,39 @@
+# !/bin/bash -ex
+##############################################################################
+# Copyright (c) 2019 Huawei Tech and others.                                 #
+#                                                                            #
+# All rights reserved. This program and the accompanying materials           #
+# are made available under the terms of the Apache License, Version 2.0      #
+# which accompanies this distribution, and is available at                   #
+# http://www.apache.org/licenses/LICENSE-2.0                                 #
+##############################################################################
+
+sudo kubeadm reset
+
+if [ -f "$HOME/testk8s-nginx.yaml" ]; then
+    cd $HOME && kubectl delete -f test-k8snginx.yaml && rm -rf testk8s-nginx.yaml
+    echo "testk8s-nginx.yaml cleaned"
+fi
+
+if [ -d "/var/lib/etcd" ]; then
+    sudo rm -rf /var/lib/etcd
+    echo "etcd cleaned"
+fi
+
+KUBEADM_RESET="sudo kubeadm reset"
+ETCD_CLEAN="sudo rm -rf /var/lib/etcd"
+CLEANUP_PROM_CADVISOR="cd eliot/scripts/ci_management && ./uninstall_cadvisor.sh"
+
+# Read all the Worker Node details from nodelist file.
+echo $(pwd)
+while read line
+do
+     nodeinfo="${line}"
+     nodeusr=$(echo ${nodeinfo} | cut -d"|" -f1)
+     nodeip=$(echo ${nodeinfo} | cut -d"|" -f2)
+     nodepaswd=$(echo ${nodeinfo} | cut -d"|" -f3)
+     sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} ${KUBEADM_RESET}
+     sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} ${ETCD_CLEAN}
+     sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} ${CLEANUP_PROM_CADVISOR}
+done < nodelist > /dev/null 2>&1
+
diff --git a/scripts/ci_management/cleanup_centos_control.sh b/scripts/ci_management/cleanup_centos_control.sh
new file mode 100755 (executable)
index 0000000..54b5b06
--- /dev/null
@@ -0,0 +1,17 @@
+#!/usr/bin/expect -f
+##############################################################################
+# Copyright (c) 2019 Huawei Tech and others.                                 #
+#                                                                            #
+# All rights reserved. This program and the accompanying materials           #
+# are made available under the terms of the Apache License, Version 2.0      #
+# which accompanies this distribution, and is available at                   #
+# http://www.apache.org/licenses/LICENSE-2.0                                 #
+##############################################################################
+
+spawn ./cleanup_centos.sh
+expect "Are you sure you want to proceed? "
+send "y\n"
+
+expect "Are you sure you want to proceed? "
+send "y\n"
+interact
index 9b2a695..5b246c5 100755 (executable)
@@ -46,7 +46,7 @@ setup_k8smaster()
   source common.sh | tee eliotcommon.log
   source k8smaster.sh | tee kubeadm.log
   # Setup ELIOT Node
-  setup_k8sworkers
+  oscheck_edge
 }
 
 setup_k8sworkers()
@@ -85,11 +85,7 @@ setup_k8smaster_centos()
   source k8smaster_centos.sh | tee kubeadm_centos.log
 
   # Setup ELIOT Node
-  setup_k8sworkers_centos
-
-  kubectl apply -f cni/calico/rbac.yaml
-  kubectl apply -f cni/calico/calico.yaml
-
+  oscheck_edge
 }
 
 
@@ -119,6 +115,25 @@ setup_k8sworkers_centos()
 
 }
 
+# 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_k8s_status(){