kubernetes删除Namespace出现Terminating状态

527 阅读1分钟

namespace删除不了

[root@kubesphere ~]# kubectl get ns
NAME              STATUS        AGE
default           Active        3h
kube-node-lease   Active        3h
kube-public       Active        3h
kube-system       Active        3h
rbd-system        Terminating   108m

一直Terminating这个生态

查看原因

[root@kubesphere ~]# kubectl get ns rbd-system -o yaml
apiVersion: v1
kind: Namespace
metadata:
  creationTimestamp: "2022-03-16T03:46:10Z"
  deletionTimestamp: "2022-03-16T05:35:20Z"
  labels:
    kubernetes.io/metadata.name: rbd-system
  name: rbd-system
  resourceVersion: "13460"
  uid: fd9b7aa5-266c-4c6e-8d29-220b70d01b31
spec:
  finalizers:
  - kubernetes
status:
  conditions:
  - lastTransitionTime: "2022-03-16T05:35:25Z"
    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: "2022-03-16T05:35:27Z"
    message: All legacy kube types successfully parsed
    reason: ParsedGroupVersions
    status: "False"
    type: NamespaceDeletionGroupVersionParsingFailure
  - lastTransitionTime: "2022-03-16T05:36:50Z"
    message: All content successfully deleted, may be waiting on finalization
    reason: ContentDeleted
    status: "False"
    type: NamespaceDeletionContentFailure
  - lastTransitionTime: "2022-03-16T05:36:50Z"
    message: All content successfully removed
    reason: ContentRemoved
    status: "False"
    type: NamespaceContentRemaining
  - lastTransitionTime: "2022-03-16T05:35:27Z"
    message: All content-preserving finalizers finished
    reason: ContentHasNoFinalizers
    status: "False"
    type: NamespaceFinalizersRemaining
  phase: Terminating

# 1
kubectl proxy --port=8081

# 2 开启另外一个终端
cat <<EOF | curl -X PUT \
  localhost:8081/api/v1/namespaces/rbd-system/finalize \
  -H "Content-Type: application/json" \
  --data-binary @-
{
  "kind": "Namespace",
  "apiVersion": "v1",
  "metadata": {
    "name": "rbd-system"
  },
  "spec": {
    "finalizers": null
  }
}
EOF

rbd-system替换成需要删除的namespace

结果

[root@kubesphere ~]# kubectl get ns
NAME              STATUS   AGE
default           Active   3h1m
kube-node-lease   Active   3h1m
kube-public       Active   3h1m
kube-system       Active   3h1m