Forum Navigation
You need to log in to create posts and topics.

Namespace stuck in terminating state

Problem

User wants to delete namespace and remove all resources. after the command kubectl delete <NAMESPACE>. namespace is not removed when examine kubectl get namespace

Solution 

run the following command to export namespace settings

kubectl get namespace <NAMESPACE> -o json > namespacee.json

edit the file and search for this lines

”spec”: {
“finalizers”: [
“kubernetes”
]
},

remove the word kubernetes from the text sample:

“spec”: {
”finalizers”: [
]
},

save the file and run the following command

kubectl replace –raw “/api/v1/namespaces/<NAMESPACE>/finalize” -f ./namespace.json

check that the name space has been removed

kubectl get namespace


 

Another Option

 

Run the following commands to remove the namespace

NAMESPACE=cert-manager
kubectl get namespace $NAMESPACE -o json > $NAMESPACE.json
sed -i -e ‘s/”kubernetes”//’ $NAMESPACE.json
kubectl replace –raw “/api/v1/namespaces/$NAMESPACE/finalize” -f ./$NAMESPACE.json

 

 

 

Uploaded files: