Kubernetes internalsLesson 3 of 12
Deletion Is More Complex Than You Think
In Kubernetes, a "delete" request does not make an object vanish at once. If cleanup work remains, it waits, and dependent objects are removed afterward by another worker. Let's follow why Terminating lingers in kubectl get.
DeletingPVC data
StateDelete requested
Finalizers left—
RequestResponse / report
What you will learn
- How deletionTimestamp and finalizers relate
- Terminating means "waiting"
- Owner references and garbage collection
- Why namespace deletion never finishes
Common finalizers and when they get stuck
| Finalizer | What it waits for | When it stays stuck |
|---|---|---|
kubernetes.io/pvc-protection | No Pod using this PVC | A Pod that mounts the PVC is still alive |
kubernetes.io/pv-protection | No PVC bound to this PV | The PVC still exists |
kubernetes on a namespace | Every object in the namespace deleted | One object inside is stuck on a finalizer |
| Names added by each tool | The tool cleaning up its external resources | The tool's controller was removed or stopped |
Try it yourself
kubectl get pvc -A -o custom-columns=NAME:.metadata.name,FINALIZERS:.metadata.finalizers # pvc-protection on every PVC
kubectl get <kind> <name> -n <namespace> -o jsonpath='{.metadata.deletionTimestamp} {.metadata.finalizers}' # Terminating: when, and waiting on what
kubectl get pod <pod> -o jsonpath='{.metadata.ownerReferences}' # Owner of this Pod
kubectl get namespace <namespace> -o jsonpath='{.status.conditions}' # Why the namespace deletion is stuck
kubectl api-resources --verbs=list --namespaced -o name | xargs -n 1 kubectl get --show-kind --ignore-not-found -n <namespace> # What is left inside
Check yourself
Further reading: Finalizers · Garbage collection · Owners and dependents