Skip to content

Finalize

A specialized combination of Pepr’s Mutate & Watch functionalities that allow a module author to run logic while Kubernetes is Finalizing a resource (i.e. cleaning up related resources after a deletion request has been accepted). Finalize() can only be accessed after a Watch() or Reconcile().

This method will:

  1. Inject a finalizer into the metadata.finalizers field of the requested resource during the mutation phase of the admission.

  2. Watch appropriate resource lifecycle events & invoke the given callback.

  3. Remove the injected finalizer from the metadata.finalizers field of the requested resource.

When(a.ConfigMap)
.IsCreated()
.InNamespace("hello-pepr-finalize-create")
.WithName("cm-reconcile-create")
.Reconcile(function reconcileCreate(cm) {
Log.info({cm}, "external api call (create): reconcile/callback")
})
.Finalize(function finalizeCreate(cm) {
Log.info({cm}, "external api call (create): reconcile/finalize")
});