<p>I have two simple Springboot microservice which connect with each other using Spring Eureka.</p>

<p>Steps -</p>

<ol>
<li>First I run Eureka server.  </li>
<li>Then I run both the microservices.</li>
<li>So both microservices register &amp; discovery from Eureka server.</li>
</ol>

<p>I want to achieve the same in Openshift v3. I know Openshift uses Kubernates Service for achieving load-balancing &amp; pod-discovery. But can I use Eureka server in Openshift?</p>

<p>In Openshift I have 3 pods..</p>

<ol>
<li>1 pod for eureka and 2 pods for microservices. </li>
<li>Both microservices register with eureka.</li>
<li><p>But in Eureka, it is registering as microservice's pod IP:PORT.</p></li>
<li><p>So when discovering the microservice tries to make the call to POD
IP &amp; fails.</p></li>
</ol>

<p>Generally, to access POD IP we need to invoke service layer in Openshift.
So how can I make eureka server register server layer IP:PORT instead of POD's IP:PORT</p>

<p>for Spring Cloud Eureka Server project:application.yml</p>

<pre><code>server:
  port: 8761

eureka:
  instance:
    hostname: server.eureka.svc   # it should be service url in openshift cluster.
  client:
    fetch-registry: false 
    register-with-eureka: false 
    service-url:
      defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
</code></pre>

<p>For Spring Cloud Eureka Client project: application.yml</p>

<pre><code>eureka.client.serviceUrl.defaultZone=http://server.eureka.svc8761/eureka/
eureka.instance.preferIpAddress=false
</code></pre>
