From d115bd57df54a59f76e9400ecb0656301a72c350 Mon Sep 17 00:00:00 2001 From: Srinivasan Selvam Date: Mon, 19 Aug 2019 08:50:57 +0000 Subject: [PATCH] k8s cleanup script on centos Signed-off-by: Srinivasan Selvam Change-Id: Ibef4ffa7cffc90e817e4557eb35f3cb801d716c4 --- scripts/ci_management/cleanup_centos.sh | 39 +++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 scripts/ci_management/cleanup_centos.sh diff --git a/scripts/ci_management/cleanup_centos.sh b/scripts/ci_management/cleanup_centos.sh new file mode 100755 index 0000000..9ddb210 --- /dev/null +++ b/scripts/ci_management/cleanup_centos.sh @@ -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 + -- 2.16.6