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.
Note, for RKE2 and K3s use the uninstall script deployed on the node during install.


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

You should now have a copy of the script in the current directory.

  • Run the script:

sudo bash

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 -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

< Back to Support Search

For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]

SUSE Support Forums

Get your questions answered by experienced Sys Ops or interact with other SUSE community experts.

Join Our Community

Support Resources

Learn how to get the most from the technical support you receive with your SUSE Subscription, Premium Support, Academic Program, or Partner Program.

SUSE Customer Support Quick Reference Guide SUSE Technical Support Handbook Update Advisories
Support FAQ

Open an Incident

Open an incident with SUSE Technical Support, manage your subscriptions, download patches, or manage user access.

Go to Customer Center