- k3s cluster (single node, running fine, hosts other workloads including Longhorn for storage)
- Was previously imported into a Rancher instance (v2.14.2) that no longer exists (no backup taken)
- Cluster still has leftover cattle-* namespaces and CRDs from that old Rancher registration
- I’ve deployed a fresh Rancher instance (different host) and want to manage this cluster again
The old Rancher being gone is actually the easy version of this, because nothing is fighting you for the cluster.
I’d start with a plain import and only clean up if it fails:
- Back up the Longhorn volumes first (Longhorn’s own backup target, S3 or NFS). Nothing below should touch longhorn-system or the longhorn.io CRDs, but that is the data you can’t get back.
- In the new Rancher: Import Existing, Generic, and run the registration command on the k3s node.
- The new cattle-cluster-agent replaces the old one in cattle-system, since there is only one per cluster. Check it points at the new server: kubectl -n cattle-system get deploy cattle-cluster-agent -o jsonpath=‘{.spec.template.spec.containers[0].env[?(@.name==“CATTLE_SERVER”)].value}’
- Give it a few minutes and watch the cluster go Active in the new Rancher. In my lab (imported EKS clusters on 2.15.1, not k3s) the agent switched to the new server in about 80 seconds.
What won’t come back, because it lived in the old Rancher and not in the cluster: projects, cluster and project role bindings, users. Recreate those in the new one. Your workloads and Longhorn keep running throughout; the import only changes who manages the cluster.
If the import hangs or the agents keep calling the old URL, that is when the leftovers matter. The rancher-cleanup script removes everything Rancher created on a cluster so you can import clean: https://github.com/rancher/rancher-cleanup. Its README says it skips Longhorn, but it also removes tools you installed through Rancher, like monitoring or logging, and it can’t be undone. I haven’t run it on a cluster with Longhorn, so read the README and have step 1 done before you try it.
(Disclosure: I work at SUSE on Rancher. This is a lab finding, not official guidance.)