Troubleshoot namespace stuck in the Terminating state
Stay organized with collections
Save and categorize content based on your preferences.
This page shows you how to resolve issues with a namespace stuck in the
Terminating
state.
Namespaces use Kubernetes finalizers
to prevent deletion if one or more resources within a namespace still exist.
When you delete a namespace using the kubectl delete
command, the namespace
enters the Terminating
state.
The namespace stays in the Terminating
state
until Kubernetes deletes its dependent resources
and clears all finalizers. The namespace lifecycle controller first lists all
resources in the namespace that GKE needs to delete.
If GKE can't delete a dependent resource,
or if the namespace
lifecycle controller can't verify that the namespace is empty, then the namespace
remains in the Terminating
state until you resolve the issue.
To resolve a namespace stuck in the Terminating
state, identify
and remove any unhealthy components blocking the deletion. Try these solutions
in order:
- Find and remove unavailable API services.
- Find and remove remaining resources.
- Force delete the namespace.
Find and remove unavailable API services
List unavailable API services:
kubectlgetapiservice|grepFalse
Troubleshoot any unresponsive services:
kubectldescribeapiserviceAPI_SERVICE
Replace
API_SERVICE
with the name of the unresponsive service.Check if the status of the namespace is still
Terminating
:kubectlgetns|grepTerminating
Find and remove remaining resources
List all the resources remaining in the terminating namespace:
kubectlapi-resources--verbs=list--namespaced-oname|xargs-n1kubectlget-nNAMESPACE
Replace
NAMESPACE
with the name of the namespace you want to delete.Remove any resources displayed in the output.
Check if the status of the namespace is still
Terminating
:kubectlgetns|grepTerminating
Force delete the namespace
Remove the finalizers blocking namespace deletion to force the namespace to terminate:
Save the namespace manifest as a YAML file:
kubectlgetnsNAMESPACE-oyaml > ns-terminating.yml
Open the manifest in a text editor and remove all values in the
spec.finalizers
field:vins-terminating.yml
Verify that the finalizers field is empty:
catns-terminating.yml
The output should look similar to the following:
apiVersion:v1 kind:Namespace metadata: annotations: name:NAMESPACE spec: finalizers: status: phase:Terminating
Start an HTTP proxy to access the Kubernetes API:
kubectlproxy
Replace the namespace manifest using
curl
:curl-H"Content-Type: application/yaml"-XPUT--data-binary@ns-terminating.ymlhttp://127.0.0.1:8001/api/v1/namespaces/NAMESPACE/finalize
Check if the status of the namespace is still
Terminating
:kubectlgetns|grepTerminating
What's next
If you can't find a solution to your problem in the documentation, see Get support for further help, including advice on the following topics:
- Opening a support case by contacting Cloud Customer Care.
- Getting support from the community by
asking questions on StackOverflow
and using the
google-kubernetes-engine
tag to search for similar issues. You can also join the#kubernetes-engine
Slack channel for more community support. - Opening bugs or feature requests by using the public issue tracker.