Namespace 删除提示 Terminating

删除 Namespace,一直处于 Terminating,删除 metadata.finalizers 即可解决。

1. 无法删除 Namespace

# kubectl get ns/monitoring
NAME                           STATUS        AGE
monitoring                     Terminating   7d23h
1
2
3

删除失效后,启用强制删除;

# kubectl delete ns/monitoring --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.
namespace "monitoring" force deleted
1
2
3

但还是无效

于是参照网上的建议,删除 metadata.finalizers,问题解决。

# kubectl edit ns/monitoring
apiVersion: v1
kind: Namespace
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
    lifecycle.cattle.io/create.namespace-auth: "true"
  creationTimestamp: 2019-08-22T07:29:35Z
  deletionGracePeriodSeconds: 0
  deletionTimestamp: 2019-08-30T06:46:08Z
  finalizers:
  - controller.cattle.io/namespace-auth  ## 删除改行
  name: monitoring
spec: {}
status:
  phase: Terminating
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

reference