Skip to content

Instantly share code, notes, and snippets.

@davidcorbin
Last active April 10, 2024 14:36
Show Gist options
  • Save davidcorbin/52221aab05516eb6f2414e9901f505d1 to your computer and use it in GitHub Desktop.
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

awasome thanks.

@gabbueno
Copy link

Excellent!

@helto4real
Copy link

Thanks a life saver!

@jorikseldeslachts
Copy link

Perfect thanks!

@bernarDuarte
Copy link

Nice script!

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