1、执行命令删除namespace后一直显示Terminating,无法删除namespace
[root@k8s-master1 ~]# kubectl get ns NAME STATUS AGE default Active 17d ingress-nginx Active 16d kube-node-lease Active 17d kube-public Active 17d kube-system Active 17d kubernetes-dashboard Active 16d monitoring Active 7d14h public-service Terminating 39h
2、获取需要强制删除的NameSpace信息,删除spec及status部分的内容还有metadata字段后的","号
kubectl get namespace public-service -o json > public-service.json
- 剩余内容大致如下
{ "apiVersion": "v1", "kind": "Namespace", "metadata": { "creationTimestamp": "2022-11-13T13:14:07Z", "deletionTimestamp": "2022-11-13T15:23:21Z", "labels": { "kubernetes.io/metadata.name": "public-service", "name": "public-service" }, "name": "public-service", "resourceVersion": "988435", "uid": "0bde65b7-757d-467f-9ed6-c2d76cbfdee5" } }
3、打开一个终端运行kube-proxy
[root@k8s-master1 ~]# kubectl proxy Starting to serve on 127.0.0.1:8001
4、通过API强制删除namespace
curl -k -H "Content-Type: application/json" -X PUT --data-binary @public-service.json http://127.0.0.1:8001/api/v1/namespaces/public-service/finalize
注:
1、@public-service.json:指的是强制删除NameSpace信息json名称
2、http://127.0.0.1:8001/api/v1/namespaces/public-service/finalize:
public-service:这里指的是NameSpace名称
5、通过API删除查看状态
[root@k8s-master1 ~]# kubectl get ns NAME STATUS AGE default Active 17d ingress-nginx Active 16d kube-node-lease Active 17d kube-public Active 17d kube-system Active 17d kubernetes-dashboard Active 16d monitoring Active 7d14h
标签:删除,service,kubernetes,17d,namespace,json,Active,kube,public From: https://www.cnblogs.com/albert919/p/16892075.html