# 强制删除Terminating的ns

本文主要介绍了在使用k8s的过程中Terminating的ns无法删除，如何强制删除Terminating的ns。

## kubectl get ns 查看处于Terminating的ns

```
[root@VM_1_4_centos ~]# kubectl get ns | grep testns
testns                   Terminating   21d
```

## 将处于Terminating的ns的描述文件保存下来

```
[root@VM_1_4_centos ~]# kubectl get ns testns -o json > tmp.json
[root@VM_1_4_centos ~]# cat tmp.json 
{
    "apiVersion": "v1",
    "kind": "Namespace",
    "metadata": {
        "creationTimestamp": "2020-10-13T14:28:07Z",
        "name": "testns",
        "resourceVersion": "13782744400",
        "selfLink": "/api/v1/namespaces/testns",
        "uid": "9ff63d71-a4a1-43bc-89e3-78bf29788844"
    },
    "spec": {
        "finalizers": [
            "kubernetes"
        ]
    },
    "status": {
        "phase": "Terminating"
    }
}
```

## 本地启动kube proxy

```
kubectl proxy --port=8081
```

## 新开窗口执行删除操作

```
curl -k -H "Content-Type: application/json" -X PUT --data-binary @tmp.json http://127.0.0.1:8081/api/v1/namespaces/testns/finalize
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.niewx.cn/20201015-qiang-zhi-shan-chu-terminating-de-ns.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
