<p>We have a system of two application A &amp; B deployed over kubernetes cluster. What we need is to set an event/trigger in kubernetes. So each time a pod of application B is created, it will trigger an action to add its IP to configmap. Also when any pod of application B is deleted, it will trigger an action to remove its IP from the configmap.</p>

<p>Is there any built in object in kubernetes to perform such function, or do we need a 3rd party plugin?</p>

Hanna
<p>Basically you have two options:</p>

<ul>
<li>Use the kubernetes (watch) API and handle the pod created/deleted events accordingly</li>
<li>Use container lifecycle hooks to react to container creation/deletion, <a href="https://kubernetes.io/docs/tasks/configure-pod-container/attach-handler-lifecycle-event/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/configure-pod-container/attach-handler-lifecycle-event/</a></li>
</ul>

<p>The later is at the container level, but should work for your use case as well.</p>
