<p>I installed rancher into existing kubernetes cluster from this <a href="https://rancher.com/docs/rancher/v2.x/en/installation/install-rancher-on-k8s/" rel="noreferrer">tutorial</a>, using these commands:</p>
<pre><code>helm repo add rancher-latest https://releases.rancher.com/server-charts/latest
kubectl create namespace rancher
kubectl apply --validate=false -f https://github.com/jetstack/cert-manager/releases/download/v1.0.4/cert-manager.crds.yaml
helm repo add jetstack https://charts.jetstack.io
helm repo update
kubectl get pods --namespace cert-manager

helm install rancher rancher-latest/rancher \
  --namespace rancher \
  --set hostname=rancher.blabla.com
kubectl -n rancher rollout status deploy/rancher # wait
kubectl -n rancher get deploy rancher
</code></pre>
<p>The uninstall method from <a href="//rancher.com/docs/rancher/v2.x/en/faq/removing-rancher/#:%7E:text=From%20the%20Global%20view%20in,Click%20Delete." rel="noreferrer">this page</a></p>
<pre><code>./system-tools_linux-amd64 remove -c ~/.kube/config -n rancher
</code></pre>
<p>But it shows an error:</p>
<pre><code>Are you sure you want to remove Rancher Management Plane in Namespace [rancher] [y/n]: y
INFO[0001] Removing Rancher management plane in namespace: [rancher] 
INFO[0001] Getting connection configuration             
INFO[0001] Removing Cattle deployment                   
INFO[0002] Removed Cattle deployment succuessfully      
INFO[0002] Removing ClusterRoleBindings                 
INFO[0003] Successfully removed ClusterRoleBindings     
INFO[0003] Removing ClusterRoles                        
INFO[0003] deleting cluster role [cluster-owner]..      
INFO[0003] deleting cluster role [create-ns]..          
INFO[0003] deleting cluster role [project-owner]..      
INFO[0003] deleting cluster role [project-owner-promoted].. 
INFO[0004] Successfully removed ClusterRoles            
INFO[0004] Removing Cattle Annotations, Finalizers and Labels 
INFO[0004] Checking API resource [bindings]             
INFO[0004] Checking API resource [componentstatuses]    
INFO[0004] Checking API resource [configmaps]           
WARN[0005] Can't build dynamic client for [configmaps]: the server could not find the requested resource
 
INFO[0005] Checking API resource [endpoints]            
WARN[0005] Can't build dynamic client for [endpoints]: the server could not find the requested resource
 
INFO[0005] Checking API resource [events]               
WARN[0005] Can't build dynamic client for [events]: the server could not find the requested resource
 
INFO[0005] Checking API resource [limitranges]          
WARN[0005] Can't build dynamic client for [limitranges]: the server could not find the requested resource
 
INFO[0005] Checking API resource [namespaces]           
WARN[0005] Can't build dynamic client for [namespaces]: the server could not find the requested resource
 
INFO[0005] Checking API resource [namespaces/finalize]  
INFO[0005] Checking API resource [namespaces/status]    
INFO[0005] Checking API resource [nodes]                
WARN[0006] Can't build dynamic client for [nodes]: the server could not find the requested resource
 
INFO[0006] Checking API resource [nodes/proxy]          
INFO[0006] Checking API resource [nodes/status]         
INFO[0006] Checking API resource [persistentvolumeclaims] 
WARN[0006] Can't build dynamic client for [persistentvolumeclaims]: the server could not find the requested resource
 
INFO[0006] Checking API resource [persistentvolumeclaims/status] 
INFO[0006] Checking API resource [persistentvolumes]    
WARN[0006] Can't build dynamic client for [persistentvolumes]: the server could not find the requested resource
 
INFO[0006] Checking API resource [persistentvolumes/status] 
INFO[0006] Checking API resource [pods]                 
WARN[0006] Can't build dynamic client for [pods]: the server could not find the requested resource
 
INFO[0006] Checking API resource [pods/attach]          
INFO[0006] Checking API resource [pods/binding]         
INFO[0006] Checking API resource [pods/eviction]        
INFO[0006] Checking API resource [pods/exec]            
INFO[0006] Checking API resource [pods/log]             
INFO[0006] Checking API resource [pods/portforward]     
INFO[0006] Checking API resource [pods/proxy]           
INFO[0006] Checking API resource [pods/status]          
INFO[0006] Checking API resource [podtemplates]         
WARN[0006] Can't build dynamic client for [podtemplates]: the server could not find the requested resource
 
INFO[0006] Checking API resource [replicationcontrollers] 
WARN[0007] Can't build dynamic client for [replicationcontrollers]: the server could not find the requested resource
 
INFO[0007] Checking API resource [replicationcontrollers/scale] 
INFO[0007] Checking API resource [replicationcontrollers/status] 
INFO[0007] Checking API resource [resourcequotas]       
WARN[0007] Can't build dynamic client for [resourcequotas]: the server could not find the requested resource
 
INFO[0007] Checking API resource [resourcequotas/status] 
INFO[0007] Checking API resource [secrets]              
WARN[0007] Can't build dynamic client for [secrets]: the server could not find the requested resource
 
INFO[0007] Checking API resource [serviceaccounts]      
WARN[0007] Can't build dynamic client for [serviceaccounts]: the server could not find the requested resource
 
INFO[0007] Checking API resource [serviceaccounts/token] 
INFO[0007] Checking API resource [services]             
WARN[0008] Can't build dynamic client for [services]: the server could not find the requested resource
 
INFO[0008] Checking API resource [services/proxy]       
INFO[0008] Checking API resource [services/status]      
INFO[0008] Checking API resource [apiservices]          
WARN[0008] Can't build dynamic client for [apiservices]: the server could not find the requested resource
 
INFO[0008] Checking API resource [apiservices/status]   
INFO[0008] Checking API resource [controllerrevisions]  
WARN[0008] Can't build dynamic client for [controllerrevisions]: the server could not find the requested resource
 
INFO[0008] Checking API resource [daemonsets]           
WARN[0009] Can't build dynamic client for [daemonsets]: the server could not find the requested resource
 
INFO[0009] Checking API resource [daemonsets/status]    
INFO[0009] Checking API resource [deployments]          
WARN[0009] Can't build dynamic client for [deployments]: the server could not find the requested resource
 
INFO[0009] Checking API resource [deployments/scale]    
INFO[0009] Checking API resource [deployments/status]   
INFO[0009] Checking API resource [replicasets]          
WARN[0009] Can't build dynamic client for [replicasets]: the server could not find the requested resource
 
INFO[0009] Checking API resource [replicasets/scale]    
INFO[0009] Checking API resource [replicasets/status]   
INFO[0009] Checking API resource [statefulsets]         
WARN[0009] Can't build dynamic client for [statefulsets]: the server could not find the requested resource
 
INFO[0009] Checking API resource [statefulsets/scale]   
INFO[0009] Checking API resource [statefulsets/status]  
INFO[0009] Checking API resource [events]               
WARN[0010] Can't build dynamic client for [events]: the server could not find the requested resource
 
INFO[0010] Checking API resource [tokenreviews]         
INFO[0010] Checking API resource [localsubjectaccessreviews] 
INFO[0010] Checking API resource [selfsubjectaccessreviews] 
INFO[0010] Checking API resource [selfsubjectrulesreviews] 
INFO[0010] Checking API resource [subjectaccessreviews] 
INFO[0010] Checking API resource [horizontalpodautoscalers] 
WARN[0011] Can't build dynamic client for [horizontalpodautoscalers]: the server could not find the requested resource
 
INFO[0011] Checking API resource [horizontalpodautoscalers/status] 
INFO[0011] Checking API resource [jobs]                 
WARN[0011] Can't build dynamic client for [jobs]: the server could not find the requested resource
 
INFO[0011] Checking API resource [jobs/status]          
INFO[0011] Checking API resource [certificatesigningrequests] 
WARN[0011] Can't build dynamic client for [certificatesigningrequests]: the server could not find the requested resource
 
INFO[0011] Checking API resource [certificatesigningrequests/approval] 
INFO[0011] Checking API resource [certificatesigningrequests/status] 
INFO[0012] Checking API resource [ingressclasses]       
WARN[0012] Can't build dynamic client for [ingressclasses]: the server could not find the requested resource
 
INFO[0012] Checking API resource [ingresses]            
WARN[0012] Can't build dynamic client for [ingresses]: the server could not find the requested resource
 
INFO[0012] Checking API resource [ingresses/status]     
INFO[0012] Checking API resource [networkpolicies]      
WARN[0012] Can't build dynamic client for [networkpolicies]: the server could not find the requested resource
 
INFO[0013] Checking API resource [ingresses]            
WARN[0013] Can't build dynamic client for [ingresses]: the server could not find the requested resource
 
INFO[0013] Checking API resource [ingresses/status]     
INFO[0013] Checking API resource [poddisruptionbudgets] 
WARN[0013] Can't build dynamic client for [poddisruptionbudgets]: the server could not find the requested resource
 
INFO[0013] Checking API resource [poddisruptionbudgets/status] 
INFO[0013] Checking API resource [podsecuritypolicies]  
WARN[0013] Can't build dynamic client for [podsecuritypolicies]: the server could not find the requested resource
 
INFO[0014] Checking API resource [clusterrolebindings]  
WARN[0014] Can't build dynamic client for [clusterrolebindings]: the server could not find the requested resource
 
INFO[0014] Checking API resource [clusterroles]         
WARN[0014] Can't build dynamic client for [clusterroles]: the server could not find the requested resource
 
INFO[0014] Checking API resource [rolebindings]         
WARN[0014] Can't build dynamic client for [rolebindings]: the server could not find the requested resource
 
INFO[0014] Checking API resource [roles]                
WARN[0014] Can't build dynamic client for [roles]: the server could not find the requested resource
 
INFO[0015] Checking API resource [csidrivers]           
WARN[0015] Can't build dynamic client for [csidrivers]: the server could not find the requested resource
 
INFO[0015] Checking API resource [csinodes]             
WARN[0015] Can't build dynamic client for [csinodes]: the server could not find the requested resource
 
INFO[0015] Checking API resource [storageclasses]       
WARN[0015] Can't build dynamic client for [storageclasses]: the server could not find the requested resource
 
INFO[0015] Checking API resource [volumeattachments]    
WARN[0016] Can't build dynamic client for [volumeattachments]: the server could not find the requested resource
 
INFO[0016] Checking API resource [volumeattachments/status] 
INFO[0016] Checking API resource [mutatingwebhookconfigurations] 
WARN[0016] Can't build dynamic client for [mutatingwebhookconfigurations]: the server could not find the requested resource
 
INFO[0016] Checking API resource [validatingwebhookconfigurations] 
WARN[0016] Can't build dynamic client for [validatingwebhookconfigurations]: the server could not find the requested resource
 
INFO[0016] Checking API resource [customresourcedefinitions] 
WARN[0017] Can't build dynamic client for [customresourcedefinitions]: the server could not find the requested resource
 
INFO[0017] Checking API resource [customresourcedefinitions/status] 
INFO[0017] Checking API resource [priorityclasses]      
WARN[0017] Can't build dynamic client for [priorityclasses]: the server could not find the requested resource
 
INFO[0017] Checking API resource [leases]               
WARN[0017] Can't build dynamic client for [leases]: the server could not find the requested resource
 
INFO[0018] Checking API resource [runtimeclasses]       
WARN[0018] Can't build dynamic client for [runtimeclasses]: the server could not find the requested resource
 
INFO[0018] Checking API resource [endpointslices]       
WARN[0018] Can't build dynamic client for [endpointslices]: the server could not find the requested resource
 
INFO[0018] Checking API resource [flowschemas]          
WARN[0019] Can't build dynamic client for [flowschemas]: the server could not find the requested resource
 
INFO[0019] Checking API resource [flowschemas/status]   
INFO[0019] Checking API resource [prioritylevelconfigurations] 
WARN[0019] Can't build dynamic client for [prioritylevelconfigurations]: the server could not find the requested resource
 
INFO[0019] Checking API resource [prioritylevelconfigurations/status] 
INFO[0019] Checking API resource [perconaxtradbclusterbackups] 
WARN[0019] Can't build dynamic client for [perconaxtradbclusterbackups]: the server could not find the requested resource
 
INFO[0019] Checking API resource [perconaxtradbclusterbackups/status] 
INFO[0019] Checking API resource [perconaxtradbclusterrestores] 
WARN[0020] Can't build dynamic client for [perconaxtradbclusterrestores]: the server could not find the requested resource
 
INFO[0020] Checking API resource [perconaxtradbclusterrestores/status] 
INFO[0020] Checking API resource [perconaxtradbclusters] 
WARN[0020] Can't build dynamic client for [perconaxtradbclusters]: the server could not find the requested resource
 
INFO[0020] Checking API resource [perconaxtradbclusters/status] 
INFO[0020] Checking API resource [challenges]           
WARN[0020] Can't build dynamic client for [challenges]: the server could not find the requested resource
 
INFO[0020] Checking API resource [challenges/status]    
INFO[0020] Checking API resource [orders]               
WARN[0020] Can't build dynamic client for [orders]: the server could not find the requested resource
 
INFO[0020] Checking API resource [orders/status]        
INFO[0021] Checking API resource [clusterrepos]         
WARN[0021] Can't build dynamic client for [clusterrepos]: the server could not find the requested resource
 
INFO[0021] Checking API resource [clusterrepos/status]  
INFO[0021] Checking API resource [apps]                 
WARN[0021] Can't build dynamic client for [apps]: the server could not find the requested resource
 
INFO[0021] Checking API resource [apps/status]          
INFO[0021] Checking API resource [operations]           
WARN[0021] Can't build dynamic client for [operations]: the server could not find the requested resource
 
INFO[0021] Checking API resource [operations/status]    
INFO[0022] Checking API resource [clusterissuers]       
WARN[0022] Can't build dynamic client for [clusterissuers]: the server could not find the requested resource
 
INFO[0022] Checking API resource [clusterissuers/status] 
INFO[0022] Checking API resource [certificaterequests]  
WARN[0022] Can't build dynamic client for [certificaterequests]: the server could not find the requested resource
 
INFO[0022] Checking API resource [certificaterequests/status] 
INFO[0022] Checking API resource [certificates]         
WARN[0022] Can't build dynamic client for [certificates]: the server could not find the requested resource
 
INFO[0022] Checking API resource [certificates/status]  
INFO[0022] Checking API resource [issuers]              
WARN[0022] Can't build dynamic client for [issuers]: the server could not find the requested resource
 
INFO[0022] Checking API resource [issuers/status]       
INFO[0023] Checking API resource [gitjobs]              
WARN[0023] Can't build dynamic client for [gitjobs]: the server could not find the requested resource
 
INFO[0023] Checking API resource [gitjobs/status]       
INFO[0023] Checking API resource [prometheusrules]      
WARN[0023] Can't build dynamic client for [prometheusrules]: the server could not find the requested resource
 
INFO[0023] Checking API resource [thanosrulers]         
WARN[0024] Can't build dynamic client for [thanosrulers]: the server could not find the requested resource
 
INFO[0024] Checking API resource [alertmanagers]        
WARN[0024] Can't build dynamic client for [alertmanagers]: the server could not find the requested resource
 
INFO[0024] Checking API resource [podmonitors]          
WARN[0024] Can't build dynamic client for [podmonitors]: the server could not find the requested resource
 
INFO[0024] Checking API resource [probes]               
WARN[0024] Can't build dynamic client for [probes]: the server could not find the requested resource
 
INFO[0024] Checking API resource [servicemonitors]      
WARN[0024] Can't build dynamic client for [servicemonitors]: the server could not find the requested resource
 
INFO[0024] Checking API resource [prometheuses]         
WARN[0025] Can't build dynamic client for [prometheuses]: the server could not find the requested resource
 
INFO[0025] Checking API resource [projects]             
WARN[0025] Can't build dynamic client for [projects]: the server could not find the requested resource
 
INFO[0025] Checking API resource [projects/status]      
INFO[0025] Checking API resource [roletemplates]        
WARN[0025] Can't build dynamic client for [roletemplates]: the server could not find the requested resource
 
INFO[0025] Checking API resource [roletemplates/status] 
INFO[0025] Checking API resource [clusters]             
WARN[0025] Can't build dynamic client for [clusters]: the server could not find the requested resource
 
INFO[0025] Checking API resource [clusters/status]      
INFO[0025] Checking API resource [roletemplatebindings] 
WARN[0026] Can't build dynamic client for [roletemplatebindings]: the server could not find the requested resource
 
INFO[0026] Checking API resource [roletemplatebindings/status] 
INFO[0026] Checking API resource [clusters]             
WARN[0026] Can't build dynamic client for [clusters]: the server could not find the requested resource
 
INFO[0026] Checking API resource [clusters/status]      
INFO[0026] Checking API resource [gitrepos]             
WARN[0026] Can't build dynamic client for [gitrepos]: the server could not find the requested resource
 
INFO[0026] Checking API resource [gitrepos/status]      
INFO[0026] Checking API resource [bundles]              
WARN[0026] Can't build dynamic client for [bundles]: the server could not find the requested resource
 
INFO[0026] Checking API resource [bundles/status]       
INFO[0026] Checking API resource [clusterregistrations] 
WARN[0027] Can't build dynamic client for [clusterregistrations]: the server could not find the requested resource
 
INFO[0027] Checking API resource [clusterregistrations/status] 
INFO[0027] Checking API resource [clusterregistrationtokens] 
WARN[0027] Can't build dynamic client for [clusterregistrationtokens]: the server could not find the requested resource
 
INFO[0027] Checking API resource [clusterregistrationtokens/status] 
INFO[0027] Checking API resource [bundledeployments]    
WARN[0027] Can't build dynamic client for [bundledeployments]: the server could not find the requested resource
 
INFO[0027] Checking API resource [bundledeployments/status] 
INFO[0027] Checking API resource [gitreporestrictions]  
WARN[0027] Can't build dynamic client for [gitreporestrictions]: the server could not find the requested resource
 
INFO[0027] Checking API resource [gitreporestrictions/status] 
INFO[0027] Checking API resource [contents]             
WARN[0028] Can't build dynamic client for [contents]: the server could not find the requested resource
 
INFO[0028] Checking API resource [clustergroups]        
WARN[0028] Can't build dynamic client for [clustergroups]: the server could not find the requested resource
 
INFO[0028] Checking API resource [clustergroups/status] 
INFO[0028] Checking API resource [bundlenamespacemappings] 
WARN[0028] Can't build dynamic client for [bundlenamespacemappings]: the server could not find the requested resource
 
INFO[0028] Checking API resource [bundlenamespacemappings/status] 
INFO[0028] Checking API resource [clusters]             
WARN[0028] Can't build dynamic client for [clusters]: the server could not find the requested resource
 
INFO[0028] Checking API resource [clusters/status]      
INFO[0028] Checking API resource [roles]                
WARN[0029] Can't build dynamic client for [roles]: the server could not find the requested resource
 
INFO[0029] Checking API resource [roles/status]         
INFO[0029] Checking API resource [roles/scale]          
INFO[0029] Checking API resource [replicasettemplates]  
WARN[0029] Can't build dynamic client for [replicasettemplates]: the server could not find the requested resource
 
INFO[0029] Checking API resource [replicasettemplates/status] 
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x148dedc]

goroutine 1 [running]:
github.com/rancher/system-tools/vendor/github.com/urfave/cli.HandleAction.func1(0xc000f3da30)
        /go/src/github.com/rancher/system-tools/vendor/github.com/urfave/cli/app.go:472 +0x278
panic(0x1681e40, 0x2adb0e0)
        /usr/local/go/src/runtime/panic.go:513 +0x1b9
github.com/rancher/system-tools/remove.getGroupAPIResourceList(0xc000198140, 0x0, 0x0, 0x0, 0x0, 0xc000e47580, 0x17, 0xc000ea7ac0, 0x1, 0x1, ...)
        /go/src/github.com/rancher/system-tools/remove/remove.go:425 +0x9c
github.com/rancher/system-tools/remove.removeCattleAnnotationsFinalizersLabels(0xc000198140, 0x0, 0x0)
        /go/src/github.com/rancher/system-tools/remove/remove.go:476 +0x1b2
github.com/rancher/system-tools/remove.DoRemoveRancher.func4(0x0, 0x0)
        /go/src/github.com/rancher/system-tools/remove/remove.go:93 +0x2a
github.com/rancher/system-tools/utils.RetryWithCount(0xc000f3d400, 0x3, 0x0, 0x0)
        /go/src/github.com/rancher/system-tools/utils/utils.go:53 +0x61
github.com/rancher/system-tools/remove.DoRemoveRancher(0xc000198140, 0x0, 0x0)
        /go/src/github.com/rancher/system-tools/remove/remove.go:92 +0x373
reflect.Value.call(0x15fa8e0, 0x1995388, 0x13, 0x18df3cc, 0x4, 0xc0007a59d0, 0x1, 0x1, 0xc00067c080, 0xc000af43b0, ...)
        /usr/local/go/src/reflect/value.go:447 +0x449
reflect.Value.Call(0x15fa8e0, 0x1995388, 0x13, 0xc0007a59d0, 0x1, 0x1, 0x5, 0x4, 0xc000686b40)
        /usr/local/go/src/reflect/value.go:308 +0xa4
github.com/rancher/system-tools/vendor/github.com/urfave/cli.HandleAction(0x15fa8e0, 0x1995388, 0xc000198140, 0x0, 0x0)
        /go/src/github.com/rancher/system-tools/vendor/github.com/urfave/cli/app.go:481 +0x1fb
github.com/rancher/system-tools/vendor/github.com/urfave/cli.Command.Run(0x18e1d91, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1911f67, 0x2a, 0x0, ...)
        /go/src/github.com/rancher/system-tools/vendor/github.com/urfave/cli/command.go:186 +0x8f6
github.com/rancher/system-tools/vendor/github.com/urfave/cli.(*App).Run(0xc0003a6d80, 0xc0000381e0, 0x6, 0x6, 0x0, 0x0)
        /go/src/github.com/rancher/system-tools/vendor/github.com/urfave/cli/app.go:235 +0x52e
main.main()
        /go/src/github.com/rancher/system-tools/main.go:84 +0x5c3
</code></pre>
<p>How to uninstall it manually?</p>

<p>Remove the cattle-system namespace where rancher install all its components.
kubectl delete ns cattle-system</p>
