- A Kubernetes cluster with the WebApp custom resource and a controller that implements a finalizer-based external cleanup.
- Namespace:
webapp-demo(for the WebApp CR) andwebapp-external(for the external ConfigMap).
- Confirm the WebApp custom resource exists and inspect its finalizers.
webapp.kodekloud.com/finalizer attached to the WebApp resource. This finalizer prevents the API server from permanently removing the object until the controller performing external cleanup removes the finalizer.
- Confirm the external ConfigMap exists and has no owner references.
ownerReferences set on the external ConfigMap. Because the external resource is not owned by the WebApp object, it requires explicit external cleanup by the controller (which is coordinated via the finalizer).
Finalizers are used when deleting a Kubernetes object requires external cleanup steps (for example, deleting resources in another namespace or cleaning up entries in an external system). The finalizer blocks the API server from completing deletion until the controller performs the cleanup and removes the finalizer.
- Delete the WebApp resource and observe the result.
webapp-external), then remove the finalizer so the API server can complete the deletion.
- Verify that both the WebApp resource and the external ConfigMap are gone.
Links and references
This exercise illustrates the pattern where a finalizer coordinates a controller-driven cleanup of external resources before the API server completes deletion of a Kubernetes object.