2020久久超碰欧美精品最新亚洲欧美日韩久久精品,国产福利电影一区二区三区,亚洲欧美日韩一区在线观看,亚洲国产欧美日韩欧美特级,亚洲欧美日韩成人一区久久,欧美日韩精品一区二区三区不卡,国产欧美日韩va另类影音先锋,亚洲欧美日韩久久精品,亚洲欧美日韩国产成人精品影院,亚洲国产欧美日韩精品一区二区三区,欧美日韩国产成人高清视频,日韩久久精品国产免费观看频道,久久人人爽人人爽从片av高清,国产精品综合一区二区

首頁技術文章正文

使用kubernetes中,無法刪除NameSpace怎么處理?

更新時間:2020-04-04 來源:黑馬程序員 瀏覽量:

在使用kubernetes過程中,我們經常會遇到無法刪除NameSpace的情況,但是如果一一去刪除NameSpace中資源比較麻煩。下面我們給大家介紹強制刪除NameSpace的方法。推薦了解linux云計算+運維開發課程。

一、查看已存在的NameSpace

[root@master1 ~]# kubectl get ns
NAME              STATUS        AGE
default           Active        56d
ingress-nginx     Active        49d
istio-system      Terminating   37d
kube-node-lease   Active        56d
kube-public       Active        56d
kube-system       Active        56d


二、獲取需要強制刪除的NameSpace信息



[root@master1 ~]# kubectl get namespace istio-system -o json > istio-system.json
[root@master1 ~]# cat istio-system.json
{
    "apiVersion": "v1",
    "kind": "Namespace",
    "metadata": {
        "annotations": {
            "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"v1\",\"kind\":\"Namespace\",\"metadata\":{\"annotations\":{},\"labels\":{\"istio-injection\":\"disabled\",\"istio-operator-managed\":\"Reconcile\",\"operator.istio.io/component\":\"Base\",\"operator.istio.io/managed\":\"Reconcile\",\"operator.istio.io/version\":\"1.4.3\"},\"name\":\"istio-system\"}}\n"
        },
        "creationTimestamp": "2020-01-27T15:26:48Z",
        "deletionTimestamp": "2020-02-15T01:17:05Z",
        "labels": {
            "istio-injection": "disabled",
            "istio-operator-managed": "Reconcile",
            "operator.istio.io/component": "Base",
            "operator.istio.io/managed": "Reconcile",
            "operator.istio.io/version": "1.4.3"
        },
        "name": "istio-system",
        "resourceVersion": "6024170",
        "selfLink": "/api/v1/namespaces/istio-system",
        "uid": "d8bdc915-ee6f-43cd-ac37-5e353218095f"
    },
    "spec": {
        "finalizers": [
            "kubernetes"
        ]
    },
    "status": {
        "conditions": [
            {
                "lastTransitionTime": "2020-02-15T01:17:10Z",
                "message": "Discovery failed for some groups, 1 failing: unable to retrieve the complete list of server APIs: metrics.k8s.io/v1beta1: the server is currently unable to handle the request",
                "reason": "DiscoveryFailed",
                "status": "True",
                "type": "NamespaceDeletionDiscoveryFailure"
            },
            {
                "lastTransitionTime": "2020-02-15T01:17:13Z",
                "message": "All legacy kube types successfully parsed",
                "reason": "ParsedGroupVersions",
                "status": "False",
                "type": "NamespaceDeletionGroupVersionParsingFailure"
            },
            {
                "lastTransitionTime": "2020-02-15T01:17:13Z",
                "message": "All content successfully deleted, may be waiting on finalization",
                "reason": "ContentDeleted",
                "status": "False",
                "type": "NamespaceDeletionContentFailure"
            },
            {
                "lastTransitionTime": "2020-02-15T01:17:40Z",
                "message": "All content successfully removed",
                "reason": "ContentRemoved",
                "status": "False",
                "type": "NamespaceContentRemaining"
            },
            {
                "lastTransitionTime": "2020-02-15T01:17:13Z",
                "message": "All content-preserving finalizers finished",
                "reason": "ContentHasNoFinalizers",
                "status": "False",
                "type": "NamespaceFinalizersRemaining"
            }
        ],
        "phase": "Terminating"
    }
}


三、修改已獲取的NameSpace信息文件
namespace小技巧

[root@master1 ~]# cat istio-system.json
{
    "apiVersion": "v1",
    "kind": "Namespace",
    "metadata": {
        "annotations": {
            "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"v1\",\"kind\":\"Namespace\",\"metadata\":{\"annotations\":{},\"labels\":{\"istio-injection\":\"disabled\",\"istio-operator-managed\":\"Reconcile\",\"operator.istio.io/component\":\"Base\",\"operator.istio.io/managed\":\"Reconcile\",\"operator.istio.io/version\":\"1.4.3\"},\"name\":\"istio-system\"}}\n"
        },
        "creationTimestamp": "2020-01-27T15:26:48Z",
        "deletionTimestamp": "2020-02-15T01:17:05Z",
        "labels": {
            "istio-injection": "disabled",
            "istio-operator-managed": "Reconcile",
            "operator.istio.io/component": "Base",
            "operator.istio.io/managed": "Reconcile",
            "operator.istio.io/version": "1.4.3"
        },
        "name": "istio-system",
        "resourceVersion": "6024170",
        "selfLink": "/api/v1/namespaces/istio-system",
        "uid": "d8bdc915-ee6f-43cd-ac37-5e353218095f"
    },
    "spec": {
    },
    "status": {
        "conditions": [
            {
                "lastTransitionTime": "2020-02-15T01:17:10Z",
                "message": "Discovery failed for some groups, 1 failing: unable to retrieve the complete list of server APIs: metrics.k8s.io/v1beta1: the server is currently unable to handle the request",
                "reason": "DiscoveryFailed",
                "status": "True",
                "type": "NamespaceDeletionDiscoveryFailure"
            },
            {
                "lastTransitionTime": "2020-02-15T01:17:13Z",
                "message": "All legacy kube types successfully parsed",
                "reason": "ParsedGroupVersions",
                "status": "False",
                "type": "NamespaceDeletionGroupVersionParsingFailure"
            },
            {
                "lastTransitionTime": "2020-02-15T01:17:13Z",
                "message": "All content successfully deleted, may be waiting on finalization",
                "reason": "ContentDeleted",
                "status": "False",
                "type": "NamespaceDeletionContentFailure"
            },
            {
                "lastTransitionTime": "2020-02-15T01:17:40Z",
                "message": "All content successfully removed",
                "reason": "ContentRemoved",
                "status": "False",
                "type": "NamespaceContentRemaining"
            },
            {
                "lastTransitionTime": "2020-02-15T01:17:13Z",
                "message": "All content-preserving finalizers finished",
                "reason": "ContentHasNoFinalizers",
                "status": "False",
                "type": "NamespaceFinalizersRemaining"
            }
        ],
        "phase": "Terminating"
    }
}

四、運行kube-proxy
[root@master1 ~]# kubectl proxy
Starting to serve on 127.0.0.1:8001


五、通過API執行強制刪除操作
[root@master1 ~]# curl -k -H "Content-Type: application/json" -X PUT --data-binary @istio-system.json http://127.0.0.1:8001/api/v1/namespaces/istio-system/finalize

六、強制刪除確認
[root@master1 ~]# kubectl get ns
NAME              STATUS        AGE
default           Active        56d
ingress-nginx     Active        49d
kube-node-lease   Active        56d
kube-public       Active       56d
kube-system       Active        56d



猜你喜歡

Linux基礎教程:linux常用命令入門

分享到:
在線咨詢 我要報名
和我們在線交談!