Skip to content

Instantly share code, notes, and snippets.

@pjmazenot
Last active February 2, 2019 17:42
Show Gist options
  • Save pjmazenot/12cf01ad7021a3e1a260eeb173e8cc3c to your computer and use it in GitHub Desktop.
Save pjmazenot/12cf01ad7021a3e1a260eeb173e8cc3c to your computer and use it in GitHub Desktop.
Clean Rancher node
#!/bin/sh
# Remove Docker containers, images and volumes
docker rm -f $(docker ps -qa)
docker rmi -f $(docker images -q)
docker volume rm $(docker volume ls -q)
# Unmount all mounts
for mount in $(mount | grep tmpfs | grep '/var/lib/kubelet' | awk '{ print $3 }') /var/lib/kubelet /var/lib/rancher; do umount $mount; done
# Clean the directories
rm -rf /etc/ceph \
/etc/cni \
/etc/kubernetes \
/opt/cni \
/opt/rke \
/opt/rke/etcd-snapshots/* \
/run/secrets/kubernetes.io \
/run/calico \
/run/flannel \
/var/lib/calico \
/var/lib/etcd \
/var/lib/cni \
/var/lib/kubelet \
/var/lib/rancher/rke/log \
/var/log/containers \
/var/log/pods \
/var/run/calico
# Reboot
reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment