Skip to content

Instantly share code, notes, and snippets.

@davidcorbin
Last active June 18, 2025 07:26
Show Gist options
  • Select an option

  • Save davidcorbin/52221aab05516eb6f2414e9901f505d1 to your computer and use it in GitHub Desktop.

Select an option

Save davidcorbin/52221aab05516eb6f2414e9901f505d1 to your computer and use it in GitHub Desktop.
Remove Rancher from Cluster - Force Delete CRDs
# Manually remove finalizers
kubectl edit -n cattle-system secret tls-rancher
kubectl patch secret tls-rancher -p '{"metadata":{"finalizers":[]}}' --type='merge' -n cattle-system
kubectl patch namespace cattle-system -p '{"metadata":{"finalizers":[]}}' --type='merge' -n cattle-system
kubectl delete namespace cattle-system --grace-period=0 --force
kubectl patch namespace cattle-global-data -p '{"metadata":{"finalizers":[]}}' --type='merge' -n cattle-system
kubectl delete namespace cattle-global-data --grace-period=0 --force
kubectl patch namespace local -p '{"metadata":{"finalizers":[]}}' --type='merge' -n cattle-system
kubectl get customresourcedefinitions |grep cattle.io |awk '{print $1}' |xargs kubectl patch -p '{"metadata":{"finalizers":[]}}' --type=merge crd
# Delete CRDs
kubectl get customresourcedefinitions |grep cattle.io |awk '{print $1}' |xargs kubectl delete customresourcedefinitions --force --grace-period=0
kubectl delete namespace local --grace-period=0 --force
@selcukkubur
Copy link
Copy Markdown

awasome thanks.

@gabbueno
Copy link
Copy Markdown

Excellent!

@helto4real
Copy link
Copy Markdown

Thanks a life saver!

@jorikseldeslachts
Copy link
Copy Markdown

Perfect thanks!

@bernarDuarte
Copy link
Copy Markdown

Nice script!

@gitmonster
Copy link
Copy Markdown

Better use this solution.

@Spashor
Copy link
Copy Markdown

Spashor commented Jan 30, 2025

Das hier hat Funktioniert
Danke

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment