Back to all scenarios
Scenario #22
Cluster Management
K8s v1.21, self-managed
Stale Finalizers Preventing Namespace Deletion
A namespace remained in “Terminating” state indefinitely.
Find this helpful?
What Happened
The namespace contained resources with finalizers pointing to a deleted controller. Kubernetes waited forever for the finalizer to complete cleanup.
Diagnosis Steps
- 1Ran kubectl get ns <name> -o json – saw dangling finalizers.
- 2Checked for the corresponding CRD/controller – it was uninstalled.
Root Cause
Finalizers without owning controller cause resource lifecycle deadlocks.
Fix/Workaround
• Manually removed finalizers using a patched JSON:
bash
CopyEdit
kubectl patch ns <name> -p '{"spec":{"finalizers":[]}}' --type=merge
Lessons Learned
Always delete CRs before removing the CRD or controller.
How to Avoid
- 1Implement controller cleanup logic.
- 2Audit finalizers periodically.