How to clean a Rancher 2.x node
This document (000020162) is provided subject to the disclaimer at the end of this document.
At times a node may need to be cleaned of all state to ensure it is consistent for further use in a cluster. This article and script are for Rancher 2.x.
Please note, this script will delete all containers, volumes, images, network interfaces, and directories that relate to Rancher and Kubernetes. It can also optionally flush all iptables rules and delete container images. It is important to perform pre-checks, and backup the node as needed before proceeding with any steps below.
- A node provisioned with the RKE distribution using Rancher or the RKE CLI.
- The node should no longer be a member of any cluster.
- A copy of the cleanup script, and root/sudo access.
- Check the running containers or Pods, these will be forcefully deleted in the following steps.
- Confirm you are on the correct node and are ready to proceed with cleaning all containers and all data specific to Kubernetes and Rancher/RKE.
The below steps use a script to automate the clean of a node, the commands used can be run manually as needed, follow the steps below cleaning a node that has been used previously in a cluster.
- Login to the node and download the cleanup script:
curl -sLO https://github.com/rancherlabs/support-tools/raw/master/extended-rancher-2-cleanup/extended-cleanup-rancher2.sh
You should now have a copy of the script in the current directory.
- Run the script:
sudo bash extended-cleanup-rancher2.sh
If desired, the optional -f and -i flags can be used together or individually to flush iptables (-f) and delete container images (-i).
sudo bash extended-cleanup-rancher2.sh -f -i
- Restart the node
The node is now in a clean consistent state to be reused in a cluster.
This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.
- Document ID:000020162
- Creation Date: 10-Aug-2022
- Modified Date:11-Aug-2022
- SUSE Rancher
For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com