Auf dieser Seite erfahren Sie, wie Sie Probleme mit einem Namespace beheben, der sich im Status Terminating befindet.
In Namespaces werden Kubernetes-Finalizer verwendet, um das Löschen zu verhindern, wenn eine oder mehrere Ressourcen in einem Namespace noch vorhanden sind.
Wenn Sie einen Namespace mit dem kubectl delete-Befehl löschen, ändert sich sein Status in Terminating.
Der Namespace bleibt im Status Terminating, bis Kubernetes die abhängigen Ressourcen löscht und alle Finalisierer beseitigt. Der Namespace-Lebenszykluscontroller listet zuerst alle Ressourcen im Namespace auf, die von GKE gelöscht werden müssen.
Wenn GKE eine abhängige Ressource nicht löschen kann oder der Namespace-Lebenszykluscontroller nicht prüfen kann, ob der Namespace leer ist, bleibt der Namespace im Status Terminating, bis Sie das Problem behoben haben.
Wenn Sie das Problem eines im Status Terminating festhängenden Namespace beheben möchten, identifizieren und entfernen Sie alle fehlerhaften Komponenten, die das Löschen blockieren. Probieren Sie die folgenden Lösungen in der angegebenen Reihenfolge aus:
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-04-22 (UTC)."],[],[],null,["# Troubleshoot namespace stuck in the Terminating state\n\n[Autopilot](/kubernetes-engine/docs/concepts/autopilot-overview) [Standard](/kubernetes-engine/docs/concepts/choose-cluster-mode)\n\n*** ** * ** ***\n\nThis page shows you how to resolve issues with a namespace stuck in the\n`Terminating` state.\n\nNamespaces use Kubernetes [finalizers](https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#finalizers)\nto prevent deletion if one or more resources within a namespace still exist.\nWhen you delete a namespace using the `kubectl delete` command, the namespace\nenters the `Terminating` state.\nThe namespace stays in the `Terminating` state\nuntil Kubernetes deletes its dependent resources\nand clears all finalizers. The namespace lifecycle controller first lists all\nresources in the namespace that GKE needs to delete.\n\nIf GKE can't delete a dependent resource,\nor if the namespace\nlifecycle controller can't verify that the namespace is empty, then the namespace\nremains in the `Terminating` state until you resolve the issue.\n\nTo resolve a namespace stuck in the `Terminating` state, identify\nand remove any unhealthy components blocking the deletion. Try these solutions\nin order:\n\n1. [Find and remove unavailable API services](#unavailable-api-services).\n2. [Find and remove remaining resources](#remove_resource).\n3. [Force delete the namespace](#force-delete-namespace).\n\nFind and remove unavailable API services\n----------------------------------------\n\n1. List unavailable API services:\n\n kubectl get apiservice | grep False\n\n2. Troubleshoot any unresponsive services:\n\n kubectl describe apiservice \u003cvar translate=\"no\"\u003eAPI_SERVICE\u003c/var\u003e\n\n Replace \u003cvar translate=\"no\"\u003eAPI_SERVICE\u003c/var\u003e with the name of the unresponsive\n service.\n3. Check if the status of the namespace is still `Terminating`:\n\n kubectl get ns | grep Terminating\n\nFind and remove remaining resources\n-----------------------------------\n\n1. List all the resources remaining in the terminating namespace:\n\n kubectl api-resources --verbs=list --namespaced -o name | xargs -n 1 kubectl get -n \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e\n\n Replace \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e with the name of the namespace you\n want to delete.\n2. Remove any resources displayed in the output.\n\n3. Check if the status of the namespace is still `Terminating`:\n\n kubectl get ns | grep Terminating\n\nForce delete the namespace\n--------------------------\n\n| **Caution:** Use the solution in this section only as a last resort if the previous solutions don't work. Force deleting a namespace could result in resources remaining in your cluster that you can't access.\n\nRemove the finalizers blocking namespace deletion to force the namespace\nto terminate:\n\n1. Save the namespace manifest as a YAML file:\n\n kubectl get ns \u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e -o yaml \u003e ns-terminating.yml\n\n2. Open the manifest in a text editor and remove all values in the\n `spec.finalizers` field:\n\n vi ns-terminating.yml\n\n3. Verify that the finalizers field is empty:\n\n cat ns-terminating.yml\n\n The output should look similar to the following: \n\n apiVersion: v1\n kind: Namespace\n metadata:\n annotations:\n name: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eNAMESPACE\u003c/span\u003e\u003c/var\u003e\n spec:\n finalizers:\n status:\n phase: Terminating\n\n4. Start an HTTP proxy to access the Kubernetes API:\n\n kubectl proxy\n\n5. Replace the namespace manifest using `curl`:\n\n curl -H \"Content-Type: application/yaml\" -X PUT --data-binary @ns-terminating.yml http://127.0.0.1:8001/api/v1/namespaces/\u003cvar translate=\"no\"\u003eNAMESPACE\u003c/var\u003e/finalize\n\n6. Check if the status of the namespace is still `Terminating`:\n\n kubectl get ns | grep Terminating\n\nWhat's next\n-----------\n\n- If you can't find a solution to your problem in the documentation, see\n [Get support](/kubernetes-engine/docs/getting-support) for further help,\n including advice on the following topics:\n\n - Opening a support case by contacting [Cloud Customer Care](/support-hub).\n - Getting support from the community by [asking questions on StackOverflow](http://stackoverflow.com/questions/tagged/google-kubernetes-engine) and using the `google-kubernetes-engine` tag to search for similar issues. You can also join the [`#kubernetes-engine` Slack channel](https://googlecloud-community.slack.com/messages/C0B9GKTKJ/) for more community support.\n - Opening bugs or feature requests by using the [public issue tracker](/support/docs/issue-trackers)."]]