当前位置:网站首页>kubernetes_Namespace无法删除的解决方法
kubernetes_Namespace无法删除的解决方法
2022-04-22 20:58:00 【饭吃三分饱】
场景:Kubectl delete ns XXXX , namespace 一直处于 Terminating 状态。

使用kubectl delete ns test --force=true,也无法删除。

原因分析: k8s 认为当前命名空间内,还存在未释放资源
实际观察,delete 命令执行后,一直在等待,所以的确有部分资源未释放
解决思路:
1. 查看命名空间下所有资源
kubectl api-resources -o name --verbs=list --namespaced | xargs -n 1 kubectl get --show-kind --ignore-not-found -n test
test命名空间下全部资源都是No Resources
注意:如果命名空间下资源不为空,执行一下操作,资源可能会无限期地继续在集群上运行。
2. 将 test 命名空间以 json文件的形式导出
kubectl get namespace test -o json > test.json
3. 将 spec 下的内容删除:这一步骤的目的在于将内容清空后,以空内容的ns覆盖原有ns,告知k8s-api 要删除的ns内容为空,删除的命令也就无法阻塞了

4. 将空内容的ns的 namespace ,通过 api-server 接口,覆盖到k8s集群中
curl -k \
-H "Content-Type: application/json" \
-X PUT \
--data-binary @test.json \
http://127.0.0.1:8001/api/v1/namespaces/test/finalize
# 因为k8s主节点使用了认证,如果直接使用以下命令会拒绝连接

# 需要使用 kube-proxy 进行代理
kubectl proxy --port=8081
注意:使用 kubectl proxy 命令没有使用守护模式,一次一旦你 Ctrl+c 后,代理就没了
正确做法 打开 2个k8s主节点终端,在一个窗口中执行 kubectl proxy,另一个窗口连接 api-server


非常感谢CSDN博主「Jerry_Pan1990」的原创文章
原文链接:https://blog.csdn.net/Jerry_Pan1990/article/details/103633627
版权声明
本文为[饭吃三分饱]所创,转载请带上原文链接,感谢
https://blog.csdn.net/Wqr_18390921824/article/details/124208510
边栏推荐
- Huawei machine test questions summary
- - 4. Compare strings (10 points) the C language standard function library includes the StrCmp function for string comparison. As an exercise, we write a function with the same function.
- 面试官宁愿要刚刚毕业工作1年的我小弟,也不要工作5年的我,年薪25w
- How to install monitoring without network in rural areas, and what kind of monitoring without WiFi at home
- Gtid replication of MySQL master-slave replication
- 【数据库学习01】
- 手写链表~内含单向链表和双向链表,请大家放心食用
- Short link design and thinking
- Introduction to dynamic programming of leetcode learning plan day1,2 (4 questions in total)
- 转载:程序员的发展方向
猜你喜欢

MySQL主从复制之GTID复制

Displays the difference between an implementation interface and an implicit implementation interface

After working for three years as a programmer in a small 9K factory with a monthly salary, he finally won the byte offer he had been longing for for for for a long time in his spare time. The salary c

H. Maximal AND

L1-046 整除光棍
Ali Interviewer: you'd better not write glide on your resume. It's not as simple as asking for the source code

MySQL advanced trigger -- trigger introduction, trigger syntax and trigger case
Reprint: the development direction of programmers

基于PAOGD的角色动画基础设计

基于PAOGD_HW1的弹出的小球-简单建模、插值动画
随机推荐
CDH6. 3.2 enable Kerberos authentication
Virtual machine building and installation pulsar environment tutorial (for development and testing)
Children's organization and ideological education in Central China Normal University
SDF accelerate trace
2022年危险化学品经营单位安全管理人员上岗证题库及模拟考试
Is it safe for futures to open an account directly online?
Minio基本使用与原理
Can you really use MySQL explain?
基于GD32F1x0手动编程实现简易freertos之任务阻塞延时
How to make robots more like "people" and make slams more flexible?
CmsEasy7. 6.3.2 logic vulnerabilities
buuctf-[Flask]SSTI
MySQL learning notes
Redis's key and value best practices
Leetcode question brushing Diary - Sword finger offer II 070 Sort numbers that appear only once in the array
H. Maximal AND
C # convert ofd to PDF
编程实用工具,总有一个你用的上
Consul 的使用
Huawei machine test questions summary