forked from DeepLJH0001/custom-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcleanup-cluster.sh
More file actions
executable file
·49 lines (37 loc) · 1.05 KB
/
cleanup-cluster.sh
File metadata and controls
executable file
·49 lines (37 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
# Nirmata cleanup script
if [ "$EUID" -ne 0 ]
then echo "Please run with sudo"
exit
fi
# Clean Nirmata agent
systemctl stop nirmata-agent.service
systemctl disable nirmata-agent.service
rm -rf /etc/systemd/system/nirmata-agent.service
# Cleanup docker
docker rm -f $(docker ps -qa)
docker volume rm $(docker volume ls -q)
# Clean anything that could possible leave stuff behind.
cleanupdirs="/var/lib/etcd /etc/kubernetes /etc/cni /opt/cni /var/lib/cni /var/run/calico /opt/rke /etc/cni/ /opt/cni/ /data /opt/nirmata"
for dir in $cleanupdirs; do
echo "Removing $dir"
rm -rf $dir
done
# Disable and cleanup Kubelet
systemctl disable kubelet
kubeadm reset -f
microk8s reset --destroy-storage
microk8s stop
# Clear IP Tables
iptables --flush
iptables -tnat --flush
# Restart Docker
# sudo systemctl restart docker
# Deletes the CNI interface
#sudo ifconfig cni0 down
#sudo brctl delbr cni0
#sudo ifconfig flannel.1 down
#sudo ip link delete cni0
#sudo ip link delete flannel.1
echo Rebooting System to flush kernel, and any hung containers.
reboot