Kubernetes pod lifecyle notification for CronJob

10/21/2019

I would like to get invoke some API for notification when a CronJob starts and completes.

I can have a initcontainer that invokes the API to inform that the Job got started. But, Is there any way to invoke the API just before the pod dies. I dont want this logic in the CronJob main container.

-- user1578872
kubernetes

1 Answer

10/21/2019

Kubernetes provides an API which supports watch, so you are immediately notified when changes of the kubernetes state happens.

This way you can listen for creation/completion/deletion of Job objects.

You can use the API from inside and outside the Kubernetes cluster, as long as the API server is reachable.

-- Thomas
Source: StackOverflow