- Published on
When Raspberry PI 4 k3s Kubernetes delete namespace gets stuck
- Authors

- Name
- Youngju Kim
- @fjvbn20031
Overview
Learn how to resolve the issue when delete namespace gets stuck in Raspberry PI 4 k3s Kubernetes.
Kubernetes Namespaces have Finalizers, which is a feature that prevents resources from being hard deleted.
For example, this occurs when you try to hard delete a running Namespace such as monitoring with kubectl delete ns monitoring, and the Namespace you attempted to delete will remain stuck in a Terminating state.
$ sudo kubectl get namespace
NAME STATUS AGE
default Active 2d22h
kube-system Active 2d22h
kube-public Active 2d22h
kube-node-lease Active 2d22h
kubernetes-dashboard Active 2d21h
monitoring Terminating 6m51s
How?
NameSpace Edit
Extract the information about the monitoring namespace to tmp.json using the command below.
$ sudo kubectl get ns monitoring -o json > tmp.json
Then open tmp.json and modify the finalizers under spec to an empty array as shown below.
"spec": {
"finalizers": []
}
apply
Open a new terminal and start a kubectl proxy server.
$ sudo kubectl proxy
Apply the modified tmp.json to the namespace using the curl command below.
$ curl -k -H "Content-Type: application/json" -X PUT --data-binary @tmp.json http://127.0.0.1:8001/api/v1/namespaces/monitoring/finalize
Result
If you check the namespaces with the command below, you can confirm that the monitoring namespace has been successfully deleted.
$ sudo kubectl get ns
NAME STATUS AGE
default Active 2d22h
kube-system Active 2d22h
kube-public Active 2d22h
kube-node-lease Active 2d22h
kubernetes-dashboard Active 2d21hgit
Reference
Quiz
Q1: What is the main topic covered in "When Raspberry PI 4 k3s Kubernetes delete namespace gets
stuck"?
Learn how to resolve the issue when delete namespace gets stuck in Raspberry PI 4 k3s Kubernetes.
Q2: What is NameSpace Edit?
Extract the information about the monitoring namespace to tmp.json using the command below. Then
open tmp.json and modify the finalizers under spec to an empty array as shown below.
Q3: Explain the core concept of apply.
Open a new terminal and start a kubectl proxy server. Apply the modified tmp.json to the namespace
using the curl command below. Result If you check the namespaces with the command below, you can
confirm that the monitoring namespace has been successfully deleted.