k8s的namespace一直Terminating的完美解决方案

在k8s集群中进行测试删除namespace是经常的事件,而为了方便操作,一般都是直接对整个名称空间进行删除操作。

相信道友们在进行此步操作的时候,会遇到要删除的namespace一直处于Terminating。下面我将给出一个完美的解决方案,

测试demo

创建demo namespace
# kubectl create ns test
namespace/test created 删除demo namespace
# kubectl delete ns test
namespace "test" deleted 一直处于deleted不见exit
查看状态 可见test namespace 处于Terminating
# kubectl get ns -w
NAME STATUS AGE
test Terminating 18s

下面给出一种完美的解决方案:调用接口删除

开启一个代理终端
# kubectl proxy
Starting to serve on 127.0.0.1:8001 再开启一个操作终端
将test namespace的配置文件输出保存
# kubectl get ns test -o json > test.json
删除spec及status部分的内容还有metadata字段后的","号,切记!
剩下内容大致如下
{
"apiVersion": "v1",
"kind": "Namespace",
"metadata": {
"annotations": {
"cattle.io/status": "{\"Conditions\":[{\"Type\":\"ResourceQuotaInit\",\"Status\":\"True\",\"Message\":\"\",\"LastUpdateTime\":\"2020-10-09T07:12:17Z\"},{\"Type\":\"InitialRolesPopulated\",\"Status\":\"True\",\"Message\":\"\",\"LastUpdateTime\":\"2020-10-09T07:12:18Z\"}]}",
"lifecycle.cattle.io/create.namespace-auth": "true"
},
"creationTimestamp": "2020-10-09T07:12:16Z",
"deletionTimestamp": "2020-10-09T07:12:22Z",
"name": "test",
"resourceVersion": "471648079",
"selfLink": "/api/v1/namespaces/test",
"uid": "862d311e-d87a-48c2-bc48-332a4db9dbdb"
}
} 调接口删除
# curl -k -H "Content-Type: application/json" -X PUT --data-binary @test.json http://127.0.0.1:8001/api/v1/namespaces/test/finalize
{
"kind": "Namespace",
"apiVersion": "v1",
"metadata": {
"name": "test",
"selfLink": "/api/v1/namespaces/test/finalize",
"uid": "862d311e-d87a-48c2-bc48-332a4db9dbdb",
"resourceVersion": "471648079",
"creationTimestamp": "2020-10-09T07:12:16Z",
"deletionTimestamp": "2020-10-09T07:12:22Z",
"annotations": {
"cattle.io/status": "{\"Conditions\":[{\"Type\":\"ResourceQuotaInit\",\"Status\":\"True\",\"Message\":\"\",\"LastUpdateTime\":\"2020-10-09T07:12:17Z\"},{\"Type\":\"InitialRolesPopulated\",\"Status\":\"True\",\"Message\":\"\",\"LastUpdateTime\":\"2020-10-09T07:12:18Z\"}]}",
"lifecycle.cattle.io/create.namespace-auth": "true"
}
},
"spec": { },
"status": {
"phase": "Terminating",
"conditions": [
{
"type": "NamespaceDeletionDiscoveryFailure",
"status": "True",
"lastTransitionTime": "2020-10-09T07:12:27Z",
"reason": "DiscoveryFailed",
"message": "Discovery failed for some groups, 1 failing: unable to retrieve the complete list of server APIs: metrics.k8s.io/v1beta1: the server is currently unable to handle the request"
},
{
"type": "NamespaceDeletionGroupVersionParsingFailure",
"status": "False",
"lastTransitionTime": "2020-10-09T07:12:28Z",
"reason": "ParsedGroupVersions",
"message": "All legacy kube types successfully parsed"
},
{
"type": "NamespaceDeletionContentFailure",
"status": "False",
"lastTransitionTime": "2020-10-09T07:12:28Z",
"reason": "ContentDeleted",
"message": "All content successfully deleted"
}
]
}
}

查看结果

1、delete 状态终止
kubectl delete ns test
namespace "test" deleted 2、Terminating状态终止
kubectl get ns -w
test Terminating 18s
test Terminating 17m

名称空间被删除掉

k8s的namespace一直Terminating的完美解决方案的更多相关文章

  1. k8s删除namespace一直处于terminating状态

    k8s删除namespace一直处于terminating状态 当遇到删除ns是一直处于terminating情况可以用调k8s api进行删除. 1.创建api proxy. [root@node1 ...

  2. 完美解决方案,可排除DATASET不支持System.Nullable错误

    完美解决方案,可排除DATASET不支持System.Nullable错误 using System; using System.Collections.Generic; using System.L ...

  3. Apache服务器网站访问伪静态内页出现No input file specified.的完美解决方案

    原文地址:Apache服务器网站访问伪静态内页出现No input file specified.的完美解决方案 启用REWRITE的伪静态功能的时候,首页可以访问,而访问内页的时候,就提示:&quo ...

  4. 关于Entity Framework中的Attached报错的完美解决方案终极版

    之前发表过一篇文章题为<关于Entity Framework中的Attached报错的完美解决方案>,那篇文章确实能解决单个实体在进行更新.删除时Attached的报错,注意我这里说的单个 ...

  5. No resource found that matches the given name 'Theme.AppCompat.Light 的完美解决方案

    No resource found that matches the given name 'Theme.AppCompat.Light 的完美解决方案 首先这个问题的产生是由于缺少Theme.App ...

  6. ecshop之transport和jquery冲突之完美解决方案

    众所周知:ecshop的transport.js文件和Jquery是冲突的,两个文件不能同时调用,现给出以下完美解决方案:原因分析:在transport.js文件中,大概 580行到590行之间,这个 ...

  7. Xcode6.1标准Framework静态库制作方法。工程转Framework,静态库加xib和图片。完美解决方案。

    http://www.cocoachina.com/bbs/read.php?tid-282490.html Xcode6.1标准Framework静态库制作方法.工程转Framework,静态库加x ...

  8. Safari 前端开发调试 iOS 完美解决方案

    转http://www.2cto.com/kf/201403/283404.html afari 前端开发调试 iOS 完美解决方案 2014-03-05      0个评论    来源:Safari ...

  9. C#多线程解决界面卡死问题的完美解决方案

    C#多线程解决界面卡死问题的完美解决方案 文章转自http://www.sufeinet.com/thread-3556-1-1.html 问题描述: 当我们的界面需要在程序运行中不断更新数据时, 当 ...

随机推荐

  1. Building(单调栈+凸包)

    Problem Description Once upon a time Matt went to a small town. The town was so small and narrow tha ...

  2. BootStrap-select插件动态添加option无法显示

    问题描述: 在使用bootstrap-select插件时出现下拉框无法显示动态追加的option,经过查看element元素发现,select标签已经append进去了所需的option选项,但是页面 ...

  3. Mysql慢查询(分析工具)

    慢查询分析工具[mysqldumpslow] 常用的慢查询日志分析工具 汇总除查询条件外其他完全相同的SQL,并将分析结果按照参数中所指定的顺序输出 语法: mysqldumpslow -s r -t ...

  4. Agumaster 增加雪球网爬虫

  5. 20190923-09Linux磁盘分区类 000 017

    df 查看磁盘空间使用情况 df: disk free 空余硬盘 1.基本语法 df  选项 (功能描述:列出文件系统的整体磁盘使用量,检查文件系统的磁盘空间占用情况) 2.选项说明 表1-32 选项 ...

  6. kali linux 开启ssh服务

    kali linux 一般默认不开启ssh服务,可使用命令查看ssh服务是否开启 命令:service ssh status 如果显示ssh服务没有开启需要修改ssh配置文件将ssh服务开启,kali ...

  7. 哦!这该死的 C 语言

    前言 C 语言是一门抽象的.面向过程的语言,C 语言广泛应用于底层开发,C 语言在计算机体系中占据着不可替代的作用,可以说 C 语言是编程的基础,也就是说,不管你学习任何语言,都应该把 C 语言放在首 ...

  8. Tcahce Stashing Unlink Attack

    今年校赛有点可惜,最后两道质量不错的pwn每做出来,总的来说还是我太菜了,希望下次校赛能AK pwn题.不过这次校赛也没有白打,还是有学到新的东西的.在这里感谢出题的学长. glibc-2.29以后u ...

  9. JS的全局变量无法给Ajax里的变量赋值

    前阶段遇到这么一个问题,在JS定义一个全局变量,JS方法里的其他地方都能使用,偏偏ajax里无法赋值,也不是无法赋值,但赋值总是慢一拍,具体的解决方案如下图所示:

  10. [剑指Offer]65-不用加减乘除做加法

    题目 写一个函数,求两个整数之和,要求在函数体内不得使用+.-.*./四则运算符号. 题解 用位运算模拟加法的三步: 无进位加法:异或运算. 进位:与运算再左移一位. 直到进位为0结束. 代码 pub ...