本文介绍了命名空间“卡住"作为终止,我如何删除它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我删除了一个卡住"的命名空间,显示在这个永恒的终止"状态.

I've had a "stuck" namespace that I deleted showing in this eternal "terminating" status.

推荐答案

假设您已经尝试强制删除资源,例如:Pods 卡在终止状态,而你在你的机智端试图恢复命名空间......

Assuming you've already tried to force-delete resources like:Pods stuck at terminating status, and your at your wits' end trying to recover the namespace...

您可以强制删除命名空间(可能会留下悬空的资源):

You can force-delete the namespace (perhaps leaving dangling resources):

(
NAMESPACE=your-rogue-namespace
kubectl proxy &
kubectl get namespace $NAMESPACE -o json |jq '.spec = {"finalizers":[]}' >temp.json
curl -k -H "Content-Type: application/json" -X PUT --data-binary @temp.json 127.0.0.1:8001/api/v1/namespaces/$NAMESPACE/finalize
)

  • 这是对此处的回答的改进,它基于评论这里.

    • This is a refinement of the answer here, which is based on the comment here.

      我正在使用 jq 实用程序以编程方式删除终结器部分中的元素.您可以改为手动执行此操作.

      I'm using the jq utility to programmatically delete elements in the finalizers section. You could do that manually instead.

      kubectl proxy127.0.0.1:8001 默认 创建监听器.如果您知道集群主服务器的主机名/IP,则可以改用它.

      kubectl proxy creates the listener at 127.0.0.1:8001 by default. If you know the hostname/IP of your cluster master, you may be able to use that instead.

      有趣的是,即使在使用 kubectl edit 进行相同更改时,这种方法似乎也有效.

      The funny thing is that this approach seems to work even when using kubectl edit making the same change has no effect.

      这篇关于命名空间“卡住"作为终止,我如何删除它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 20:25