Created
December 30, 2020 23:24
-
-
Save electrical/bc959fe58993a1b8bd1dad71201d0b41 to your computer and use it in GitHub Desktop.
rancher cleanup script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
user=$EUID | |
if [ "${user}" != "0" ]; then | |
echo | |
echo "$0 must be run as root - you are running as $EUID" | |
echo | |
exit 1 | |
fi | |
echo | |
echo "About to destroy Rancher 2.x install" | |
echo "5s to cancel with ^c" | |
echo | |
sleep 5 | |
containers=$(docker ps -aq) | |
if [ "${containers}x" != "x" ] | |
then | |
docker rm -f $(docker ps -qa) | |
else | |
echo "No running containers - ignoring docker rm" | |
fi | |
images=$(docker images -aq) | |
if [ "${images}x" != "x" ] | |
then | |
docker rmi $(docker images -aq) | |
else | |
echo "No images - ignoring docker rmi" | |
fi | |
docker volume prune -f | |
for mount in $(mount | grep tmpfs | grep kubelet | awk '{print $3}'); do | |
echo "unmounting $mount" | |
umount $mount | |
done | |
cleanupdirs="/var/lib/etcd /etc/kubernetes /etc/cni /opt/cni /var/lib/cni /var/run/calico /opt/rke /opt/rancher /var/lib/rook /etc/ceph" | |
for dir in $cleanupdirs; do | |
echo "Removing $dir" | |
rm -rf $dir | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment