介绍

最近一直在玩 EKS(Elastic Kubernetes Service -- Amazon EKS) 和 KubeSphere。 因为之前没有使用过 EKS 和 KubeSphere,所以这个过程也是一个试错的过程,在我使用 KubeSphere 的时候发现有一个日志服务,在好奇心的驱使下,我创建了它。

在我创建了日志服务(KubeSphere Logging System)以后,我发现我并不想使用它。(可能我只是想看看它到底是什么吧。)强迫症的我就想把它给删除掉。于是我在我的 EKS 中对他进行了强制删除:

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

让人尴尬的是,这个 Namespace 并没有立马删除,我自我安慰道,可能 Namespace 下边有其他没有删除的资源在等待删除,我再等等。。。

过了半个小时,再次查看删除进度:

$ kubectl get  ns  kubesphere-logging-system
NAME STATUS AGE
kubesphere-logging-system Terminating 6d19h

它好像这地卡在了 Terminating 的状态。我试着寻找解决方法,参考这个 isue:http://github.com/kubernetes/kubernetes/issues/60807。但是这种方法要通过 API 才可以实现。EKS 是托管在 AWS 中的,我根本没有办法去操作 EKS 的后台。

终于我在这个 issue 中找到了答案:https://github.com/kubernetes/kubernetes/issues/60807#issuecomment-663853215

如何彻底删除 namespace

获取 namespace 的详情信息并转为 json

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

打开 json 文件编辑

{
"apiVersion": "v1",
"kind": "Namespace",
"metadata": {
"creationTimestamp": "2021-12-31T05:03:58Z",
"deletionTimestamp": "2022-01-05T08:05:40Z",
"labels": {
"kubesphere.io/namespace": "kubesphere-logging-system",
"kubesphere.io/workspace": "system-workspace"
},
"managedFields": [
{
"apiVersion": "v1",
"fieldsType": "FieldsV1",
"fieldsV1": {
"f:metadata": {
"f:labels": {
".": {},
"f:kubesphere.io/namespace": {}
},
"f:ownerReferences": {
".": {},
"k:{\"uid\":\"6d535470-2592-4f3c-a155-eabc362c339d\"}": {
".": {},
"f:apiVersion": {},
"f:blockOwnerDeletion": {},
"f:controller": {},
"f:kind": {},
"f:name": {},
"f:uid": {}
}
}
}
},
"manager": "controller-manager",
"operation": "Update",
"time": "2021-12-31T05:04:01Z"
},
{
"apiVersion": "v1",
"fieldsType": "FieldsV1",
"fieldsV1": {
"f:metadata": {
"f:labels": {
"f:kubesphere.io/workspace": {}
}
},
"f:status": {
"f:phase": {}
}
},
"manager": "kubectl",
"operation": "Update",
"time": "2021-12-31T05:04:01Z"
},
{
"apiVersion": "v1",
"fieldsType": "FieldsV1",
"fieldsV1": {
"f:status": {
"f:conditions": {
".": {},
"k:{\"type\":\"NamespaceContentRemaining\"}": {
".": {},
"f:lastTransitionTime": {},
"f:message": {},
"f:reason": {},
"f:status": {},
"f:type": {}
},
"k:{\"type\":\"NamespaceDeletionContentFailure\"}": {
".": {},
"f:lastTransitionTime": {},
"f:message": {},
"f:reason": {},
"f:status": {},
"f:type": {}
},
"k:{\"type\":\"NamespaceDeletionDiscoveryFailure\"}": {
".": {},
"f:lastTransitionTime": {},
"f:message": {},
"f:reason": {},
"f:status": {},
"f:type": {}
},
"k:{\"type\":\"NamespaceDeletionGroupVersionParsingFailure\"}": {
".": {},
"f:lastTransitionTime": {},
"f:message": {},
"f:reason": {},
"f:status": {},
"f:type": {}
},
"k:{\"type\":\"NamespaceFinalizersRemaining\"}": {
".": {},
"f:lastTransitionTime": {},
"f:message": {},
"f:reason": {},
"f:status": {},
"f:type": {}
}
}
}
},
"manager": "kube-controller-manager",
"operation": "Update",
"time": "2022-01-05T08:05:47Z"
}
],
"name": "kubesphere-logging-system",
"ownerReferences": [
{
"apiVersion": "tenant.kubesphere.io/v1alpha1",
"blockOwnerDeletion": true,
"controller": true,
"kind": "Workspace",
"name": "system-workspace",
"uid": "6d535470-2592-4f3c-a155-eabc362c339d"
}
],
"resourceVersion": "7376520",
"uid": "2b76e9b1-75f2-4a2e-a819-73b36aea188e"
},
"spec": {
"finalizers": [
"kubernetes" # 将此行删除
]
},
"status": {
"conditions": [
{
"lastTransitionTime": "2022-01-05T08:05:47Z",
"message": "All resources successfully discovered",
"reason": "ResourcesDiscovered",
"status": "False",
"type": "NamespaceDeletionDiscoveryFailure"
},
{
"lastTransitionTime": "2022-01-05T08:05:47Z",
"message": "All legacy kube types successfully parsed",
"reason": "ParsedGroupVersions",
"status": "False",
"type": "NamespaceDeletionGroupVersionParsingFailure"
},
{
"lastTransitionTime": "2022-01-05T08:05:47Z",
"message": "All content successfully deleted, may be waiting on finalization",
"reason": "ContentDeleted",
"status": "False",
"type": "NamespaceDeletionContentFailure"
},
{
"lastTransitionTime": "2022-01-05T08:05:47Z",
"message": "Some resources are remaining: fluentbits.logging.kubesphere.io has 1 resource instances",
"reason": "SomeResourcesRemain",
"status": "True",
"type": "NamespaceContentRemaining"
},
{
"lastTransitionTime": "2022-01-05T08:05:47Z",
"message": "Some content in the namespace has finalizers remaining: fluentbit.logging.kubesphere.io in 1 resource instances",
"reason": "SomeFinalizersRemain",
"status": "True",
"type": "NamespaceFinalizersRemaining"
}
],
"phase": "Terminating"
}
}

找到 spec 将 finalizers 下的 kubernetes 删除。

具体如下

{
"apiVersion": "v1",
"kind": "Namespace",
"metadata": {
"creationTimestamp": "2021-12-31T05:03:58Z",
"deletionTimestamp": "2022-01-05T08:05:40Z",
"labels": {
"kubesphere.io/namespace": "kubesphere-logging-system",
"kubesphere.io/workspace": "system-workspace"
},
"managedFields": [
{
"apiVersion": "v1",
"fieldsType": "FieldsV1",
"fieldsV1": {
"f:metadata": {
"f:labels": {
".": {},
"f:kubesphere.io/namespace": {}
},
"f:ownerReferences": {
".": {},
"k:{\"uid\":\"6d535470-2592-4f3c-a155-eabc362c339d\"}": {
".": {},
"f:apiVersion": {},
"f:blockOwnerDeletion": {},
"f:controller": {},
"f:kind": {},
"f:name": {},
"f:uid": {}
}
}
}
},
"manager": "controller-manager",
"operation": "Update",
"time": "2021-12-31T05:04:01Z"
},
{
"apiVersion": "v1",
"fieldsType": "FieldsV1",
"fieldsV1": {
"f:metadata": {
"f:labels": {
"f:kubesphere.io/workspace": {}
}
},
"f:status": {
"f:phase": {}
}
},
"manager": "kubectl",
"operation": "Update",
"time": "2021-12-31T05:04:01Z"
},
{
"apiVersion": "v1",
"fieldsType": "FieldsV1",
"fieldsV1": {
"f:status": {
"f:conditions": {
".": {},
"k:{\"type\":\"NamespaceContentRemaining\"}": {
".": {},
"f:lastTransitionTime": {},
"f:message": {},
"f:reason": {},
"f:status": {},
"f:type": {}
},
"k:{\"type\":\"NamespaceDeletionContentFailure\"}": {
".": {},
"f:lastTransitionTime": {},
"f:message": {},
"f:reason": {},
"f:status": {},
"f:type": {}
},
"k:{\"type\":\"NamespaceDeletionDiscoveryFailure\"}": {
".": {},
"f:lastTransitionTime": {},
"f:message": {},
"f:reason": {},
"f:status": {},
"f:type": {}
},
"k:{\"type\":\"NamespaceDeletionGroupVersionParsingFailure\"}": {
".": {},
"f:lastTransitionTime": {},
"f:message": {},
"f:reason": {},
"f:status": {},
"f:type": {}
},
"k:{\"type\":\"NamespaceFinalizersRemaining\"}": {
".": {},
"f:lastTransitionTime": {},
"f:message": {},
"f:reason": {},
"f:status": {},
"f:type": {}
}
}
}
},
"manager": "kube-controller-manager",
"operation": "Update",
"time": "2022-01-05T08:05:47Z"
}
],
"name": "kubesphere-logging-system",
"ownerReferences": [
{
"apiVersion": "tenant.kubesphere.io/v1alpha1",
"blockOwnerDeletion": true,
"controller": true,
"kind": "Workspace",
"name": "system-workspace",
"uid": "6d535470-2592-4f3c-a155-eabc362c339d"
}
],
"resourceVersion": "7376520",
"uid": "2b76e9b1-75f2-4a2e-a819-73b36aea188e"
},
"spec": {
"finalizers": [
]
},
"status": {
"conditions": [
{
"lastTransitionTime": "2022-01-05T08:05:47Z",
"message": "All resources successfully discovered",
"reason": "ResourcesDiscovered",
"status": "False",
"type": "NamespaceDeletionDiscoveryFailure"
},
{
"lastTransitionTime": "2022-01-05T08:05:47Z",
"message": "All legacy kube types successfully parsed",
"reason": "ParsedGroupVersions",
"status": "False",
"type": "NamespaceDeletionGroupVersionParsingFailure"
},
{
"lastTransitionTime": "2022-01-05T08:05:47Z",
"message": "All content successfully deleted, may be waiting on finalization",
"reason": "ContentDeleted",
"status": "False",
"type": "NamespaceDeletionContentFailure"
},
{
"lastTransitionTime": "2022-01-05T08:05:47Z",
"message": "Some resources are remaining: fluentbits.logging.kubesphere.io has 1 resource instances",
"reason": "SomeResourcesRemain",
"status": "True",
"type": "NamespaceContentRemaining"
},
{
"lastTransitionTime": "2022-01-05T08:05:47Z",
"message": "Some content in the namespace has finalizers remaining: fluentbit.logging.kubesphere.io in 1 resource instances",
"reason": "SomeFinalizersRemain",
"status": "True",
"type": "NamespaceFinalizersRemaining"
}
],
"phase": "Terminating"
}
}

执行清理命令

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

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

执行完以后,你需要等待一会,再次执行命令检查 Namespace。

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

最后的检查

$ kubectl get ns kubesphere-logging-system
Error from server (NotFound): namespaces "kubesphere-logging-system" not found $ kubectl get ns
NAME STATUS AGE
default Active 23d
kubesphere-controls-system Active 9d
kubesphere-devops-system Active 9d
kubesphere-devops-worker Active 16h
kubesphere-monitoring-federated Active 9d
kubesphere-monitoring-system Active 9d
kubesphere-sample-dev Active 8d
kubesphere-system Active 9d

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

本文由博客一文多发平台 OpenWrite 发布!

删除 KubeSphere 中一直卡在 Terminating 的 Namespace的更多相关文章

  1. 聊聊 Kubernetes Pod or Namespace 卡在 Terminating 状态的场景

    这个话题,想必玩过kubernetes的同学当不陌生,我会分Pod和Namespace分别来谈. 开门见山,为什么Pod会卡在Terminationg状态? 一句话,本质是API Server虽然标记 ...

  2. 容器化 | 在 KubeSphere 中部署 MySQL 集群

    程润科 数据库研发工程师,目前从事 RadonDB MySQL Kubernetes 研发,热衷于研究数据库内核.K8s 相关技术. 张莉梅 高级文档工程师,目前负责数据库产品文档开发.维护和管理工作 ...

  3. JSON相关知识,转载:删除JSON中数组删除操作

    一:JSON是什么 JSONg格式:对象是一个无序的“名称/值”对的集合. 对象以括号开始,括号结束. 名称冒号分隔值. "名称/值"之间用逗号分隔 例: var people = ...

  4. C# 删除字符串中的中文

    /// <summary> /// 删除字符串中的中文 /// </summary> public static string Delete中文(string str) { s ...

  5. 如何删除datatable中的一行数据

    在C#中,如果要删除DataTable中的某一行,大约有以下几种办法: 1,使用DataTable.Rows.Remove(DataRow),或者DataTable.Rows.RemoveAt(ind ...

  6. iOS开发-删除字典中的null

    删除字典中的null 我们在处理数据库接口的过程中,如果数据中出现null,我们是没法处理的.我在使用NSUserDaults保存后,出现崩溃. null产生原因 null是后台在处理数据的时候,如果 ...

  7. [java]删除数组中的某一个元素

    package org.company.project.test; import java.util.Arrays; import java.util.Scanner; public class Ar ...

  8. SqlServer删除表中重复记录

    重复记录:有两个意义上的重复记录 一是完全重复的记录,也即所有字段均重复的记录: 二是部分关键字段重复的记录,比如Name字段重复,而其他字段不一定重复或都重复可以忽略. 1.对于第一种重复,比较容易 ...

  9. 查询和删除表中重复数据sql语句

      1.查询表中重复数据.select * from peoplewhere peopleId in (select   peopleId   from   people   group   by   ...

  10. Java删除数据库中的数据

    1:删除数据库中数据表中的数据同样也是一个非常用的技术,使用executeUpdate()方法执行用来做删除SQL的语句可以删除数据库表中的数据 2:本案例使用Statement接口中的execute ...

随机推荐

  1. 七牛云-存储区域代码:报错:"statusCode": 400,"error": incorrect region, please use up-cn-east-2.qiniup.com ——【图床】Typora 七牛云图床 配置文件

    使用PicList对七牛云配置图床,报错信息: 2023-12-13 19:52:19 [PicList ERROR] { "method": "POST", ...

  2. MD5签名生成,字典排序,实际生产

    1.背景 作用:防止请求参数篡改,限制请求时效性: 常用方式:md5签名 关键:签名Key 常用签名原串排列:字母顺序.key1=value1&key2=value2....key (注意:签 ...

  3. 如何在通用异常处理时获取到方法名称(获取注解参数JoinPoint)

    1.背景 很多时候我们在梳理公共异常时,需要获取到接口的而具体名称,便于很好的提示是那个接口错误了 2.实现逻辑 1.在controller方法上的注解上写方法名称,一般使用了swagger都有方法名 ...

  4. ComfyUI插件:efficiency-nodes-comfyui节点

    前言: 学习ComfyUI是一场持久战, efficiency-nodes-comfyui是提高工作流创造效率的工具,包含效率节点整合工作流中的基础功能,比如Efficient Loader节点相当于 ...

  5. 利用标准IO函数接口实现文件拷贝

    把本地磁盘的文件A中的数据完整的拷贝到另一个文本B中,如果文本B不存在则创建,要求文本A的名称和文本B的名称通过命令行传递,并进行验证是否正确. /************************** ...

  6. SMU Summer 2023 Contest Round 13

    SMU Summer 2023 Contest Round 13 A. Review Site 我们总是可以把差评放到另一个服务器,好评和中立放另一个,这样最多投票数就是好评与中立数 #include ...

  7. 线性dp:最长公共子序列

    最长公共子序列 本文讲解的题与leetcode1143.最长公共子序列这题一样,阅读完可以挑战一下. 力扣题目链接 题目叙述: 给定两个字符串,输出其最长公共子序列,并输出它的长度 输入: ADABE ...

  8. .NET 8 Moq mock GetRequiredKeyedService Setup报错

    .NET 8 Moq mock GetRequiredKeyedService Setup报错 代码有地方用到了IServiceProvider.GetRequiredKeyedService来解析服 ...

  9. 【YashanDB知识库】update/delete未选中行时,v$transaction视图没有事务,alter超时问题

    问题现象 1.alter table修改表字段名,卡住,超时. 2.查看v$transaction事务视图,没有看到事务记录. 3.问题单:调整表结构时超时 问题风险及影响 无风险 问题影响版本 客户 ...

  10. webpack笔记-webpack之模块module、路径解析、resolve 配置(三)

    module webpack 的初衷是让 js 支持模块化管理,并且将前端中的各种资源都纳入到对应的模块管理中来,所以在 webpack 的设计中,最重要的部分就是管理模块和模块之间的关系. 在 we ...