k8s通过webhook禁止随意删除namespace

今天在开发环境遇到问题,通过 kubectl delete namespace 失败,提示了 valiate.namespace.dev 的 webhook 的错误,造成删除 webhook 失败,解决办法删除 webhook

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
[root@k-m1 manifests]# kubectl get ValidatingWebhookConfiguration
NAME                                                    WEBHOOKS   AGE
cert-manager-webhook                                    1          182d
elastic-webhook.k8s.elastic.co                          13         122d
flink-operator-default-webhook-configuration            1          182d
kubegems-local-controller-webhook                       7          98d
rook-ceph-webhook                                       5          171d
seldon-validating-webhook-configuration-seldon-system   1          97d
[root@k-m1 manifests]# kubectl delete ValidatingWebhookConfiguration kubegems-local-controller-webhook
validatingwebhookconfiguration.admissionregistration.k8s.io "kubegems-local-controller-webhook" deleted
[root@k-m1 manifests]# kubectl delete ns kong-test
namespace "kong-test" deleted

发现删除完 webook 之后,即可正常删除 namespacee

参考文档:

https://www.51cto.com/article/712358.html

Licensed under CC BY-NC-SA 4.0
最后更新于 Sep 10, 2025 02:16 UTC
comments powered by Disqus
Built with Hugo
主题 StackJimmy 设计
Caret Up