Introduction

Kubernetes namespace cannot delete when finalizers blocking. This guide provides step-by-step diagnosis and resolution.

Symptoms

Typical error output:

bash
namespace "my-namespace" is terminating
Finalizers: [kubernetes]
Resources remaining: 5
Namespace deletion blocked by finalizers.

Common Causes

  1. 1.Configuration limit or quota exceeded
  2. 2.Authentication or authorization failure
  3. 3.Network or connectivity issue
  4. 4.Resource unavailable or incorrectly sized

Step-by-Step Fix

Step 1: Check Current State

bash
# Check service status
systemctl status <service>
kubectl get all -A
# View logs
journalctl -xe
# Verify configuration
cat /etc/<service>/config.yaml

Step 2: Identify Root Cause

bash
# Check logs
journalctl -u <service> -n 50
# Verify configuration
cat /etc/<service>/config.yaml
# Check resource usage
kubectl top nodes

Step 3: Apply Primary Fix

```bash # Primary fix: Check and reconfigure # Verify limits kubectl describe quota -A

# Check configuration cat /etc/<service>/config.yaml

# Restart if needed systemctl restart <service> ```

Step 4: Apply Alternative Fix

```bash # Alternative: Debug and repair # View detailed logs journalctl -u <service> -n 100

# Check resource usage kubectl top nodes kubectl top pods -A

# Verify quotas and limits kubectl describe limits -A ```

Step 5: Verify the Fix

bash
# Verify operation
systemctl status <service>
kubectl get pods -A
# All resources should show healthy state

Common Pitfalls

  • Not checking resource quotas before deployment
  • Using incorrect configuration values
  • Not monitoring after changes applied
  • Missing documentation of changes

Best Practices

  • Monitor all critical components
  • Set up alerting for resource limits
  • Keep configuration in version control
  • Test changes in non-production first
  • Configuration Error
  • Resource Quota Exceeded
  • Authentication Failed
  • Service Unavailable