【发布时间】:2020-09-26 03:09:55
【问题描述】:
我想删除在 Kubernetes 中创建的命名空间。 我执行的命令:
kubectl 删除命名空间 devops-ui
但这个过程耗时太长(约 20 分钟)而且还在计数。
在检查 minikube 仪表板时,一个 pod 仍然存在,它没有被删除,它处于终止状态。
有什么办法吗?
【问题讨论】:
标签: kubernetes namespaces minikube terminate
我想删除在 Kubernetes 中创建的命名空间。 我执行的命令:
kubectl 删除命名空间 devops-ui
但这个过程耗时太长(约 20 分钟)而且还在计数。
在检查 minikube 仪表板时,一个 pod 仍然存在,它没有被删除,它处于终止状态。
有什么办法吗?
【问题讨论】:
标签: kubernetes namespaces minikube terminate
请先使用以下命令删除 pod
kubectl delete pod pod_name_here --grace-period=0 --force --namespace devops-ui
现在删除命名空间
kubectl delete namespaces devops-ui
【讨论】:
参考:https://kubernetes.io/docs/tasks/administer-cluster/namespaces/
【讨论】:
一些 CRD 有终结器,这将阻止命名空间终止
示例从这里开始 https://github.com/kubernetes/kubernetes/issues/60807#issuecomment-408599873
@ManifoldFR , I had the same issue as yours and I managed to make it work by making an API call with json file .
kubectl get namespace annoying-namespace-to-delete -o json > tmp.json
then edit tmp.json and remove"kubernetes"
curl -k -H "Content-Type: application/json" -X PUT --data-binary @tmp.json https://kubernetes-cluster-ip/api/v1/namespaces/annoying-namespace-to-delete/finalize
注意 - 使用 https://kubernetes.io/docs/tasks/access-application-cluster/access-cluster/ - 如果您正在运行测试集群并需要获取集群 API 访问权限
在我的情况下,它抛出了持有的资源(在默认命名空间中)
{
"type": "NamespaceContentRemaining",
"status": "True",
"lastTransitionTime": "2020-10-09T09:35:11Z",
"reason": "SomeResourcesRemain",
"message": "Some resources are remaining: cephblockpools.ceph.rook.io has 2 resource instances, cephclusters.ceph.rook.io has 1 resource instances"
},
{
"type": "NamespaceFinalizersRemaining",
"status": "True",
"lastTransitionTime": "2020-10-09T09:35:11Z",
"reason": "SomeFinalizersRemain",
"message": "Some content in the namespace has finalizers remaining: cephblockpool.ceph.rook.io in 2 resource instances, cephcluster.ceph.rook.io in 1 resource instances"
}
]
【讨论】: