<p>If I have a service, pod etc. that I can query using a selector changes its ip address, is there a way to get notified?</p>

<p>For example, say my application needs to have a list of ip addresses of a pod, or the ip address of a service.  Since the container can go down and get recreated using kubernetes, is there a way to get notified when the containers go down and get recreated so I can then use the kubernetes API to get the latest values for the ip addresses?</p>

<p>This would be required for things like primary and slave databases etc.</p>

<p>Does kubernetes have a webhook type functionality that can be used to notify my app?</p>

<p>You can use <em>watch</em> API operations.</p>

<p>To watch all Endpoints objects:</p>

<pre><code>GET /api/v1/namespaces/{namespace}/endpoints?watch=true
</code></pre>

<p>To watch a specific Endpoints object:</p>

<pre><code>GET /api/v1/watch/namespaces/{namespace}/endpoints/{name}?watch=true
</code></pre>

<p>This creates a hanging HTTP GET request and you get notified whenever any of the watched objects changes.</p>

<p>See the <a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#list-endpoints-v1-core" rel="noreferrer">Kubernetes API reference</a>.</p>
