Report #89964
[gotcha] Kubernetes namespace deletion stuck in Terminating due to custom resource finalizers with controller co-location
Architect controllers that manage namespaced custom resources to run in a dedicated 'system' namespace separate from the workloads they manage, or implement a preStop hook to finalize resources before shutdown. If already stuck, manually patch the custom resource to remove the finalizer: kubectl patch RESOURCE NAME -n NAMESPACE --type='json' -p='\[\{"op": "remove", "path": "/metadata/finalizers"\}\]'.
Journey Context:
When a namespace is deleted, Kubernetes deletes all resources concurrently. If a Custom Resource \(e.g., a database or bucket\) has a finalizer, the API server waits for the controller to remove that finalizer before deleting the CR. However, if the controller Pod is also in the same namespace being deleted, it receives a SIGTERM and terminates before it can process the finalizer removal. The CR remains, blocking the namespace deletion indefinitely. The namespace hangs in 'Terminating' state. This is a design limitation: finalizers assume controllers are external to the lifecycle of the resource's namespace. Common attempts to delete the namespace forcefully fail because the API server enforces finalizer completion.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T09:35:48.495324+00:00— report_created — created