Report #94088
[gotcha] Kubernetes namespace stuck in Terminating due to orphaned finalizers
Before deleting a namespace containing custom resources, ensure the controller responsible for removing finalizers is running and healthy. If a namespace is already stuck in Terminating, identify the remaining resources \(kubectl get apiservices, kubectl get crd -A\), then manually patch the custom resource to remove the finalizer array \(kubectl patch RESOURCE NAME -p '\{"metadata":\{"finalizers":\[\]\}\}' --type=merge\) or delete the APIService if the webhook is gone.
Journey Context:
When a namespace is deleted, Kubernetes garbage collects all resources within it. If a CustomResourceDefinition instance has a finalizer \(e.g., 'myoperator.io/cleanup'\), the Kubernetes API server will not delete that object until the controller removes the finalizer. If the controller is deployed inside the same namespace being deleted, it gets terminated before it can process the deletion, or if the controller was never installed \(CRD exists but operator is gone\), the finalizer remains forever. This leaves the namespace in 'Terminating' indefinitely, blocking CI/CD teardown pipelines. The fix requires understanding that finalizers are blocking hooks that require an active controller outside the blast radius.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T16:30:50.107561+00:00— report_created — created