我删除了一个命名空间,该命名空间的服务使用 nginx-ingress 公开,并由证书管理器控制的 Let's Encrypt 证书。命名空间的删除挂起,状态为"正在终止"。
这可能是内部 API 的问题,如此处所述。当我运行时:
kubectl api-resources
它返回无法访问 CertManager Webhook API:
错误:无法检索服务器 API 的完整列表: webhook.certmanager.k8s.io/v1beta1:服务器当前无法处理请求
当我运行kubectl get apiservices v1beta1.webhook.certmanager.k8s.io -o yaml
时,用于检查其状态条件:
...
service:
name: cert-manager-webhook
namespace: nginx-ingress
port: 443
version: v1beta1
versionPriority: 15
status:
conditions:
- lastTransitionTime: "2020-01-21T15:02:23Z"
message: 'failing or missing response from https://10.24.32.6:10250/apis/webhook.certmanager.k8s.io/v1beta1:
bad status from https://10.24.32.6:10250/apis/webhook.certmanager.k8s.io/v1beta1:
404'
reason: FailedDiscoveryCheck
status: "False"
type: Available
所有 nginx-ingress 和 cert-manager pod 都处于良好状态。在部署和删除此命名空间时,我已经对 certmanager 进行了更新,这可能是对问题的解释。如何解决这个问题?
版本:
- Kubernetes: v1.15.4-gke.22
- 证书管理器 v0.12.0
- nginx-入口:1.29.3
这里提出了解决此问题的简单解决方案。但这并没有描述这样的问题是如何出现或可以预防的。
创建描述终止命名空间的临时 JSON 文件:
kubectl get namespace <terminating-namespace> -o json >tmp.json
通过从finalizers
字段中删除kubernetes
值来编辑文件tmp.json
并保存文件。
设置临时代理 IP 和端口:
kubectl proxy
在新终端窗口中,使用您的临时代理 IP 和端口进行 API 调用:
curl -k -H "Content-Type: application/json" -X PUT --data-binary @tmp.json http://127.0.0.1:8001/api/v1/namespaces/<terminating-namespace>/finalize