5分钟6步强制删除kubernetes NameSpace小技巧
在使用kubernetes过程中,我们经常会遇到无法删除NameSpace的情况,但是如果一一去删除NameSpace中资源比较麻烦。下面我们给大家介绍强制删除NameSpace的方法。
一、查看已存在的NameSpace
$ kubectl get ns
NAME STATUS AGE
default Active 56d
ingress-nginx Active 49d
istio-system Terminating 37d
kube-node-lease Active 56d
kube-public Active 56d
kube-system Active 56d
二、获取需要强制删除的NameSpace信息
$ kubectl get namespace istio-system -o json > istio-system.json
$ cat istio-system.json
{
"apiVersion": "v1",
"kind": "Namespace",
"metadata": {
"annotations": {
"kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"v1\",\"kind\":\"Namespace\",\"metadata\":{\"annotations\":{},\"labels\":{\"istio-injection\":\"disabled\",\"istio-operator-managed\":\"Reconcile\",\"operator.istio.io/component\":\"Base\",\"operator.istio.io/managed\":\"Reconcile\",\"operator.istio.io/version\":\"1.4.3\"},\"name\":\"istio-system\"}}\n"
},
"creationTimestamp": "2020-01-27T15:26:48Z",
"deletionTimestamp": "2020-02-15T01:17:05Z",
"labels": {
"istio-injection": "disabled",
"istio-operator-managed": "Reconcile",
"operator.istio.io/component": "Base",
"operator.istio.io/managed": "Reconcile",
"operator.istio.io/version": "1.4.3"
},
"name": "istio-system",
"resourceVersion": "6024170",
"selfLink": "/api/v1/namespaces/istio-system",
"uid": "d8bdc915-ee6f-43cd-ac37-5e353218095f"
},
"spec": {
"finalizers": [
"kubernetes"
]
},
"status": {
"conditions": [
{
"lastTransitionTime": "2020-02-15T01:17:10Z",
"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",
"reason": "DiscoveryFailed",
"status": "True",
"type": "NamespaceDeletionDiscoveryFailure"
},
{
"lastTransitionTime": "2020-02-15T01:17:13Z",
"message": "All legacy kube types successfully parsed",
"reason": "ParsedGroupVersions",
"status": "False",
"type": "NamespaceDeletionGroupVersionParsingFailure"
},
{
"lastTransitionTime": "2020-02-15T01:17:13Z",
"message": "All content successfully deleted, may be waiting on finalization",
"reason": "ContentDeleted",
"status": "False",
"type": "NamespaceDeletionContentFailure"
},
{
"lastTransitionTime": "2020-02-15T01:17:40Z",
"message": "All content successfully removed",
"reason": "ContentRemoved",
"status": "False",
"type": "NamespaceContentRemaining"
},
{
"lastTransitionTime": "2020-02-15T01:17:13Z",
"message": "All content-preserving finalizers finished",
"reason": "ContentHasNoFinalizers",
"status": "False",
"type": "NamespaceFinalizersRemaining"
}
],
"phase": "Terminating"
}
}
三、修改已获取的NameSpace信息文件
示例
$ cat istio-system.json
{
"apiVersion": "v1",
"kind": "Namespace",
"metadata": {
"annotations": {
"kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"v1\",\"kind\":\"Namespace\",\"metadata\":{\"annotations\":{},\"labels\":{\"istio-injection\":\"disabled\",\"istio-operator-managed\":\"Reconcile\",\"operator.istio.io/component\":\"Base\",\"operator.istio.io/managed\":\"Reconcile\",\"operator.istio.io/version\":\"1.4.3\"},\"name\":\"istio-system\"}}\n"
},
"creationTimestamp": "2020-01-27T15:26:48Z",
"deletionTimestamp": "2020-02-15T01:17:05Z",
"labels": {
"istio-injection": "disabled",
"istio-operator-managed": "Reconcile",
"operator.istio.io/component": "Base",
"operator.istio.io/managed": "Reconcile",
"operator.istio.io/version": "1.4.3"
},
"name": "istio-system",
"resourceVersion": "6024170",
"selfLink": "/api/v1/namespaces/istio-system",
"uid": "d8bdc915-ee6f-43cd-ac37-5e353218095f"
},
"spec": {
},
"status": {
"conditions": [
{
"lastTransitionTime": "2020-02-15T01:17:10Z",
"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",
"reason": "DiscoveryFailed",
"status": "True",
"type": "NamespaceDeletionDiscoveryFailure"
},
{
"lastTransitionTime": "2020-02-15T01:17:13Z",
"message": "All legacy kube types successfully parsed",
"reason": "ParsedGroupVersions",
"status": "False",
"type": "NamespaceDeletionGroupVersionParsingFailure"
},
{
"lastTransitionTime": "2020-02-15T01:17:13Z",
"message": "All content successfully deleted, may be waiting on finalization",
"reason": "ContentDeleted",
"status": "False",
"type": "NamespaceDeletionContentFailure"
},
{
"lastTransitionTime": "2020-02-15T01:17:40Z",
"message": "All content successfully removed",
"reason": "ContentRemoved",
"status": "False",
"type": "NamespaceContentRemaining"
},
{
"lastTransitionTime": "2020-02-15T01:17:13Z",
"message": "All content-preserving finalizers finished",
"reason": "ContentHasNoFinalizers",
"status": "False",
"type": "NamespaceFinalizersRemaining"
}
],
"phase": "Terminating"
}
}
四、运行kube-proxy
$ kubectl proxy
Starting to serve on 127.0.0.1:8001
五、通过API执行强制删除操作
$ curl -k -H "Content-Type: application/json" -X PUT --data-binary @istio-system.json http://127.0.0.1:8001/api/v1/namespaces/istio-system/finalize
六、强制删除确认
$ kubectl get ns
NAME STATUS AGE
default Active 56d
ingress-nginx Active 49d
kube-node-lease Active 56d
kube-public Active 56d
kube-system Active 56d
转载至https://zhuanlan.zhihu.com/p/128599556
5分钟6步强制删除kubernetes NameSpace小技巧的更多相关文章
- MySQL平滑删除数据的小技巧【转】
今天接到一位开发同学的数据操作需求,需求看似很简单,需要执行下面的SQL语句: delete from test_track_log where log_time < '2019-1-7 00: ...
- Redis批量删除key的小技巧,你知道吗?
在使用redis的过程中,经常会遇到要批量删除某种规则的key,但是redis提供了批量查询一类key的命令keys或scan,没有提供批量删除某种规则key的命令,怎么办?看完本文即可,哈哈. 本文 ...
- node的第一步,hello,以及小技巧和CPU使用情况。到底能用几个核心?
安装了啥的就不说了,百度一下有很多. Windows环境.Linux不会,所有就不说了. 1. hello Word node的hello Word很简单,就一行. console.log(&quo ...
- iOS开发时间控件怎么强制24小时制(小技巧)
1)当你的format格式是 NSDateFormatter* dateFormatter = [[[NSDateFormatter alloc] init] autorelease];[dateFo ...
- k8s强制删除资源
一般强制删除 kubernetes 的资源: kubectl delete <resource> <resourename> --grace-period=0 --force ...
- Kubernetes中强制删除Pod、namespace
Kubernetes中强制删除Pod.namespace 解决方法 可使用kubectl中的强制删除命令 # 删除POD kubectl delete pod PODNAME --force --gr ...
- kubernetes如何强制删除namespace
K8S如何强制删除namespace 先运行kubectl get namespace ingress-nginx -o json > nginx.json,拿到当前namespace描述,然后 ...
- 用kubernetes部署oa 强制删除pod delete
1.[root@pserver88 oa]# cat Dockerfile FROM tomcat RUN rm -rf /usr/local/tomcat/webapps/*ADD ROOT.war ...
- kubernetes namespace Terminating
1.kubectl get namespace annoying-namespace-to-delete -o json > tmp.jsonthen edit tmp.json and rem ...
随机推荐
- Vue | uni-app 中使用websocket
@ 目录 首先在根目录下新建一个store文件夹,并新建一个websocket.js文件,代码如下: import Vue from 'vue' import Vuex from 'vuex' Vue ...
- Spring Cloud Alibaba 使用RestTemplate进行服务消费
创建服务提供者工程 创建spring-cloud-alibaba-service-member工程,会员中心服务该服务提供用户会员信息. pom.xml <?xml version=" ...
- jquery 实现 <imput>标签 密码框显示/隐藏密码功能
1 <!doctype html> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 < ...
- You (oracle) are not allowed to access to (crontab) because of pam configura
用oracle用户添加备份计划任务,crontab -e,提示:You (oracle) are not allowed to access to (crontab) because of pam c ...
- APP 自动化之appium元素定位(三)
APP自动化测试关键环节--元素定位,以下我们来了解appium提供的元素定位方法! 1. id定位,id一个控件的唯一标识,由开发人员在项目中指定,如果一个元素有对应的resource-id,我们就 ...
- Centos7+Postfix+Dovecot实现内网邮件收发
1. 前期准备: 主机:CentOS release 7.6.1810 (Core) #安装时选择邮件服务器 IP:192.168.71.108 #示例 本地yum源 #因为是内网,所以建 ...
- 解决虚拟机安装linux系统无法全屏问题 & vmtools安装
修改设置 1) 如下图右单击虚拟机名,选择[settings-],调出虚拟机设置界面. 2) 在设置界面选择[hardware]->[CD/DVD2(IDE)]->[Connection] ...
- R数据分析:跟随top期刊手把手教你做一个临床预测模型
临床预测模型也是大家比较感兴趣的,今天就带着大家看一篇临床预测模型的文章,并且用一个例子给大家过一遍做法. 这篇文章来自护理领域顶级期刊的文章,文章名在下面 Ballesta-Castillejos ...
- 修改eclipse中注释字体而不影响代码字体
eclipse的注释字体大小如何修改?不改变代码的字体 貌似没有直接的办法,但是可以取个巧: Window --> Preferences --> General --> Appea ...
- cmd命令配置MySQL
当安装完MySql后,每次windows启动的时候都会将MySql服务启动起来. 如果是winxp则不需要使用管理员权限既可以很简单的打开和关闭,具体在cmd中敲入命令: 1.启动MySql服务: n ...