<p>Our application runs jobs on Kubernetes.
We are currently querying kubernetes to give feedback to the users about the statuses of jobs and once a job is completed also want to provide them the job (pod) logs. This happens often, eg every 30s.
We have such high amount of jobs now, that this pod querying and handling the information takes too long. </p>

<p>It would be great to be informed about kubernetes events: a pod is pending, scheduled, pulling, running, succeeded/failed. Not sure what is the best way to get these events in our application, but the main questions here is:</p>

<p><strong>Is there any event that a pod is terminated (successfully or in failure) or that a job is completed?</strong> </p>

<p>If this does not exist, is there a workaround to get to know whether a pod or job is terminated (so that we can go fetch the pod logs)?</p>

timv
<p><code>Kubectl get events</code> provides events happening in the cluster. For advanced scenarios you can check <a href="https://github.com/bitnami-labs/kubewatch" rel="nofollow noreferrer">kubewatch</a>.</p>

<p>Kubewatch is a Kubernetes watcher that currently publishes notification to available collaboration hubs/notification channels. Run it in your k8s cluster, and you will get event notifications through webhooks.</p>

<p>Another option would be to add a handler in preStop which sends an event before the pod/job is terminated</p>

<p><a href="https://kubernetes.io/docs/tasks/configure-pod-container/attach-handler-lifecycle-event/#define-poststart-and-prestop-handlers" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/configure-pod-container/attach-handler-lifecycle-event/#define-poststart-and-prestop-handlers</a></p>
