解決k8s namespace 一直處于 Terminating 狀態(tài)的問(wèn)題
以下的 tool 為 Terminating 狀態(tài)的 namespace,下面相關(guān)的一些操作記得將 tool 修改成自己的 namespace 名稱(chēng)
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- 記得修改成自己的文件名稱(chēng)tool/finalize- 里面的 tool 修改成自己的namespace名稱(chēng)
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)文章
Kubernetes應(yīng)用配置管理創(chuàng)建使用詳解
這篇文章主要為大家介紹了Kubernetes應(yīng)用配置管理創(chuàng)建使用詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-11-11
Kubernetes?Ingress實(shí)現(xiàn)細(xì)粒度IP訪問(wèn)控制
這篇文章主要為大家介紹了Kubernetes?Ingress實(shí)現(xiàn)細(xì)粒度IP訪問(wèn)控制,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-04-04
Kubernetes訪問(wèn)控制之鑒權(quán)方法詳解
這篇文章主要為大家介紹了Kubernetes訪問(wèn)控制之鑒權(quán)方法詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-09-09
關(guān)于Rancher部署并導(dǎo)入K8S集群的問(wèn)題
這篇文章主要介紹了關(guān)于Rancher部署并導(dǎo)入K8S集群的問(wèn)題,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-12-12
理解k8s控制器DaemonSet創(chuàng)建及使用場(chǎng)景
這篇文章主要為大家介紹了k8s控制器DaemonSet創(chuàng)建及使用場(chǎng)景詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-09-09
Kubernetes中crictl的詳細(xì)用法教程與應(yīng)用實(shí)戰(zhàn)記錄
crictl作為Kubernetes的容器運(yùn)行時(shí)接口(CRI)的命令行工具,為Kubernetes的調(diào)試和管理提供了強(qiáng)大的支持,通過(guò)本文的詳細(xì)介紹,你應(yīng)該已經(jīng)掌握了crictl的基本安裝、配置、常用命令以及高級(jí)用法,需要的朋友可以參考下2024-07-07

