Namespaces may be stuck in a terminating state due to finalizers. Follow these steps to delete them.
- First, you need to retrieve the full definition of the stuck namespace in JSON format.
kubectl get namespace user-d7gnp -o json > user-d7gnp.json
- Edit the JSON to Remove Finalizers.
Before
{
"apiVersion": "v1",
"items": [
{
"apiVersion": "v1",
"kind": "Namespace",
"creationTimestamp": "2024-06-19T04:23:56Z",
"deletionTimestamp": "2025-07-23T13:25:02Z",
"finalizers": [
"controller.cattle.io/namespace-auth"
],
"labels": {
"kubernetes.io/metadata.name": "user-d7gnp"
},
After
{
"apiVersion": "v1",
"items": [
{
"apiVersion": "v1",
"kind": "Namespace",
"creationTimestamp": "2024-06-19T04:23:56Z",
"deletionTimestamp": "2025-07-23T13:25:02Z",
"labels": {
"kubernetes.io/metadata.name": "user-d7gnp"
},
- Apply the Modified JSON via kubectl replace.
kubectl replace --raw "/api/v1/namespaces/user-d7gnp/finalize" -f ./user-d7gnp.json
- Verify Deletion.
k get ns user-d7gnp