Namespace stuck in terminating state
Quote from moshe on 25/07/2021, 9:54 amProblem
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
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: