解決k8s namespace 一直處于 Terminating 狀態(tài)的問(wèn)題
以下的 tool 為 Terminating 狀態(tài)的 namespace,下面相關(guān)的一些操作記得將 tool 修改成自己的 namespace 名稱
json 格式導(dǎo)出 namespace 信息
k get ns tool -o json > tool.json
修改 json 文件
{
"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 下面的內(nèi)容清空,將 metadata 字段花括號(hào)結(jié)尾的逗號(hào)去掉,保留完整的 json 格式
以下是修改過(guò)后的樣式 [ 提供參考的,用來(lái)和原始 json 做對(duì)比,好增加理解 ]
{
"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"
}
}
開(kāi)啟 proxy 服務(wù)
這個(gè)時(shí)候要新打開(kāi)一個(gè)終端,開(kāi)啟的 proxy 服務(wù)不是后臺(tái)運(yùn)行的,會(huì)占用一個(gè)終端
kubectl proxy
開(kāi)啟后會(huì)返回如下的內(nèi)容
Starting to serve on 127.0.0.1:8001
調(diào)用接口刪除 namespace
在另一個(gè)可以操作命令的終端,執(zhí)行下面的 curl 命令
tool.json- 記得修改成自己的文件名稱tool/finalize- 里面的 tool 修改成自己的namespace名稱
curl -k -H "Content-Type: application/json" \ -X PUT --data-binary @tool.json \ http://127.0.0.1:8001/api/v1/namespaces/tool/finalize
通過(guò) kubectl 命令查看 namespace 是否還存在
到此這篇關(guān)于k8s namespace 一直處于 Terminating 狀態(tài)的解決方法的文章就介紹到這了,更多相關(guān)k8s 命名空間處于 Terminating 狀態(tài)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- 理解k8s控制器DaemonSet創(chuàng)建及使用場(chǎng)景
- K8S集群范圍使用imagePullSecret示例詳解
- k8s安裝CICD?devtron過(guò)程詳解
- kubernetes k8s 存儲(chǔ)動(dòng)態(tài)掛載配置詳解
- K8S?prometheus?operator監(jiān)控工作原理介紹
- K8S節(jié)點(diǎn)本地存儲(chǔ)被撐爆問(wèn)題徹底解決方法
- Kubernetes集群模擬刪除k8s重裝詳解
- Centos7 安裝部署Kubernetes(k8s)集群實(shí)現(xiàn)過(guò)程
- k8s編排之DaemonSet知識(shí)點(diǎn)詳解
相關(guān)文章
在AWS-EC2中安裝Minikube集群的詳細(xì)過(guò)程
這篇文章主要介紹了在AWS-EC2中安裝Minikube集群,本文通過(guò)圖文并茂的形式給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-06-06
Rancher通過(guò)界面管理K8s平臺(tái)的圖文步驟詳解
這篇文章主要為大家介紹了Rancher通過(guò)界面管理K8s平臺(tái)通過(guò)詳細(xì)的圖文進(jìn)行步驟講解,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-03-03
云原生技術(shù)kubernetes(K8S)簡(jiǎn)介
這篇文章主要介紹了云原生技術(shù)kubernetes的相關(guān)資料,幫助大家更好的理解和學(xué)習(xí)使用K8S,感興趣的朋友可以了解下2021-03-03
kubernetes k8s 存儲(chǔ)動(dòng)態(tài)掛載配置詳解
這篇文章主要為大家介紹了kubernetes k8s 存儲(chǔ)動(dòng)態(tài)掛載配置詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-11-11
kubernetes?部署dashboard最新詳細(xì)步驟
這篇文章主要介紹了kubernetes?部署dashboard最新詳細(xì)步驟,本文給大家介紹的非常詳細(xì),感興趣的朋友跟隨小編一起看看吧2024-06-06
kubernetes?k8s?CRD自定義資源學(xué)習(xí)筆記
這篇文章主要介紹了kubernetes?k8s?CRD自定義資源學(xué)習(xí)筆記,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-05-05
K8S?使用EFK日志的統(tǒng)一管理(詳細(xì)步驟)
在Kubernetes中,EFK是一種常見(jiàn)的日志統(tǒng)一管理方案,EFK堆棧允許你收集、存儲(chǔ)、搜素、分析和可視化容器應(yīng)用程序的日志,下面是如何在Kubernetes中使用EFK實(shí)現(xiàn)日志統(tǒng)一管理的詳細(xì)步驟,感興趣的朋友一起看看吧2025-01-01

