integrate eureka with kubernetes issue

12/1/2016

i have a (spring boot/spring cloud) application (micro-service 'MS' architecture) built with netflix tools and which i want to deploy it on kubernetes cluster (one master and 2 minions) to get advantage from its orchestration fact.

By the way, i created a kube-dns service on the cluster and i tried also to mount an eureka service (named eurekaservice) with 3 pods. From the other side, i run a micro-service with the next eureka configuration:

client:
  serviceUrl:
    defaultZone: http://eurekaservice:8761/eureka/

The good news is that every eureka pod on the cluster get notified about the new mounted MS instance. The bad news was that when the MS goes down, only one eureka pod get notified and the others no. Another thing, is that when i see the MS logfile, while mounted, it shows me the next errors:

Dec 01 09:01:54 ctc-cicd3 docker-current[1465]: 2016-12-01 06:01:54.469 ERROR 1 --- [nio-8761-exec-1] c.n.eureka.resources.StatusResource: Could not determine if the replica is available

Dec 01 09:01:54 ctc-cicd3 docker-current[1465]:
Dec 01 09:01:54 ctc-cicd3 docker-current[1465]: java.lang.NullPointerException: null
Dec 01 09:01:54 ctc-cicd3 docker-current[1465]: at com.netflix.eureka.resources.StatusResource.isReplicaAvailable(StatusResource.java:90)
Dec 01 09:01:54 ctc-cicd3 docker-current[1465]: at com.netflix.eureka.resources.StatusResource.getStatusInfo(StatusResource.java:70)
Dec 01 09:01:54 ctc-cicd3 docker-current[1465]: at org.springframework.cloud.netflix.eureka.server.EurekaController.status(EurekaController.java:63)
Dec 01 09:01:54 ctc-cicd3 docker-current[1465]: at sun.reflect.GeneratedMethodAccessor92.invoke(Unknown Source)
Dec 01 09:01:54 ctc-cicd3 docker-current[1465]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
Dec 01 09:01:54 ctc-cicd3 docker-current[1465]: at java.lang.reflect.Method.invoke(Method.java:606)


Dec 01 09:02:16 ctc-cicd3 docker-current[1465]: 2016-12-01 06:02:16.918  WARN 1 --- [nio-8761-exec-8] com.netflix.eureka.InstanceRegistry      : DS: Registry: lease doesn't exist, registering resource: MS - gateway-bbn50:MS:8090
Dec 01 09:02:16 ctc-cicd3 docker-current[1465]: 2016-12-01 06:02:16.919  WARN 1 --- [nio-8761-exec-8] c.n.eureka.resources.InstanceResource    : Not Found (Renew): MS - gateway-bbn50:MS:8090
Dec 01 09:02:16 ctc-cicd3 docker-current[1465]: 2016-12-01 06:02:16.927  INFO 1 --- [nio-8761-exec-5] com.netflix.eureka.InstanceRegistry      : Registered instance id 12.16.64.2 with status UP
Dec 01 09:02:17 ctc-cicd3 docker-current[1465]: 2016-12-01 06:02:17.061  INFO 1 --- [io-8761-exec-10] com.netflix.eureka.InstanceRegistry      : Registered instance id 12.16.64.2 with status UP
Dec 01 09:02:46 ctc-cicd3 docker-current[1465]: 2016-12-01 06:02:46.932  WARN 1 --- [nio-8761-exec-9] com.netflix.eureka.InstanceRegistry      : DS: Registry: lease doesn't exist, registering resource: MS - gateway-bbn50:MS:8090

I think what was causing the problem is that replicas was unable to see each others.

how can i resolve this issue!!

-- mootez
kubernetes
netflix-eureka
service-discovery
spring-boot
spring-cloud

3 Answers

12/4/2016

The problem here is that Eureka is a stateful app and you cannot scale it by just increasing the number of replicas.

See the Eureka "peer awereness" docs : http://cloud.spring.io/spring-cloud-netflix/spring-cloud-netflix.html

-- Pierre Besson
Source: StackOverflow

4/3/2020

Since you disabled eureka, only using zuul proxy :

server.ribbon.listOfServers=localhost:9090,localhost:9091,localhost:9092 server.ribbon.eureka.enabled=false

in case you are deploying on k8s (kubernetes), use the service name

ribbon: 
  eureka: 
    enabled: false

zuul:
  routes:
    organization-proxy:
      serviceId: organization-service
      path: /organization/**


organization-proxy:   
  ribbon:
    listOfServers: organization

enter image description here

-- Tiago Medici
Source: StackOverflow

12/6/2016

As it seems you want to replace Eureka discovery by Kubernetes discovery here is another answer (from http://cloud.spring.io/spring-cloud-netflix/spring-cloud-netflix.html) :

First disable eureka support in Ribbon:

ribbon:
  eureka:
   enabled: false

Then add a config property like this in your gateway for every microservice you want to access through your gateway (you could load those properties with a config server).

app1:   
  ribbon:
    listOfServers: app1-k8s-service-name
app2:   
  ribbon:
    listOfServers: app2-k8s-service-name

Then your gateway should be able correctly route calls to your microservices.

-- Pierre Besson
Source: StackOverflow