<p>I have some legacy application, which deployed on clustered environment. When one of the application nodes receives call it gets from some configuration file static list of all application nodes where application is deployed.</p>

<p>When all ip's collected it communicates with each app node over jmx. </p>

<p>Current aim is to <strong>migrate to k8s</strong>, so in this case list of application pods is dynamic and can be just stored as is. Need to implement something like service discovery. </p>

<p>Current thoughts is to implement some simple rest service that will run in separate pod, main aim of which is always return some list of ips (entrypoints) of application pods filtered by some predicate.</p>

<p><strong>So I have few questions:</strong></p>

<ol>
<li>Is it correct way to work? Any other options? (without changing legacy code)</li>
<li>Is there any ready solution for this? If not, how can I get information about needed pods inside my rest service?</li>
</ol>

liotur
<p>Define a service with a scope selector so all your special pods are included then you can list all your endpoints IP's asking the apiservice.<br>
You can check it's working with the  command.</p>

<p>kubectl get endpoints </p>

<p>After that remains how to execute this command inside your pod. That's another story. 
This link explain that matter 
<a href="https://kubernetes.io/docs/tasks/administer-cluster/access-cluster-api/#accessing-the-api-from-a-pod" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/administer-cluster/access-cluster-api/#accessing-the-api-from-a-pod</a>  </p>
