Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 853
user2062360 Avatar asked Jun 15 '20 15:06

user2062360


People also ask

How do I force delete a CRD?

How to delete a CRD. To delete the CRD and resources we created, simply run kubectl delete just like with any other resources.

Can CRD be namespaced?

When you create a new CustomResourceDefinition (CRD), the Kubernetes API Server creates a new RESTful resource path for each version you specify. The custom resource created from a CRD object can be either namespaced or cluster-scoped, as specified in the CRD's spec.

What is a validating Webhook?

Put simply, a validating webhook is an endpoint Kubernetes can invoke prior to persisting resources in ETCD. This endpoint should return a structured response indicating whether the resource should be rejected or accepted and persisted to the datastore.


1 Answers

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
like image 68
Arghya Sadhu Avatar answered Oct 17 '22 06:10

Arghya Sadhu