2
votes

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

1
Q: Do the both microservices are deployed out of openshift? - xds2000
Microservices are deployed inside Openshift. 1) I have 3 pods, 1 for eureka and 2 for microservices. 2) Both microservices register with eureka. 3) But in Eureka, it is registering as microservice's pod IP:PORT. - John Seen
eureka.instance.hostname = should be use service name. it should be found in your openshift console. - xds2000

1 Answers

2
votes

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