有没有办法强制删除 webhook 失败的 crd?

use*_*360 5 kubernetes kubernetes-operator kubedb

在这种情况下,kubedb操作符已经崩溃并且没有响应——但是我需要清理这些资源。

 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

Run Code Online (Sandbox Code Playgroud)

Arg*_*dhu 8

应该有一种资源,MutatingWebhookConfiguration或者ValidatingWebhookConfiguration它实际向webhookKubernetes API 服务器注册。您需要先删除该资源,从而从 Kubernetes API 服务器取消注册 webhook。

临时存储kubedb-webhook配置:

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
Run Code Online (Sandbox Code Playgroud)

删除您的资源:

kubectl delete redis r1 redis-queue --namespace cts
Run Code Online (Sandbox Code Playgroud)

带回 webhook 配置:

kubectl apply -f redis-validator.yaml
kubectl apply -f redis-mutate-validator.yaml
Run Code Online (Sandbox Code Playgroud)

  • 删除 webhook 配置后,检查自定义资源是否没有设置任何终结器,这将阻止删除:“kubectl get redis -o custom-columns=name:.metadata.name,finalizers:.metadata.finalizers”,如果是这样,则编辑对象并从 .metadata.finalizers 中删除终结器,然后尝试再次删除它。 (3认同)