John Seen
John Seen

Reputation: 731

Spring Eureka on Openshift

I have two simple Springboot microservice which connect with each other using Spring Eureka.

Steps -

  1. First I run Eureka server.
  2. Then I run both the microservices.
  3. So both microservices register & discovery from Eureka server.

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

In Openshift I have 3 pods..

  1. 1 pod for eureka and 2 pods for microservices.
  2. Both microservices register with eureka.
  3. But in Eureka, it is registering as microservice's pod IP:PORT.

  4. So when discovering the microservice tries to make the call to POD IP & fails.

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

Upvotes: 2

Views: 6160

Answers (1)

xds2000
xds2000

Reputation: 1194

for Spring Cloud Eureka Server project:application.yml

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/

For Spring Cloud Eureka Client project: application.yml

eureka.client.serviceUrl.defaultZone=http://server.eureka.svc8761/eureka/
eureka.instance.preferIpAddress=false

Upvotes: 2

Related Questions