user2062360
user2062360

Reputation: 1523

Is there a way to force delete a crd with failing webhooks?

The kubedb operator in this case has crashed and un-responsive - however I need to cleanup these resources.

 k delete redis r1 redis-queue --namespace cts --force --grace-period=0
warning: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely.
Error from server (InternalError): Internal error occurred: failed calling webhook "redis.validators.kubedb.com": the server is currently unable to handle the request
Error from server (InternalError): Internal error occurred: failed calling webhook "redis.validators.kubedb.com": the server is currently unable to handle the request

Upvotes: 15

Views: 17830

Answers (1)

Arghya Sadhu
Arghya Sadhu

Reputation: 44579

There should be a resource of kind MutatingWebhookConfiguration or ValidatingWebhookConfiguration which actually registers the webhook with Kubernetes API Server. You need to delete that resource first which deregisters the webhook from the Kubernetes API Server.

Temporary store kubedb-webhook configuration:

kubectl get ValidatingWebhookConfiguration redis.validators.kubedb.com \
  -o yaml > redis-validator.yaml
kubectl get MutatingWebhookConfiguration redis.validators.kubedb.com \
  -o yaml > redis-mutate-validator.yaml

Remove your resources:

kubectl delete redis r1 redis-queue --namespace cts

Bring back the webhook configuration:

kubectl apply -f redis-validator.yaml
kubectl apply -f redis-mutate-validator.yaml

Upvotes: 23

Related Questions