A Namespace Is Stuck in the Terminating State — Jevic

A Namespace Is Stuck in the Terminating State

2020/05/23 Kubernetes
    1. Run the following command to view the namespaces that are stuck in the Terminating state:
# kubectl get ns|grep Terminating
cattle-prometheus      Terminating   406d
    1. Select a terminating namespace and view the contents of the namespace to find out the finalizer. Run the following command:
# kubectl get ns cattle-prometheus -o yaml
apiVersion: v1
kind: Namespace
metadata:
  annotations:
    cattle.io/appIds: cluster-monitoring,monitoring-operator
    cattle.io/status: '{"Conditions":[{"Type":"ResourceQuotaInit","Status":"True","Message":"","LastUpdateTime":"2019-05-09T06:34:14Z"},{"Type":"InitialRolesPopulated","Status":"True","Message":"","LastUpdateTime":"2019-05-09T06:34:19Z"}]}'
    field.cattle.io/projectId: c-s2zlj:p-kw9lj
    lifecycle.cattle.io/create.namespace-auth: "true"
  creationTimestamp: "2019-05-09T06:34:13Z"
  deletionGracePeriodSeconds: 0
  deletionTimestamp: "2019-11-13T02:50:20Z"
  finalizers:
  - controller.cattle.io/namespace-auth
  labels:
    cattle.io/creator: norman
    field.cattle.io/projectId: p-kw9lj
  name: cattle-prometheus
  resourceVersion: "39020658"
  selfLink: /api/v1/namespaces/cattle-prometheus
  uid: 75c9cd36-7224-11e9-9de0-e23029de4489
spec: {}
status:
  phase: Terminating
    1. Run the following command remove finalizers config Delete the following two lines of configuration save exit
# kubectl edit ns cattle-prometheus
.... 
finalizers:
  - controller.cattle.io/namespace-auth
....
    1. Finally, execute the delete command again
kubectl delete ns cattle-prometheus

Cause analysis

Finalizers is an asynchronous pre delete hook commonly used by operators of kubernetes. When this resource is deleted, it needs to be cleaned up by the program that created the resource before deletion. After cleaning up, it needs to remove the identifier from the finalizers of the resource, and then the resource will be completely deleted

Search

    Post Directory