Halaman ini menunjukkan cara menyelesaikan masalah terkait namespace yang macet dalam status Terminating.
Namespace menggunakan finalizer Kubernetes
untuk mencegah penghapusan jika satu atau beberapa resource dalam namespace masih ada.
Saat Anda menghapus namespace menggunakan perintah kubectl delete, namespace akan memasuki status Terminating.
Namespace tetap dalam status Terminating hingga Kubernetes menghapus resource dependennya dan menghapus semua finalizer. Pengontrol siklus proses namespace pertama-tama mencantumkan semua
resource di namespace yang perlu dihapus oleh GKE.
Jika GKE tidak dapat menghapus resource dependen, atau jika pengontrol siklus proses namespace tidak dapat memastikan bahwa namespace kosong, namespace akan tetap dalam status Terminating hingga Anda menyelesaikan masalah ini.
Untuk menyelesaikan namespace yang terjebak dalam status Terminating, identifikasi dan hapus komponen tidak responsif yang memblokir penghapusan. Coba solusi berikut secara berurutan:
Periksa apakah status namespace masih Terminating:
kubectlgetns|grepTerminating
Langkah berikutnya
Jika Anda tidak dapat menemukan solusi untuk masalah Anda dalam dokumentasi, lihat Mendapatkan dukungan untuk mendapatkan bantuan lebih lanjut, termasuk saran tentang topik berikut:
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-09-04 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)."]]