{"id":640,"date":"2020-09-04T21:43:20","date_gmt":"2020-09-04T13:43:20","guid":{"rendered":"https:\/\/www.myway5.com\/?p=640"},"modified":"2023-07-05T21:24:57","modified_gmt":"2023-07-05T13:24:57","slug":"k8s-namespace-deletion","status":"publish","type":"post","link":"https:\/\/www.myway5.com\/index.php\/2020\/09\/04\/k8s-namespace-deletion\/","title":{"rendered":"k8s \u4e2d\u5220\u9664 namespace \u65f6\u53d1\u751f\u4e86\u4ec0\u4e48"},"content":{"rendered":"<h2>\u4e00\u3001\u6982\u8ff0<\/h2>\n<p>namespace \u662f kubernetes \u4e2d\u4e00\u4e2a\u6bd4\u8f83\u91cd\u8981\u7684\u6982\u5ff5\uff0c\u662f\u5bf9\u4e00\u7ec4\u8d44\u6e90\u548c\u5bf9\u8c61\u7684\u62bd\u8c61\uff0c\u4e5f\u5e38\u7528\u6765\u4f5c\u4e0d\u540c\u7528\u6237\u7684\u9694\u79bb\u3002namespace \u4e0b\u6709\u5f88\u591a\u8d44\u6e90\uff0c\u6bd4\u5982\u6211\u4eec\u5e38\u7528\u7684 deployment, pods, service, ingress, configmap \u7b49\u7b49\u3002<\/p>\n<p>\u5f53\u7136\u672c\u7bc7\u6587\u7ae0\u7684\u91cd\u70b9\u5728\u4e8e\u5220\u9664 namespace \u65f6\u53d1\u751f\u4e86\u4ec0\u4e48\uff1f\u4e00\u4e2a\u5f88\u5178\u578b\u7684\u573a\u666f\u662f\u5728\u7ec8\u7aef\u4e2d\u6267\u884c <code>kubectl delete ns test<\/code> \u65f6\uff0c\u6211\u4eec\u4f1a\u89c2\u5bdf\u5230\uff0c\u5728\u6267\u884c\u547d\u4ee4\u540e\uff0ctest \u547d\u540d\u7a7a\u95f4\u4f1a\u7acb\u523b\u8fdb\u5165 terminating \u72b6\u6001\uff0c\u5728\u51e0\u79d2\u949f\u4e4b\u540e\uff0c\u624d\u4f1a\u88ab\u771f\u6b63\u5220\u9664\u3002\u5373\u4f7f test \u547d\u540d\u7a7a\u95f4\u4e2d\u6ca1\u6709\u4efb\u4f55\u8d44\u6e90\u3002<\/p>\n<pre><code class=\"language-shell line-numbers\">NAME              STATUS   AGE\ndefault           Active   2d2h\ndocker            Active   2d2h\nkube-node-lease   Active   2d2h\nkube-public       Active   2d2h\nkube-system       Active   2d2h\ntest              Active   4s\ntest              Terminating   18s\ntest              Terminating   23s\ntest              Terminating   23s\n<\/code><\/pre>\n<p>\u56e0\u6b64\uff0c\u6211\u4eec\u5728\u4e0b\u9762\u4f1a\u63a2\u7a76\u4ee5\u4e0b\u51e0\u70b9\uff1a<\/p>\n<ul>\n<li>api-server \u5982\u4f55\u5904\u7406 namespace \u7684\u5220\u9664\u8bf7\u6c42<\/li>\n<li>\u5220\u9664 namespace \u65f6\u5982\u4f55\u5904\u7406\u5176\u4e2d\u7684\u8d44\u6e90<\/li>\n<\/ul>\n<h2>\u4e8c\u3001api server \u5982\u4f55\u5904\u7406 namespace \u5220\u9664\u8bf7\u6c42<\/h2>\n<p>\u548c\u5176\u4ed6\u8d44\u6e90\u4e0d\u540c\uff0cnamespace \u5728\u5220\u9664\u65f6\uff0c\u9700\u8981\u5148\u6e05\u7a7a namespace \u4e0b\u8d44\u6e90\u3002\u56e0\u6b64 namespace \u6709\u4e24\u79cd\u72b6\u6001\uff0c\u5373 active \u548c terminating\u3002\u5f53 namespace \u5904\u4e8e terminating \u65f6\uff0c\u8bf4\u660e\u5176\u4e0b\u7684\u8d44\u6e90\u8fd8\u6ca1\u6709\u88ab\u786e\u8ba4\u5220\u9664\u5e72\u51c0\u3002\u56e0\u6b64\uff0capi-server \u5728\u6536\u5230 namespace \u7684\u5220\u9664\u8bf7\u6c42\u65f6\uff0c\u5e76\u4e0d\u4f1a\u7acb\u523b\u5c06\u5176\u4ece etcd \u4e2d\u5220\u9664\uff0c\u800c\u662f\u5148\u68c0\u67e5 metadata.DeletionTimestamp \u662f\u5426\u4e3a\u7a7a\uff0c\u5982\u679c\u4e3a\u7a7a\uff0c\u5219\u662f\u5148\u5c06 metadata.DeletionTimestamp \u7f6e\u4e3a\u5f53\u524d\u65f6\u95f4\uff0c\u7136\u540e\u5c06 status.Phase \u7f6e\u4e3a terminating\u3002\u5982\u679c metadata.DeletionTimestamp \u4e0d\u4e3a\u7a7a\uff0c\u8fd8\u8981\u518d\u5224\u65ad spec.Finalizers \u662f\u5426\u4e3a\u7a7a\u3002\u5982\u679c\u4e3a\u7a7a\uff0c\u624d\u4f1a\u771f\u6b63\u7684\u5220\u9664\u8be5 namespace\u3002<\/p>\n<p>\u8fd9\u6837\u7684\u5904\u7406\u65b9\u5f0f\uff0c\u5c31\u4fdd\u8bc1\u4e86\u5728 spec.Finalizers \u4e0d\u4e3a\u7a7a\u65f6\uff0cnamespace \u4e0d\u4f1a\u88ab\u5220\u9664\u3002\u90a3\u4e48 finalizer \u662f\u5728\u4ec0\u4e48\u65f6\u5019\u6dfb\u52a0\u7684\u5462\uff1f\u5177\u4f53\u7684\u4f5c\u7528\u662f\u600e\u4e48\u4f53\u73b0\u7684\uff1f<\/p>\n<h2>\u4e09\u3001finalizer \u673a\u5236<\/h2>\n<p>namespace \u7684 finalizer \u5176\u5b9e\u5728\u521b\u5efa\u7684\u65f6\u5019\u5c31\u5df2\u7ecf\u6dfb\u52a0\u4e0a\u53bb\u4e86\u3002\u5904\u7406\u903b\u8f91\u53ef\u89c1\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre><code class=\"language-go line-numbers\">\/\/ PrepareForCreate clears fields that are not allowed to be set by end users on creation.\nfunc (namespaceStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {\n    \/\/ on create, status is active\n    namespace := obj.(*api.Namespace)\n    namespace.Status = api.NamespaceStatus{\n        Phase: api.NamespaceActive,\n    }\n    \/\/ on create, we require the kubernetes value\n    \/\/ we cannot use this in defaults conversion because we let it get removed over life of object\n    hasKubeFinalizer := false\n    for i := range namespace.Spec.Finalizers {\n        if namespace.Spec.Finalizers[i] == api.FinalizerKubernetes {\n            hasKubeFinalizer = true\n            break\n        }\n    }\n    if !hasKubeFinalizer {\n        if len(namespace.Spec.Finalizers) == 0 {\n            namespace.Spec.Finalizers = []api.FinalizerName{api.FinalizerKubernetes}\n        } else {\n            namespace.Spec.Finalizers = append(namespace.Spec.Finalizers, api.FinalizerKubernetes)\n        }\n    }\n}\n<\/code><\/pre>\n<p>\u7136\u540e\u5728\u5220\u9664\u65f6 namespace \u53d8\u66f4\u5230 terminating \u72b6\u6001\uff0cnamespace controller \u5c31\u5f00\u59cb\u53d1\u6325\u4f5c\u7528\u4e86\u3002namespace controller \u5c5e\u4e8e controller manager\uff0c\u5176\u4f1a\u76d1\u542c namespace \u7684 add \u548c update \u4e8b\u4ef6<\/p>\n<pre><code class=\"language-go line-numbers\">    \/\/ configure the namespace informer event handlers\n    namespaceInformer.Informer().AddEventHandlerWithResyncPeriod(\n        cache.ResourceEventHandlerFuncs{\n            AddFunc: func(obj interface{}) {\n                namespace := obj.(*v1.Namespace)\n                namespaceController.enqueueNamespace(namespace)\n            },\n            UpdateFunc: func(oldObj, newObj interface{}) {\n                namespace := newObj.(*v1.Namespace)\n                namespaceController.enqueueNamespace(namespace)\n            },\n        },\n        resyncPeriod,\n    )\n<\/code><\/pre>\n<p>\u5e76\u4e14\u4f1a\u4f7f\u7528 workqueue \u6765\u4fdd\u5b58\u6bcf\u4e00\u4e2a namespace \u7684\u53d8\u5316\u4e8b\u4ef6\u3002\u7136\u540e\u7edf\u7edf\u89e6\u53d1 <code>nm.namespacedResourcesDeleter.Delete(namespace.Name)<\/code>\u3002\u5f53\u7136\uff0c\u5982\u679c namespace \u4e0d\u5b58\u5728\u6216\u8005 namespace.DeletionTimestamp \u4e3a\u7a7a\uff0c\u5219\u4f1a\u9000\u51fa\uff1a<\/p>\n<pre><code class=\"language-go line-numbers\">    namespace, err := d.nsClient.Get(context.TODO(), nsName, metav1.GetOptions{})\n    if err != nil {\n        if errors.IsNotFound(err) {\n            return nil\n        }\n        return err\n    }\n    if namespace.DeletionTimestamp == nil {\n        return nil\n    }\n<\/code><\/pre>\n<p>\u5426\u5219\u65e0\u8bba\u5982\u4f55\u90fd\u4f1a\u5148\u5c06 namespace \u7684 phase \u5148\u7f6e\u4e3a terminating\u3002\u8fd9\u4e5f\u5c31\u662f\u8bf4\uff0c\u5982\u679c\u4e00\u4e2a namespace \u5df2\u7ecf\u5904\u4e8e terminating \u4e86\uff0c\u4f60\u5c31\u65e0\u6cd5\u901a\u8fc7\u4ec5\u4ec5\u4fee\u6539\u8be5 phase \u6765\u6539\u53d8\u8be5 namespace \u7684\u72b6\u6001\u3002\u6211\u4e4b\u524d\u5728\u9047\u5230\u8fc7 namespace \u4e00\u76f4\u5904\u4e8e terminating \u65f6\uff0c\u624b\u52a8\u4fee\u6539\u4e86 phase \u4e3a active\uff0c\u4f46\u662f namespace \u4f1a\u7acb\u523b\u53d8\u4e3a terminating\uff0c\u539f\u56e0\u5927\u6982\u5c31\u662f\u5982\u6b64\u4e86\u3002<\/p>\n<pre><code class=\"language-go line-numbers\">\/\/ updateNamespaceStatusFunc will verify that the status of the namespace is correct\nfunc (d *namespacedResourcesDeleter) updateNamespaceStatusFunc(namespace *v1.Namespace) (*v1.Namespace, error) {\n    if namespace.DeletionTimestamp.IsZero() || namespace.Status.Phase == v1.NamespaceTerminating {\n        return namespace, nil\n    }\n    newNamespace := v1.Namespace{}\n    newNamespace.ObjectMeta = namespace.ObjectMeta\n    newNamespace.Status = *namespace.Status.DeepCopy()\n    newNamespace.Status.Phase = v1.NamespaceTerminating\n    return d.nsClient.UpdateStatus(context.TODO(), &amp;newNamespace, metav1.UpdateOptions{})\n}\n<\/code><\/pre>\n<p>\u4e4b\u540e\u5c31\u5f00\u59cb\u5c1d\u8bd5\u6e05\u7a7a\u8be5 namespace \u4e0b\u7684\u6240\u6709\u5185\u5bb9\uff1a<\/p>\n<pre><code class=\"language-go line-numbers\">    \/\/ there may still be content for us to remove\n    estimate, err := d.deleteAllContent(namespace)\n    if err != nil {\n        return err\n    }\n    if estimate &gt; 0 {\n        return &amp;ResourcesRemainingError{estimate}\n    }\n<\/code><\/pre>\n<h2>\u56db\u3001DiscoveryInterface \u7684\u5de5\u4f5c\u673a\u5236<\/h2>\n<p>\u73b0\u5728\u6211\u4eec\u9762\u4e34\u7684\u4e00\u4e2a\u95ee\u9898\u5c31\u662f\u5982\u4f55\u6e05\u7406\u8be5 namespace \u4e0b\u7684\u6240\u6709\u8d44\u6e90\u5462\uff1f\u5e73\u65f6\u5982\u679c\u6211\u4eec\u8981\u5220\u9664\u4e00\u4e2a pod\uff0c\u6211\u4eec\u53ef\u4ee5\u8c03\u7528 client-go \u63d0\u4f9b\u7684 PodInterface \u63a5\u53e3\u6765\u5220\u9664\uff0c\u5176\u5b9e\u5c31\u662f RESTful \u7684 HTTP DELETE \u52a8\u4f5c\u7684\u5c01\u88c5\u3002\u4f46\u662f\u73b0\u5728\u56e0\u4e3a\u6211\u4eec\u4e0d\u77e5\u9053 namespace \u4e0b\u6709\u54ea\u4e9b\u8d44\u6e90\uff0c\u6240\u4ee5\u5c31\u6ca1\u6709\u529e\u6cd5\u76f4\u63a5\u8c03\u7528\u5220\u9664\u7684\u63a5\u53e3\u3002<\/p>\n<p>\u6240\u4ee5 client-go \u8fd8\u63d0\u4f9b\u4e86\u4e00\u4e2a  DiscoveryInterface\uff0c\u987e\u540d\u601d\u4e49\uff0cDicoveryInterface \u53ef\u4ee5\u7528\u6765\u53d1\u73b0\u96c6\u7fa4\u4e2d\u7684 API groups\uff0cversions, resources\u3002\u5728\u53d6\u5f97\u96c6\u7fa4\u4e2d\u6240\u6709\u7684\u63a5\u53e3\u8d44\u6e90\u5217\u8868\u53e3\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u5bf9\u8fd9\u4e9b\u8d44\u6e90\u8fdb\u884c\u67e5\u8be2\u548c\u5220\u9664\u4e86\u3002DicoveryInterface \u63a5\u53e3\u5982\u4e0b:<\/p>\n<pre><code class=\"language-go line-numbers\">\/\/ DiscoveryInterface holds the methods that discover server-supported API groups,\n\/\/ versions and resources.\ntype DiscoveryInterface interface {\n    RESTClient() restclient.Interface\n    ServerGroupsInterface\n    ServerResourcesInterface\n    ServerVersionInterface\n    OpenAPISchemaInterface\n}\n<\/code><\/pre>\n<p>\u5176\u4e2d ServerGroupInterface \u63d0\u4f9b\u4e86\u83b7\u53d6\u96c6\u7fa4\u4e2d\u6240\u6709\u63a5\u53e3\u7ec4\u7684\u80fd\u529b\uff0c\u5177\u4f53\u7684\u51fd\u6570\u7b7e\u540d\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-go line-numbers\">    \/\/ ServerGroups returns the supported groups, with information like supported versions and the\n    \/\/ preferred version.\n    ServerGroups() (*metav1.APIGroupList, error)\n<\/code><\/pre>\n<p>ServerVersionInterface \u53ef\u4ee5\u7528\u6765\u83b7\u53d6\u670d\u52a1\u7684\u7248\u672c\u4fe1\u606f\uff0c\u5177\u4f53\u7684\u51fd\u6570\u7b7e\u540d\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-go line-numbers\">    \/\/ ServerVersion retrieves and parses the server's version (git version).\n    ServerVersion() (*version.Info, error)\n<\/code><\/pre>\n<p>\u7136\u540e\u6211\u4eec\u9700\u8981\u5173\u6ce8\u7684\u662f ServerResourcesInterface \u8fd9\u4e2a\u63a5\u53e3<\/p>\n<pre><code class=\"language-go line-numbers\">\/\/ ServerResourcesInterface has methods for obtaining supported resources on the API server\ntype ServerResourcesInterface interface {\n    \/\/ ServerResourcesForGroupVersion returns the supported resources for a group and version.\n    ServerResourcesForGroupVersion(groupVersion string) (*metav1.APIResourceList, error)\n    \/\/ ServerResources returns the supported resources for all groups and versions.\n    \/\/\n    \/\/ The returned resource list might be non-nil with partial results even in the case of\n    \/\/ non-nil error.\n    \/\/\n    \/\/ Deprecated: use ServerGroupsAndResources instead.\n    ServerResources() ([]*metav1.APIResourceList, error)\n    \/\/ ServerResources returns the supported groups and resources for all groups and versions.\n    \/\/\n    \/\/ The returned group and resource lists might be non-nil with partial results even in the\n    \/\/ case of non-nil error.\n    ServerGroupsAndResources() ([]*metav1.APIGroup, []*metav1.APIResourceList, error)\n    \/\/ ServerPreferredResources returns the supported resources with the version preferred by the\n    \/\/ server.\n    \/\/\n    \/\/ The returned group and resource lists might be non-nil with partial results even in the\n    \/\/ case of non-nil error.\n    ServerPreferredResources() ([]*metav1.APIResourceList, error)\n    \/\/ ServerPreferredNamespacedResources returns the supported namespaced resources with the\n    \/\/ version preferred by the server.\n    \/\/\n    \/\/ The returned resource list might be non-nil with partial results even in the case of\n    \/\/ non-nil error.\n    ServerPreferredNamespacedResources() ([]*metav1.APIResourceList, error)\n}\n<\/code><\/pre>\n<p>\u8fd9\u91cc\u6211\u4eec\u53ef\u4ee5\u7528 ServerPreferredNamespacedResources \u6765\u83b7\u53d6\u6240\u6709\u5c5e\u4e8e namespace \u7684\u8d44\u6e90\u5217\u8868\u3002\u7136\u540e\u8fc7\u6ee4\u51fa\u652f\u6301 DELETE \u7684\u8d44\u6e90\u3002\u6700\u540e\u83b7\u53d6\u8fd9\u4e9b\u8d44\u6e90\u7684 GroupVersionResources\uff08\u7b80\u79f0 GVR \uff09\u3002<\/p>\n<pre><code class=\"language-go line-numbers\">    resources, err := d.discoverResourcesFn()\n    if err != nil {\n        \/\/ discovery errors are not fatal.  We often have some set of resources we can operate against even if we don't have a complete list\n        errs = append(errs, err)\n        conditionUpdater.ProcessDiscoverResourcesErr(err)\n    }\n    \/\/ TODO(sttts): get rid of opCache and pass the verbs (especially \"deletecollection\") down into the deleter\n    deletableResources := discovery.FilteredBy(discovery.SupportsAllVerbs{Verbs: []string{\"delete\"}}, resources)\n    groupVersionResources, err := discovery.GroupVersionResources(deletableResources)\n    if err != nil {\n        \/\/ discovery errors are not fatal.  We often have some set of resources we can operate against even if we don't have a complete list\n        errs = append(errs, err)\n        conditionUpdater.ProcessGroupVersionErr(err)\n    }\n<\/code><\/pre>\n<p>\u6700\u540e\u904d\u5386\u8fd9\u4e9b GVR \u8fdb\u884c\u5220\u9664\uff1a<\/p>\n<pre><code class=\"language-go line-numbers\">    for gvr := range groupVersionResources {\n        gvrDeletionMetadata, err := d.deleteAllContentForGroupVersionResource(gvr, namespace, namespaceDeletedAt)\n    }\n<\/code><\/pre>\n<h2>\u4e94\u3001\u4e3a\u4ec0\u4e48 namespace \u4f1a\u957f\u65f6\u95f4\u5904\u4e8e terminating \u72b6\u6001<\/h2>\n<p>\u8981\u63a2\u7a76 namespace \u957f\u65f6\u95f4\u5904\u4e8e terminating \u72b6\u6001\u7684\u539f\u56e0\uff0c\u6211\u4eec\u5148\u770b\u4e0b\u9762\u4e00\u6bb5\u5f88\u77ed\u7684\u4ee3\u7801\uff1a<\/p>\n<pre><code class=\"language-go line-numbers\">    \/\/ there may still be content for us to remove\n    estimate, err := d.deleteAllContent(namespace)\n    if err != nil {\n        return err\n    }\n    if estimate &gt; 0 {\n        return &amp;ResourcesRemainingError{estimate}\n    }\n<\/code><\/pre>\n<p>\u5728\u5220\u9664\u547d\u540d\u7a7a\u95f4\u4e0b\u6240\u6709\u8d44\u6e90\u7684\u65f6\u5019\uff0c\u5982\u679c\u8fd4\u56de\u4e86\u9519\u8bef\uff0c\u6216\u8005\u9884\u4f30\u5220\u9664\u5b8c\u6240\u6709\u8d44\u6e90\u7684\u65f6\u95f4\u5927\u4e8e 0 \u7684\u8bdd\uff0c\u5c31\u4f1a\u7ee7\u7eed\u5904\u4e8e terminating \u72b6\u6001\u3002\u6bd4\u5982\u8bf4 pod \u4f1a\u6709\u4e00\u4e2a terminationGracePeriodSeconds\uff0c\u90a3\u4e48\u5728\u5220\u9664 pod \u7684\u65f6\u5019\u5c31\u53ef\u80fd\u8981\u7b49\u5f85\u8fd9\u4e2a\u5468\u671f\u8fc7\u53bb\u3002\u4f46\u662f\u8fd9\u4e5f\u9020\u6210\u4e0d\u4e86\u4ec0\u4e48\u95ee\u9898\uff0c\u6211\u4eec\u5e38\u5e38\u9047\u5230\u7684\u5934\u75bc\u95ee\u9898\u662f\uff0cnamespace \u4e00\u76f4\u65e0\u6cd5\u5220\u9664\u3002\u7b80\u5355\u6765\u8bf4\uff0c\u5c31\u662f namespace \u4e0b\u80af\u5b9a\u8fd8\u6709\u8d44\u6e90\u6ca1\u6cd5\u5220\u9664\uff0c\u53ef\u80fd\u6027\u6709\u4ee5\u4e0b\u51e0\u79cd\u3002<\/p>\n<p><strong>\u90e8\u5206\u8d44\u6e90\u6709 admission \u963b\u6b62\u4e86\u5220\u9664<\/strong>\uff0c\u56e0\u4e3a\u6240\u6709\u7684\u5220\u9664\u8bf7\u6c42\u90fd\u8981\u5148\u8fdb\u8fc7 admission webhook\uff0c\u90a3\u4e48\u53ef\u80fd\u56e0\u4e3a admission \u7684\u539f\u56e0\u5bfc\u81f4\u90e8\u5206\u8d44\u6e90\u65e0\u6cd5\u76f4\u63a5\u5220\u9664\u3002<\/p>\n<p><strong>apiservice \u51fa\u95ee\u9898\u4e86<\/strong>\u3002\u8fd9\u4e2a\u95ee\u9898\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7 <code>kubectl get apiservice<\/code> \u6765\u786e\u8ba4\uff0c\u5728 AVAILABLE \u4e00\u5217\u4e2d\uff0c\u5982\u679c\u6709 false \u7684\u8bdd\uff0c\u6211\u4eec\u5c31\u8981\u53bb\u68c0\u67e5\u8fd9\u4e2a apiservice \u65e0\u6cd5\u4f7f\u7528\u7684\u539f\u56e0\u4e86\u3002\u56e0\u4e3a apiservice \u51fa\u4e86\u95ee\u9898\uff0c\u5c31\u4f1a\u5bfc\u81f4\u8fd9\u4e2a apiservice \u4e0b\u7684\u8d44\u6e90\u65e0\u6cd5\u901a\u8fc7 HTTP \u8bf7\u6c42\u53bb\u67e5\u8be2\u6216\u64cd\u4f5c\uff0c\u90a3\u4e48\u81ea\u7136\u65e0\u6cd5\u786e\u8ba4\u662f\u5426\u8fd8\u6709\u8fd9\u90e8\u5206\u8d44\u6e90\u9057\u7559\uff0c\u4e5f\u5c31\u65e0\u6cd5\u5f7b\u5e95\u5220\u9664\u4e86\u3002<\/p>\n<p>\u6700\u540e\uff0c\u5173\u4e8e namespace \u65e0\u6cd5\u5220\u9664\u7684\u89e3\u51b3\u65b9\u6848\uff0c\u7f51\u4e0a\u7ed9\u51fa\u7684\u65b9\u6848\u5f80\u5f80\u662f\u901a\u8fc7\u7f6e\u7a7a namespace \u7684 spec.finalizers \u6765\u505a\uff0c\u4f46\u662f\u8fd9\u662f\u6cbb\u6807\u4e0d\u6cbb\u672c\u7684\u65b9\u6cd5\u3002\u56e0\u4e3a\u5982\u679c namespace \u65e0\u6cd5\u5220\u9664\uff0c\u5c31\u4e00\u5b9a\u8bf4\u660e\u4f60\u7684\u96c6\u7fa4\u4e2d\u5b58\u5728\u7f3a\u9677\u6216\u95ee\u9898\uff0c\u8fd8\u662f\u8981\u627e\u51fa\u771f\u6b63\u7684\u539f\u56e0\u624d\u662f\u89e3\u51b3\u4e4b\u9053\u3002\u4f60\u4e5f\u53ef\u4ee5\u5c1d\u8bd5\u8fd9\u4e2a\u5de5\u5177\u627e\u51fa\u95ee\u9898\u6240\u5728\uff1ahttps:\/\/github.com\/thyarles\/knsk<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u6982\u8ff0 namespace \u662f kubernetes \u4e2d\u4e00\u4e2a\u6bd4\u8f83\u91cd\u8981\u7684\u6982\u5ff5\uff0c\u662f\u5bf9\u4e00\u7ec4\u8d44\u6e90\u548c\u5bf9\u8c61\u7684\u62bd\u8c61\uff0c\u4e5f\u5e38\u7528 &hellip; <a href=\"https:\/\/www.myway5.com\/index.php\/2020\/09\/04\/k8s-namespace-deletion\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">k8s \u4e2d\u5220\u9664 namespace \u65f6\u53d1\u751f\u4e86\u4ec0\u4e48<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[119,89],"tags":[121,120],"class_list":["post-640","post","type-post","status-publish","format-standard","hentry","category-controller","category-k8s","tag-controller","tag-namespace"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>k8s \u4e2d\u5220\u9664 namespace \u65f6\u53d1\u751f\u4e86\u4ec0\u4e48 - \u4e00\u53ea\u5b89\u9759\u7684\u732b<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.myway5.com\/index.php\/2020\/09\/04\/k8s-namespace-deletion\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"k8s \u4e2d\u5220\u9664 namespace \u65f6\u53d1\u751f\u4e86\u4ec0\u4e48 - \u4e00\u53ea\u5b89\u9759\u7684\u732b\" \/>\n<meta property=\"og:description\" content=\"\u4e00\u3001\u6982\u8ff0 namespace \u662f kubernetes \u4e2d\u4e00\u4e2a\u6bd4\u8f83\u91cd\u8981\u7684\u6982\u5ff5\uff0c\u662f\u5bf9\u4e00\u7ec4\u8d44\u6e90\u548c\u5bf9\u8c61\u7684\u62bd\u8c61\uff0c\u4e5f\u5e38\u7528 &hellip; \u7ee7\u7eed\u9605\u8bfbk8s \u4e2d\u5220\u9664 namespace \u65f6\u53d1\u751f\u4e86\u4ec0\u4e48\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.myway5.com\/index.php\/2020\/09\/04\/k8s-namespace-deletion\/\" \/>\n<meta property=\"og:site_name\" content=\"\u4e00\u53ea\u5b89\u9759\u7684\u732b\" \/>\n<meta property=\"article:published_time\" content=\"2020-09-04T13:43:20+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-07-05T13:24:57+00:00\" \/>\n<meta name=\"author\" content=\"jiangpengfei\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"jiangpengfei\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.myway5.com\/index.php\/2020\/09\/04\/k8s-namespace-deletion\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.myway5.com\/index.php\/2020\/09\/04\/k8s-namespace-deletion\/\"},\"author\":{\"name\":\"jiangpengfei\",\"@id\":\"https:\/\/www.myway5.com\/#\/schema\/person\/b19267e8b106343431e163ec96950685\"},\"headline\":\"k8s \u4e2d\u5220\u9664 namespace \u65f6\u53d1\u751f\u4e86\u4ec0\u4e48\",\"datePublished\":\"2020-09-04T13:43:20+00:00\",\"dateModified\":\"2023-07-05T13:24:57+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.myway5.com\/index.php\/2020\/09\/04\/k8s-namespace-deletion\/\"},\"wordCount\":137,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/www.myway5.com\/#\/schema\/person\/b19267e8b106343431e163ec96950685\"},\"keywords\":[\"controller\",\"namespace\"],\"articleSection\":[\"controller\u7684\u5b9e\u73b0\",\"k8s\"],\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.myway5.com\/index.php\/2020\/09\/04\/k8s-namespace-deletion\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.myway5.com\/index.php\/2020\/09\/04\/k8s-namespace-deletion\/\",\"url\":\"https:\/\/www.myway5.com\/index.php\/2020\/09\/04\/k8s-namespace-deletion\/\",\"name\":\"k8s \u4e2d\u5220\u9664 namespace \u65f6\u53d1\u751f\u4e86\u4ec0\u4e48 - \u4e00\u53ea\u5b89\u9759\u7684\u732b\",\"isPartOf\":{\"@id\":\"https:\/\/www.myway5.com\/#website\"},\"datePublished\":\"2020-09-04T13:43:20+00:00\",\"dateModified\":\"2023-07-05T13:24:57+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.myway5.com\/index.php\/2020\/09\/04\/k8s-namespace-deletion\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.myway5.com\/index.php\/2020\/09\/04\/k8s-namespace-deletion\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.myway5.com\/index.php\/2020\/09\/04\/k8s-namespace-deletion\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.myway5.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"k8s \u4e2d\u5220\u9664 namespace \u65f6\u53d1\u751f\u4e86\u4ec0\u4e48\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.myway5.com\/#website\",\"url\":\"https:\/\/www.myway5.com\/\",\"name\":\"\u4e00\u53ea\u5b89\u9759\u7684\u732b\",\"description\":\"\u60f3\u5565\u5462\",\"publisher\":{\"@id\":\"https:\/\/www.myway5.com\/#\/schema\/person\/b19267e8b106343431e163ec96950685\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.myway5.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-Hans\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/www.myway5.com\/#\/schema\/person\/b19267e8b106343431e163ec96950685\",\"name\":\"jiangpengfei\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.myway5.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/f8c7de757f6e0247412bcfd31b7c2271?s=96&d=monsterid&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/f8c7de757f6e0247412bcfd31b7c2271?s=96&d=monsterid&r=g\",\"caption\":\"jiangpengfei\"},\"logo\":{\"@id\":\"https:\/\/www.myway5.com\/#\/schema\/person\/image\/\"},\"url\":\"https:\/\/www.myway5.com\/index.php\/author\/joyme\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"k8s \u4e2d\u5220\u9664 namespace \u65f6\u53d1\u751f\u4e86\u4ec0\u4e48 - \u4e00\u53ea\u5b89\u9759\u7684\u732b","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.myway5.com\/index.php\/2020\/09\/04\/k8s-namespace-deletion\/","og_locale":"zh_CN","og_type":"article","og_title":"k8s \u4e2d\u5220\u9664 namespace \u65f6\u53d1\u751f\u4e86\u4ec0\u4e48 - \u4e00\u53ea\u5b89\u9759\u7684\u732b","og_description":"\u4e00\u3001\u6982\u8ff0 namespace \u662f kubernetes \u4e2d\u4e00\u4e2a\u6bd4\u8f83\u91cd\u8981\u7684\u6982\u5ff5\uff0c\u662f\u5bf9\u4e00\u7ec4\u8d44\u6e90\u548c\u5bf9\u8c61\u7684\u62bd\u8c61\uff0c\u4e5f\u5e38\u7528 &hellip; \u7ee7\u7eed\u9605\u8bfbk8s \u4e2d\u5220\u9664 namespace \u65f6\u53d1\u751f\u4e86\u4ec0\u4e48","og_url":"https:\/\/www.myway5.com\/index.php\/2020\/09\/04\/k8s-namespace-deletion\/","og_site_name":"\u4e00\u53ea\u5b89\u9759\u7684\u732b","article_published_time":"2020-09-04T13:43:20+00:00","article_modified_time":"2023-07-05T13:24:57+00:00","author":"jiangpengfei","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"jiangpengfei","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"6 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.myway5.com\/index.php\/2020\/09\/04\/k8s-namespace-deletion\/#article","isPartOf":{"@id":"https:\/\/www.myway5.com\/index.php\/2020\/09\/04\/k8s-namespace-deletion\/"},"author":{"name":"jiangpengfei","@id":"https:\/\/www.myway5.com\/#\/schema\/person\/b19267e8b106343431e163ec96950685"},"headline":"k8s \u4e2d\u5220\u9664 namespace \u65f6\u53d1\u751f\u4e86\u4ec0\u4e48","datePublished":"2020-09-04T13:43:20+00:00","dateModified":"2023-07-05T13:24:57+00:00","mainEntityOfPage":{"@id":"https:\/\/www.myway5.com\/index.php\/2020\/09\/04\/k8s-namespace-deletion\/"},"wordCount":137,"commentCount":1,"publisher":{"@id":"https:\/\/www.myway5.com\/#\/schema\/person\/b19267e8b106343431e163ec96950685"},"keywords":["controller","namespace"],"articleSection":["controller\u7684\u5b9e\u73b0","k8s"],"inLanguage":"zh-Hans","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.myway5.com\/index.php\/2020\/09\/04\/k8s-namespace-deletion\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.myway5.com\/index.php\/2020\/09\/04\/k8s-namespace-deletion\/","url":"https:\/\/www.myway5.com\/index.php\/2020\/09\/04\/k8s-namespace-deletion\/","name":"k8s \u4e2d\u5220\u9664 namespace \u65f6\u53d1\u751f\u4e86\u4ec0\u4e48 - \u4e00\u53ea\u5b89\u9759\u7684\u732b","isPartOf":{"@id":"https:\/\/www.myway5.com\/#website"},"datePublished":"2020-09-04T13:43:20+00:00","dateModified":"2023-07-05T13:24:57+00:00","breadcrumb":{"@id":"https:\/\/www.myway5.com\/index.php\/2020\/09\/04\/k8s-namespace-deletion\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.myway5.com\/index.php\/2020\/09\/04\/k8s-namespace-deletion\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.myway5.com\/index.php\/2020\/09\/04\/k8s-namespace-deletion\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.myway5.com\/"},{"@type":"ListItem","position":2,"name":"k8s \u4e2d\u5220\u9664 namespace \u65f6\u53d1\u751f\u4e86\u4ec0\u4e48"}]},{"@type":"WebSite","@id":"https:\/\/www.myway5.com\/#website","url":"https:\/\/www.myway5.com\/","name":"\u4e00\u53ea\u5b89\u9759\u7684\u732b","description":"\u60f3\u5565\u5462","publisher":{"@id":"https:\/\/www.myway5.com\/#\/schema\/person\/b19267e8b106343431e163ec96950685"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.myway5.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-Hans"},{"@type":["Person","Organization"],"@id":"https:\/\/www.myway5.com\/#\/schema\/person\/b19267e8b106343431e163ec96950685","name":"jiangpengfei","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.myway5.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/f8c7de757f6e0247412bcfd31b7c2271?s=96&d=monsterid&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f8c7de757f6e0247412bcfd31b7c2271?s=96&d=monsterid&r=g","caption":"jiangpengfei"},"logo":{"@id":"https:\/\/www.myway5.com\/#\/schema\/person\/image\/"},"url":"https:\/\/www.myway5.com\/index.php\/author\/joyme\/"}]}},"views":8057,"_links":{"self":[{"href":"https:\/\/www.myway5.com\/index.php\/wp-json\/wp\/v2\/posts\/640","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.myway5.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.myway5.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.myway5.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.myway5.com\/index.php\/wp-json\/wp\/v2\/comments?post=640"}],"version-history":[{"count":4,"href":"https:\/\/www.myway5.com\/index.php\/wp-json\/wp\/v2\/posts\/640\/revisions"}],"predecessor-version":[{"id":644,"href":"https:\/\/www.myway5.com\/index.php\/wp-json\/wp\/v2\/posts\/640\/revisions\/644"}],"wp:attachment":[{"href":"https:\/\/www.myway5.com\/index.php\/wp-json\/wp\/v2\/media?parent=640"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.myway5.com\/index.php\/wp-json\/wp\/v2\/categories?post=640"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.myway5.com\/index.php\/wp-json\/wp\/v2\/tags?post=640"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}