删除
查看Terminating 状态
[root@master01 dashboard]# kubectl get ns|grep kubernetes-dashboard kubernetes-dashboard Terminating 26h kubernetes-dashboard-head Terminating 5h57m
[root@master01 dashboard]# kubectl get ns kubernetes-dashboard -o yaml
apiVersion: v1
kind: Namespace
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"v1","kind":"Namespace","metadata":{"annotations":{},"name":"kubernetes-dashboard"}}
creationTimestamp: "2020-01-20T06:25:38Z"
deletionTimestamp: "2020-01-21T06:18:30Z"
name: kubernetes-dashboard
resourceVersion: "208494"
selfLink: /api/v1/namespaces/kubernetes-dashboard
uid: 77cae2ea-b0bd-48a3-8070-29e5d56573f5
spec:
finalizers:
- kubernetes
status:
conditions:
- lastTransitionTime: "2020-01-21T06:18:35Z"
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-01-21T06:18:37Z"
message: All legacy kube types successfully parsed
reason: ParsedGroupVersions
status: "False"
type: NamespaceDeletionGroupVersionParsingFailure
- lastTransitionTime: "2020-01-21T06:18:37Z"
message: All content successfully deleted
reason: ContentDeleted
status: "False"
type: NamespaceDeletionContentFailure
phase: Terminating
查看详情
error: unable to retrieve the complete list of server APIs: metrics.k8s.io/v1beta1: the server is currently unable to handle the request
[root@master01 dashboard]# kubectl delete apiservice v1beta1.metrics.k8s.io apiservice.apiregistration.k8s.io "v1beta1.metrics.k8s.io" deleted
# 查看k8s集群中可以使用命名空间隔离的资源
[root@master01 dashboard]# kubectl api-resources -o name --verbs=list --namespaced | xargs -n 1 kubectl get --show-kind --ignore-not-found -n kubernetes-dashboard [root@master01 dashboard]#
发现并没有
第一种方式:
[root@master01 dashboard]# kubectl delete ns kubernetes-dashboard Error from server (Conflict): Operation cannot be fulfilled on namespaces "kubernetes-dashboard": The system is ensuring all content is removed from this namespace. Upon completion, this namespace will automatically be purged by the system.
第二种
# 使用强制删除(依然无法删除该命名空间)
[root@master01 dashboard]# kubectl delete ns kubernetes-dashboard --force --grace-period=0 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. Error from server (NotFound): namespaces "kubernetes-dashboard" not found
使用原生接口删除
# 获取namespace的详情信息
[root@master01 dashboard]# kubectl get ns kubernetes-dashboard -o json > kubernetes-dashboard.json [root@master01 dashboard]# cat kubernetes-dashboard.json { "apiVersion": "v1", "kind": "Namespace", "metadata": { "annotations": { "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"v1\",\"kind\":\"Namespace\",\"metadata\":{\"annotations\":{},\"name\":\"kubernetes-dashboard\"}}\n" }, "creationTimestamp": "2020-01-20T06:25:38Z", "deletionTimestamp": "2020-01-21T06:18:30Z", "name": "kubernetes-dashboard", "resourceVersion": "208494", "selfLink": "/api/v1/namespaces/kubernetes-dashboard", "uid": "77cae2ea-b0bd-48a3-8070-29e5d56573f5" }, "spec": { "finalizers": [ "kubernetes" ] }, "status": { "conditions": [ { "lastTransitionTime": "2020-01-21T06:18:35Z", "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-01-21T06:18:37Z", "message": "All legacy kube types successfully parsed", "reason": "ParsedGroupVersions", "status": "False", "type": "NamespaceDeletionGroupVersionParsingFailure" }, { "lastTransitionTime": "2020-01-21T06:18:37Z", "message": "All content successfully deleted", "reason": "ContentDeleted", "status": "False", "type": "NamespaceDeletionContentFailure" } ], "phase": "Terminating" } }
参考了 https://juejin.im/post/5dada0bc5188253b2f003eff 这个