Kubernetes namespace stuck in terminating status

Kubernetes namespace is stuck in terminating status.

This usually happens due to the finalizer

$ kubectl get ns
NAME             STATUS        AGE
cert-manager     Active        14d
custom-metrics   Terminating   7d
default          Active        222d
nfs-share        Active        15d
ingress-nginx    Active        103d
kube-public      Active        222d
kube-system      Active        222d
lb               Terminating   4d
monitoring       Terminating   6d
production       Active        221d

Solution 1:

This worked for me :

kubectl get namespace linkerd -o json > linkerd.json

Where:/api/v1/namespaces/<your_namespace_here>/finalize

kubectl replace --raw "/api/v1/namespaces/linkerd/finalize" -f ./linkerd.json