github.com/dmaizel/tests@v0.0.0-20210728163746-cae6a2d9cee8/integration/kubernetes/cleanup_env.sh (about) 1 #!/bin/bash 2 # 3 # Copyright (c) 2018 Intel Corporation 4 # 5 # SPDX-License-Identifier: Apache-2.0 6 # 7 # This script is used to reset the kubernetes cluster 8 9 SCRIPT_PATH=$(dirname "$(readlink -f "$0")") 10 source "${SCRIPT_PATH}/../../lib/common.bash" 11 12 cri_runtime="${CRI_RUNTIME:-crio}" 13 14 case "${cri_runtime}" in 15 containerd) 16 cri_runtime_socket="/run/containerd/containerd.sock" 17 ;; 18 crio) 19 cri_runtime_socket="/var/run/crio/crio.sock" 20 ;; 21 *) 22 echo "Runtime ${cri_runtime} not supported" 23 ;; 24 esac 25 26 export KUBECONFIG="$HOME/.kube/config" 27 sudo -E kubeadm reset -f --cri-socket="${cri_runtime_socket}" 28 29 sudo systemctl stop "${cri_runtime}" 30 31 sudo ip link set dev cni0 down || true 32 sudo ip link set dev flannel.1 down || true 33 sudo ip link del cni0 || true 34 sudo ip link del flannel.1 || true 35 36 # if CI run in bare-metal, we need a set of extra clean 37 BAREMETAL="${BAREMETAL:-false}" 38 if [ "${BAREMETAL}" == true ] && [ -f "${SCRIPT_PATH}/cleanup_bare_metal_env.sh" ]; then 39 bash -f "${SCRIPT_PATH}/cleanup_bare_metal_env.sh" 40 fi 41 42 # Check no kata processes are left behind after reseting kubernetes 43 check_processes 44 45 # Checks that pods were not left 46 check_pods