SUSE Support

Here When You Need Us

How to clean a Rancher 2.x RKE cluster

This document (000020162) is provided subject to the disclaimer at the end of this document.

Environment

Rancher 2.x
RKE1 (all versions)

Situation

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.

Prerequisite

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

Resolution

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.

Additional Information

For RKE2 and K3s use the uninstall script deployed on the node during install.

Disclaimer

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: 27-Mar-2024
  • Modified Date:27-Mar-2024
    • SUSE Rancher

< Back to Support Search

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

SUSE Support Forums

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

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.

Open an Incident

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