#建议不要直接删除名称空间,先删除名称空间里面的资源
1. 获取命名空间的资源: 查看该命名空间下的资源:
kubectl get all -n system
2. 强制删除命名空间: 使用以下命令强制删除命名空间及其资源:
kubectl delete namespace system --grace-period=0 --force
3. 检查删除状态: 再次检查命名空间状态:
kubectl get namespaces
如果以上方法删除了还有残留的话接下往下看
[root@master01 ~]# kubectl delete namespace system --grace-period=0 --force
Warning: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely.
namespace "system" force deleted
还有是删除不了的话最后的绝招!
先在一个终端执行命令:
直接修改 finalizers: 尝试直接通过 API 删除 finalizers: 启动 kubectl proxy:
kubectl proxy
然后再开一个终端执行下面的删除命令
curl -X PUT http://localhost:8001/api/v1/namespaces/system/finalize -H "Content-Type: application/json" -d '{"kind":"Namespace","apiVersion":"v1","metadata":{"name":"system","finalizers":[]}}'
curl -X PUT http://localhost:8001/api/v1/namespaces/monitoring/finalize -H "Content-Type: application/json" -d '{"kind":"Namespace","apiVersion":"v1","metadata":{"name":"monitoring","finalizers":[]}}'
curl -X PUT http://localhost:8001/api/v1/namespaces/mysqlcluster-operator-system/finalize -H "Content-Type: application/json" -d '{"kind":"Namespace","apiVersion":"v1","metadata":{"name":"mysqlcluster-operator-system","finalizers":[]}}'
评论 (0)