K8S Garbage Collection

Cascading deletion: When deleting an object, one can specify whether the object's dependents are also deleted automatically. Deleting the dependents automatically is called cascading deletion.

Foreground cascading deletion

  1. Root object first enters "deletion in progress" state

    1. The object is still available via REST API

    2. deletionTimestamp is set

    3. metadata.finalizers contains the value of foregroundDeletion

  2. Garbage collector deletes the object's dependents

  3. Once the garbage collector has deleted all “blocking” dependents (objects with ownerReference.blockOwnerDeletion=true), it deletes the owner object. Otherwise the deletion of the objects will be blocked

Background cascading deletion

In background cascading deletion, Kubernetes deletes the owner object immediately and the garbage collector then deletes the dependents in the background.

Setting the cascading deletion policy

Checkout the link

References

Last updated