解决k8s namespace 一直处于 Terminating 状态的问题

以下的 tool 为 Terminating 状态的 namespace,下面相关的一些操作记得将 tool 修改成自己的 namespace 名称

json 格式导出 namespace 信息

?
1
k get ns tool -o json > tool.json

修改 json 文件

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{
“apiVersion”: “v1”,
“kind”: “Namespace”,
“metadata”: {
“annotations”: {
“applicationCnName”: “tool”,
“kubernetes.customized/bocloud_env_id”: “3”,
“kubernetes.customized/bocloud_partition_id”: “172”,
“kubernetes.customized/project_creator”: “7”,
“kubernetes.customized/project_id”: “10”,
“kubernetes.customized/tree_application_id”: “10”
},
“creationTimestamp”: “2022-10-18T06:38:25Z”,
“deletionTimestamp”: “2022-10-20T02:34:18Z”,
“labels”: {
“app”: “tool”
},
“name”: “tool”,
“resourceVersion”: “1011030”,
“selfLink”: “/api/v1/namespaces/tool”,
“uid”: “79793f2c-5290-4225-938b-8ce9e639a38c”
},
“spec”: {
“finalizers”: [
“kubernetes”
]
},
“status”: {
“conditions”: [
{
“lastTransitionTime”: “2022-10-20T02:34:23Z”,
“message”: “Discovery failed for some groups, 2 failing: unable to retrieve the complete list of server APIs: custom.metrics.k8s.io/v1beta1: the server is currently unable to handle the request, metrics.k8s.io/v1beta1: the server is currently unable to handle the request”,
“reason”: “DiscoveryFailed”,
“status”: “True”,
“type”: “NamespaceDeletionDiscoveryFailure”
},
{
“lastTransitionTime”: “2022-10-20T02:34:23Z”,
“message”: “All legacy kube types successfully parsed”,
“reason”: “ParsedGroupVersions”,
“status”: “False”,
“type”: “NamespaceDeletionGroupVersionParsingFailure”
},
{
“lastTransitionTime”: “2022-10-20T02:34:23Z”,
“message”: “All content successfully deleted, may be waiting on finalization”,
“reason”: “ContentDeleted”,
“status”: “False”,
“type”: “NamespaceDeletionContentFailure”
},
{
“lastTransitionTime”: “2022-10-20T02:34:23Z”,
“message”: “All content successfully removed”,
“reason”: “ContentRemoved”,
“status”: “False”,
“type”: “NamespaceContentRemaining”
},
{
“lastTransitionTime”: “2022-10-20T02:34:23Z”,
“message”: “All content-preserving finalizers finished”,
“reason”: “ContentHasNoFinalizers”,
“status”: “False”,
“type”: “NamespaceFinalizersRemaining”
}
],
“phase”: “Terminating”
}
}

将 spec 和 status 下面的内容清空,将 metadata 字段花括号结尾的逗号去掉,保留完整的 json 格式

以下是修改过后的样式 [ 提供参考的,用来和原始 json 做对比,好增加理解 ]

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{
“apiVersion”: “v1”,
“kind”: “Namespace”,
“metadata”: {
“annotations”: {
“applicationCnName”: “tool”,
“kubernetes.customized/bocloud_env_id”: “3”,
“kubernetes.customized/bocloud_partition_id”: “172”,
“kubernetes.customized/project_creator”: “7”,
“kubernetes.customized/project_id”: “10”,
“kubernetes.customized/tree_application_id”: “10”
},
“creationTimestamp”: “2022-10-18T06:38:25Z”,
“deletionTimestamp”: “2022-10-20T02:34:18Z”,
“labels”: {
“app”: “tool”
},
“name”: “tool”,
“resourceVersion”: “1011030”,
“selfLink”: “/api/v1/namespaces/tool”,
“uid”: “79793f2c-5290-4225-938b-8ce9e639a38c”
}
}

开启 proxy 服务

这个时候要新打开一个终端,开启的 proxy 服务不是后台运行的,会占用一个终端

?
1
kubectl proxy

开启后会返回如下的内容

?
1
Starting to serve on 127.0.0.1:8001

调用接口删除 namespace

在另一个可以操作命令的终端,执行下面的 curl 命令

tool.json – 记得修改成自己的文件名称 tool/finalize – 里面的 tool 修改成自己的 namespace 名称
?
1
2
3
curl -k -H “Content-Type: application/json” \
-X PUT –data-binary @tool.json \
http://127.0.0.1:8001/api/v1/namespaces/tool/finalize

通过 kubectl 命令查看 namespace 是否还存在

到此这篇关于k8s namespace 一直处于 Terminating 状态的解决方法的文章就介绍到这了,更多相关k8s 命名空间处于 Terminating 状态内容请搜索服务器之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持服务器之家!

原文链接:https://blog.csdn.net/u010383467/article/details/127487098

声明: 猿站网有关资源均来自网络搜集与网友提供,任何涉及商业盈利目的的均不得使用,否则产生的一切后果将由您自己承担! 本平台资源仅供个人学习交流、测试使用 所有内容请在下载后24小时内删除,制止非法恶意传播,不对任何下载或转载者造成的危害负任何法律责任!也请大家支持、购置正版! 。本站一律禁止以任何方式发布或转载任何违法的相关信息访客发现请向站长举报,会员发帖仅代表会员个人观点,并不代表本站赞同其观点和对其真实性负责。本网站的资源部分来源于网络,如有侵权烦请发送邮件至:2697268773@qq.com进行处理。
建站知识

小知识:m3u8是什么格式

2023-3-2 22:57:28

建站知识

docker-compose简单使用方法详解

2023-3-2 23:01:07

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索