一种删除 KubeSphere 中一直卡在 Terminating 的 Namespace--KubeSphere Logging System的简单方法

简介: 一种删除 KubeSphere 中一直卡在 Terminating 的 Namespace--KubeSphere Logging System的简单方法

一、问题提出

在使用 KubeSphere 的时候发现有一个日志服务KubeSphere Logging System,它被创建命名空间为kubesphere-logging-system下。当我们不想使用它,需要删除它时,确一直在 Terminating中,怎么也删除不掉。

kubectl delete ns kubesphere-logging-system  --force --grace-period=0

二、删除方法

1,获取kubesphere-logging-syste的详细信息json文件

首先 通过以下命令获取 namespace 的详情信息并转为 json。

kubectl get namespace kubesphere-logging-system -o json > kubesphere-logging-system.json

2,编辑kubesphere-logging-system.json

vim kubesphere-logging-system.json
{
    "apiVersion": "v1",
    "kind": "Namespace",
    "metadata": {
        "creationTimestamp": "2023-12-24T23:13:34Z",
        "deletionTimestamp": "2023-12-27T07:49:27Z",
        "labels": {
            "kubesphere.io/namespace": "kubesphere-logging-system",
            "kubesphere.io/workspace": "system-workspace"
        },
        "name": "kubesphere-logging-system",
        "resourceVersion": "2878899",
        "selfLink": "/api/v1/namespaces/kubesphere-logging-system",
        "uid": "dd01ee56-2dee-40ba-b63e-5fc71e27507b"
    },
    "spec": {
        "finalizers": [
           "kubernetes" # 将此行删除
        ]
    },
    "status": {
        "conditions": [
            {
                "lastTransitionTime": "2023-12-27T07:49:35Z",
                "message": "All resources successfully discovered",
                "reason": "ResourcesDiscovered",
                "status": "False",
                "type": "NamespaceDeletionDiscoveryFailure"
            },
            {
                "lastTransitionTime": "2023-12-27T07:49:35Z",
                "message": "All legacy kube types successfully parsed",
                "reason": "ParsedGroupVersions",
                "status": "False",
                "type": "NamespaceDeletionGroupVersionParsingFailure"
            },
            {
                "lastTransitionTime": "2023-12-27T08:47:05Z",
                "message": "All content successfully deleted, may be waiting on finalization",
                "reason": "ContentDeleted",
                "status": "False",
                "type": "NamespaceDeletionContentFailure"
            },
            {
                "lastTransitionTime": "2023-12-27T07:49:35Z",
                "message": "Some resources are remaining: exporters.events.kubesphere.io has 1 resource instances, fluentbits.logging.kubesphere.io has 1 resource instances, rulers.events.kubesphere.io has 1 resource instances",
                "reason": "SomeResourcesRemain",
                "status": "True",
                "type": "NamespaceContentRemaining"
            },
            {
                "lastTransitionTime": "2023-12-27T07:49:35Z",
                "message": "Some content in the namespace has finalizers remaining: exporters.finalizer.events.kubesphere.io in 1 resource instances, fluentbit.logging.kubesphere.io in 1 resource instances, rulers.finalizer.events.kubesphere.io in 1 resource instances",
                "reason": "SomeFinalizersRemain",
                "status": "True",
                "type": "NamespaceFinalizersRemaining"
            }
        ],
        "phase": "Terminating"
    }
}

找到 spec 将 finalizers 下的 kubernetes 删除。

3,执行清理命令

现在我们只需要一条命令 就可以彻底删除这个 Namespace。

kubectl replace --raw "/api/v1/namespaces/kubesphere-logging-system/finalize" -f ./kubesphere-logging-system.json

三、检查结果

查看namespace kubesphere-logging-system,

kubectl get ns kubesphere-logging-system

已经找不到命名空间kubesphere-logging-system了。

查看所有命名空间:

kubectl get ns

再次查看的时候,它已经不存在了!!

目录
相关文章
|
Prometheus Kubernetes 监控
Kubernetes 的 NameSpace 无法删除应该怎么办?
Kubernetes 的 NameSpace 无法删除应该怎么办?
|
Kubernetes 负载均衡 应用服务中间件
【K8S系列】第十三讲:Ingress详解
【K8S系列】第十三讲:Ingress详解
7879 0
|
JSON Kubernetes API
手把手带你,在K8S集群中删除处于 "terminating" 状态命名空间。
手把手带你,在K8S集群中删除处于 "terminating" 状态命名空间。
|
3月前
|
人工智能 自然语言处理 监控
发布即颠覆?实测smardaten 2.0 :当 AI 遇上无代码软件开发,真的能重新定义 “对话即开发”
发布即颠覆?实测smardaten 2.0 :当 AI 遇上无代码软件开发,真的能重新定义 “对话即开发”
|
机器学习/深度学习 PyTorch 算法框架/工具
深度学习之格式转换笔记(一):模型文件pt转onnx转tensorrt格式实操成功
关于如何将深度学习模型从PyTorch的.pt格式转换为ONNX格式,然后再转换为TensorRT格式的实操指南。
1890 0
深度学习之格式转换笔记(一):模型文件pt转onnx转tensorrt格式实操成功
|
9月前
|
应用服务中间件 nginx Docker
配置Containerd运行时镜像加速器
containerd配置国内容器镜像加速器
3589 1
|
搜索推荐 Java 开发者
org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException 问题处理
【5月更文挑战第14天】org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException 问题处理
4647 1
|
Kubernetes 网络安全 容器
在K8S中,有个服务使用service的nodeport进行暴露,发现访问不到如何排查?
在K8S中,有个服务使用service的nodeport进行暴露,发现访问不到如何排查?
|
存储 Prometheus Kubernetes
在K8S中,如何收集K8S日志?有哪些方案?
在K8S中,如何收集K8S日志?有哪些方案?
|
Kubernetes 文件存储 容器
【Azure K8S | AKS】在中国区AKS上遇见ImagePullBackOff时的替代方案
【Azure K8S | AKS】在中国区AKS上遇见ImagePullBackOff时的替代方案
179 0