1 ########################################################################################
3 # The script is to reset the settings on ELIOT Manager and ELIOT nodes #
4 # before running the setup.sh file again on the same setup. #
5 # It resets the settings of kubeadm and restarts its service #
6 # It releases the ports used. #
7 # It deletes the files created for kubernetes on node machine #
8 # Script is tested in Ubuntu 16.04 version. #
9 ########################################################################################
12 OSPLATFORM=$(awk -F= '/^NAME/{print $2}' /etc/os-release)
16 echo "The script is to reset the settings on ELIOT Manager and ELIOT nodes which "
17 echo "needs to be done before executing the setup.sh file again."
18 echo "The changes will be first executed on manager machine and then on the node machines."
19 echo "It will pick the node machine details from nodelist file"
22 # Resetting ELIOT Manager Node
25 sudo yes y | kubeadm reset
26 sudo apt-get install iptables
27 sudo iptables -F && iptables -t nat -F && iptables -t mangle -F && iptables -X
28 sudo apt-get install ipvsadm
29 sudo systemctl restart kubelet
30 sudo fuser -k -n tcp 10250
35 #Resetting ELIOT Worker Node
38 RESET_KUBEADM="sudo yes y | kubeadm reset"
39 INSTALL_IPVSADM="sudo apt-get install ipvsadm"
40 RESTART_KUBELET="sudo systemctl restart kubelet"
41 RESET_PORT="sudo fuser -k -n tcp 10250"
42 #REMOVE_KUBE_FILES="cd /etc/kubernetes && sudo rm -rf !('manifests') "
43 REMOVE_KUBE_FILES="cd /etc/kubernetes && sudo rm -rf bootstrap-kubelet.conf kubelet.conf pki"
44 REMOVE_CADVISOR_FILES="docker rm cadvisor-iot-node1"
46 #Read all the Worker Node details from nodelist file.
50 nodeusr=$(echo ${nodeinfo} | cut -d"|" -f1)
51 nodeip=$(echo ${nodeinfo} | cut -d"|" -f2)
52 nodepaswd=$(echo ${nodeinfo} | cut -d"|" -f3)
53 sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} ${RESET_KUBEADM} < /dev/null
54 sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} ${INSTALL_IPVSADM} < /dev/null
55 sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} ${RESTART_KUBELET} < /dev/null
56 sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} ${RESET_PORT} < /dev/null
57 sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} ${REMOVE_KUBE_FILES} < /dev/null
58 sshpass -p ${nodepaswd} ssh ${nodeusr}@${nodeip} ${REMOVE_CADVISOR_FILES} < /dev/null
59 done < nodelist > /dev/null 2>&1
67 if [ $1 == "--help" ] || [ $1 == "-h" ];
73 if [[ $OSPLATFORM = *Ubuntu* ]]; then
77 echo "The script supports only Linux - Ubuntu"