<p>I've a namespace I'm unable to delete in my Kubernetes cluster. When I run <code>kubectl get ns traefik -o yaml</code>, I get the following:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Namespace
metadata:
  annotations:
    cattle.io/status: '{&quot;Conditions&quot;:[{&quot;Type&quot;:&quot;ResourceQuotaInit&quot;,&quot;Status&quot;:&quot;True&quot;,&quot;Message&quot;:&quot;&quot;,&quot;LastUpdateTime&quot;:&quot;2021-06-11T20:28:59Z&quot;},{&quot;Type&quot;:&quot;InitialRolesPopulated&quot;,&quot;Status&quot;:&quot;True&quot;,&quot;Message&quot;:&quot;&quot;,&quot;LastUpdateTime&quot;:&quot;2021-06-11T20:29:00Z&quot;}]}'
    field.cattle.io/projectId: c-5g2hz:p-bl9sf
    lifecycle.cattle.io/create.namespace-auth: &quot;true&quot;
  creationTimestamp: &quot;2021-06-11T20:28:58Z&quot;
  deletionTimestamp: &quot;2021-07-04T07:21:20Z&quot;
  labels:
    field.cattle.io/projectId: p-bl9sf
  managedFields:
  - apiVersion: v1
    fieldsType: FieldsV1
    fieldsV1:
      f:metadata:
        f:annotations:
          .: {}
          f:field.cattle.io/projectId: {}
        f:labels:
          .: {}
          f:field.cattle.io/projectId: {}
      f:status:
        f:phase: {}
    manager: agent
    operation: Update
    time: &quot;2021-06-11T20:28:58Z&quot;
  - apiVersion: v1
    fieldsType: FieldsV1
    fieldsV1:
      f:metadata:
        f:annotations:
          f:cattle.io/status: {}
          f:lifecycle.cattle.io/create.namespace-auth: {}
    manager: rancher
    operation: Update
    time: &quot;2021-06-11T20:28:58Z&quot;
  - apiVersion: v1
    fieldsType: FieldsV1
    fieldsV1:
      f:status:
        f:conditions:
          .: {}
          k:{&quot;type&quot;:&quot;NamespaceContentRemaining&quot;}:
            .: {}
            f:lastTransitionTime: {}
            f:message: {}
            f:reason: {}
            f:status: {}
            f:type: {}
          k:{&quot;type&quot;:&quot;NamespaceDeletionContentFailure&quot;}:
            .: {}
            f:lastTransitionTime: {}
            f:message: {}
            f:reason: {}
            f:status: {}
            f:type: {}
          k:{&quot;type&quot;:&quot;NamespaceDeletionDiscoveryFailure&quot;}:
            .: {}
            f:lastTransitionTime: {}
            f:message: {}
            f:reason: {}
            f:status: {}
            f:type: {}
          k:{&quot;type&quot;:&quot;NamespaceDeletionGroupVersionParsingFailure&quot;}:
            .: {}
            f:lastTransitionTime: {}
            f:message: {}
            f:reason: {}
            f:status: {}
            f:type: {}
          k:{&quot;type&quot;:&quot;NamespaceFinalizersRemaining&quot;}:
            .: {}
            f:lastTransitionTime: {}
            f:message: {}
            f:reason: {}
            f:status: {}
            f:type: {}
    manager: kube-controller-manager
    operation: Update
    time: &quot;2021-07-04T07:21:26Z&quot;
  name: traefik
  resourceVersion: &quot;15400692&quot;
  uid: 4b198956-bbd5-4bdb-9dc6-9d53feda91e4
spec:
  finalizers:
  - kubernetes
status:
  conditions:
  - lastTransitionTime: &quot;2021-07-04T07:21:25Z&quot;
    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: &quot;True&quot;
    type: NamespaceDeletionDiscoveryFailure
  - lastTransitionTime: &quot;2021-07-04T07:21:26Z&quot;
    message: All legacy kube types successfully parsed
    reason: ParsedGroupVersions
    status: &quot;False&quot;
    type: NamespaceDeletionGroupVersionParsingFailure
  - lastTransitionTime: &quot;2021-07-04T07:21:26Z&quot;
    message: All content successfully deleted, may be waiting on finalization
    reason: ContentDeleted
    status: &quot;False&quot;
    type: NamespaceDeletionContentFailure
  - lastTransitionTime: &quot;2021-07-04T07:21:26Z&quot;
    message: All content successfully removed
    reason: ContentRemoved
    status: &quot;False&quot;
    type: NamespaceContentRemaining
  - lastTransitionTime: &quot;2021-07-04T07:21:26Z&quot;
    message: All content-preserving finalizers finished
    reason: ContentHasNoFinalizers
    status: &quot;False&quot;
    type: NamespaceFinalizersRemaining
  phase: Terminating
</code></pre>
<p>And when I run <code>kubectl delete ns traefik --v=10</code>, the last output is the following:</p>
<pre><code>I0708 18:38:26.538676   31537 round_trippers.go:425] curl -k -v -XGET  -H &quot;Accept: application/json&quot; -H &quot;User-Agent: kubectl/v1.20.2 (linux/amd64) kubernetes/faecb19&quot; 'http://127.0.0.1:44427/6614317c-41da-462b-8be3-c6cda2f0df24/api/v1/namespaces?fieldSelector=metadata.name%3Dtraefik&amp;resourceVersion=17101173&amp;watch=true'
I0708 18:38:27.013394   31537 round_trippers.go:445] GET http://127.0.0.1:44427/6614317c-41da-462b-8be3-c6cda2f0df24/api/v1/namespaces?fieldSelector=metadata.name%3Dtraefik&amp;resourceVersion=17101173&amp;watch=true 200 OK in 474 milliseconds
I0708 18:38:27.013421   31537 round_trippers.go:451] Response Headers:
I0708 18:38:27.013427   31537 round_trippers.go:454]     Access-Control-Allow-Origin: *
I0708 18:38:27.013450   31537 round_trippers.go:454]     Date: Thu, 08 Jul 2021 16:38:27 GMT
I0708 18:38:27.013453   31537 round_trippers.go:454]     Connection: keep-alive
I0708 18:38:27.013468   31537 request.go:708] Unexpected content type from the server: &quot;&quot;: mime: no media type
</code></pre>
<p>I already tried to remove the finalizers as described on <a href="https://www.ibm.com/docs/en/cloud-private/3.2.0?topic=console-namespace-is-stuck-in-terminating-state" rel="nofollow noreferrer">https://www.ibm.com/docs/en/cloud-private/3.2.0?topic=console-namespace-is-stuck-in-terminating-state</a> but after some seconds I finally get <code>EOF</code>:</p>
<pre class="lang-sh prettyprint-override"><code>&gt; curl -k -H &quot;Content-Type: application/json&quot; -X PUT --data-binary @tmp.json http://127.0.0.1:8001/api/v1/namespaces/traefik/finalize
EOF
</code></pre>
<p>Is anyone having any idea how I can delete the traefik namespace?</p>

Nrgyzer
<p>Posting this as a community wiki out of comments, feel free to edit and expand.</p>
<p>After analysing a state of the problematic namespace, this part was the main cause of the issue:</p>
<pre><code>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'
</code></pre>
<p>The issue was with <code>metric server</code> in kubernetes. Once the <code>metric server</code> is available, namespace can be unblocked to be deleted.</p>
<p>Similar issue was resolved in <a href="https://stackoverflow.com/questions/62442679/could-not-get-apiversions-from-kubernetes-unable-to-retrieve-the-complete-list/62464015#62464015">another answer on the stackoverflow</a>.</p>
