#!/bin/bash

#set -u -e

ifconfig docker0 down && brctl delbr docker0

ip link delete kube-ipvs0 && modprobe -r ipip && modprobe  ipip && ifconfig docker0 down && brctl delbr docker0

systemctl stop keepalived
ifconfig cni0 down
ip link delete cni0
ifconfig flannel.1 down
ip link delete flannel.1
rm -rf /var/lib/cni/
rm -f /etc/cni/net.d/*
ifconfig virbr0 down
brctl delbr virbr0
systemctl disable libvirtd.service

# kylin系统运行中的NetworkManager对k8s网络解析有影响，直接关闭
if [ -f /etc/os-release ]; then
    . /etc/os-release
    # 检查NetworkManager是否正在运行中
    if [[ ${ID} = "kylin" && "$(systemctl is-active NetworkManager)" = "active" ]]; then
      systemctl stop NetworkManager
      systemctl disable NetworkManager
    fi
fi

exit 0
