How to cleanup CRDs from a dead Operator deployment

Looking for a dashboard alternative to the Kubernetes dashboard, I stumbled upon Rancher.io. Raving reviews, open-source, and has good traction. Spun up a cluster and off to the races. Well from the title of this post, it did not go well and I had to uninstall it.

I installed it using helm and so I proceeded to do the same to uninstall it and it pretty much worked all except the Custom Resource Definitions. The CRDs created by Rancher.io was a lot and kubectl delete crd was not cutting it and I needed a way to iterate through the list of crds

Luckily for me, xargs was here to save the day in addition to using kubectl output

kubectl get customresourcedefinitions |grep cattle.io |awk '{print $1}' |xargs kubectl delete customresourcedefinitions

cattle.io was a common denominator for all the Rancher CRDs so this can vary depending on the Operator installed, you may use kong if you are trying to clean up kong CRDs for example.

By Dennis Otugo

Dennis Otugo is a Consultant at Bantrain, and loves all things DevOps. In his role, he enables enterprise customers in their digital transformation journey and helps architect cloud-native solutions