############################################################################################
当前 namespace: kubernetes-dashboard /monitoring 显示terminating 不能删除
[root@k8s1 ~]#
[root@k8s1 ~]# kubectl get ns
NAME STATUS AGE
ceph Active 15d
cephfs Active 7d3h
default Active 22d
kube-node-lease Active 22d
kube-public Active 22d
kube-system Active 22d
kube-util Active 16d
kubernetes-dashboard Terminating 21d
monitoring Terminating 20d
###############################################################################################
解决办法:
启动一个proxy 如8081端口
kubectl proxy跑一个API代理在本地的8081端口
[root@k8s1 ~]# nohup kubectl proxy --port=8081&
[root@k8s1 ~]# kubectl get namespace kubernetes-dashboard -o json |jq '.spec = {"finalizers":[]}' >temp.json
[root@k8s1 ~]# curl -k -H "Content-Type: application/json" -X PUT --data-binary @temp.json 127.0.0.1:8081/api/v1/namespaces/kubernetes-dashboard/finalize
[root@k8s1 ~]#
[root@k8s1 ~]#
[root@k8s1 ~]# kubectl get ns
NAME STATUS AGE
ceph Active 15d
cephfs Active 7d3h
default Active 22d
kube-node-lease Active 22d
kube-public Active 22d
kube-system Active 22d
kube-util Active 16d
monitoring Terminating 20d
[root@k8s1 ~]#
[root@k8s1 ~]#
[root@k8s1 ~]#
[root@k8s1 ~]#
[root@k8s1 ~]# kubectl get namespace monitoring -o json |jq '.spec = {"finalizers":[]}' >temp01.json
[root@k8s1 ~]# curl -k -H "Content-Type: application/json" -X PUT --data-binary @temp01.json 127.0.0.1:8081/api/v1/namespaces/monitoring/finalize
{
"kind": "Namespace",
"apiVersion": "v1",
"metadata": {
"name": "monitoring",
"selfLink": "/api/v1/namespaces/monitoring/finalize",
"uid": "ea316ed9-0c42-402b-b45d-aaa1bebafbf9",
"resourceVersion": "3997654",
"creationTimestamp": "2019-11-08T07:03:26Z",
"deletionTimestamp": "2019-11-28T07:28:43Z"
},
"spec": {
},
"status": {
"phase": "Terminating",
"conditions": [
{
"type": "NamespaceDeletionDiscoveryFailure",
"status": "True",
"lastTransitionTime": "2019-11-28T07:28:48Z",
"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": "2019-11-28T07:28:50Z",
"reason": "ParsedGroupVersions",
"message": "All legacy kube types successfully parsed"
},
{
"type": "NamespaceDeletionContentFailure",
"status": "False",
"lastTransitionTime": "2019-11-28T07:31:00Z",
"reason": "ContentDeleted",
"message": "All content successfully deleted"
}
]
}
}[root@k8s1 ~]#
[root@k8s1 ~]#
[root@k8s1 ~]# kubectl get ns
NAME STATUS AGE
ceph Active 15d
cephfs Active 7d3h
default Active 22d
kube-node-lease Active 22d
kube-public Active 22d
kube-system Active 22d
kube-util Active 16d
[root@k8s1 ~]#