This script can be used to reverse RKE cluster state migrations that are performed automatically by Rancher on all downstream RKE clusters as of releases v2.7.14
, and v2.8.5
. Running this script should only be necessary if you have upgraded to a Rancher version at or above the aforementioned versions and need to restore Rancher back to a version that is older than the aforementioned versions. For example, you're on v2.8.0
and you take a backup of Rancher and then upgrade to v2.8.5
, but then you restore Rancher from your backup. In this case, you'd have to use this script to reverse the RKE cluster state migrations that would have occurred during the upgrade to v2.8.5
.
full-cluster-state
secrets from downstream RKE clusters.
- Take backups of your downstream RKE clusters.
- Ensure you have kubectl, jq, and yq installed.
- Generate a Rancher API token and use it to set the
RANCHER_TOKEN
environment variable. - Run the script pointing to your Rancher server URL.
export RANCHER_TOKEN=<your token>
./reverse-rke-state-migrations.sh --rancher-host <my-rancher.my-domain.com>
This script will iterate over all downstream RKE clusters and, for each one, it will ensure that a full-cluster-state
ConfigMap exists inside the cluster as is expected by older versions of RKE. After doing this successfully for each of the targeted clusters, the script will remove a ConfigMap from the local cluster that marks the original migration as complete since it will effectively have been reversed.