Spring Cloud Eureka with Config Server
Asked Answered
H

4

19

What is the recommended configuration when running both Config Server with Eureka Server? Should Config Server be a client of Eureka? Or should Eureka be dependent on Config Server properties for its configuration? Or is both OK?

Haplo answered 13/11, 2015 at 19:33 Comment(2)
I could only get it to work with centralizing the config for Eureka clients on the Config Server -- which for my setup seems better as the config to reach the config server is 1 line versus 6 lines for setting up Eureka and "auto-discover" the Config Server. Also, when I tried the auto-discover, I ended up getting errors with Eureka saying "No qualifying bean of type [com.netflix.appinfo.EurekaInstanceConfig] is defined: expected single matching bean but found 2: eurekaInstanceConfig,eurekaInstanceConfigBean". What did you end up deciding to do? What worked for you?Wooton
Yes, I haven't finished implementing it yet, but that's what I'm planning to do, have Eureka be a client of Config Server.Haplo
O
10

The default way to use Eureka and Config Server is to use Config First bootstrap. Essentially, you make eureka server a client of the config server but you don't make the config server a client of eureka.

As said by David Syer on these (and this) issues, the founder of spring cloud, you have to use the config server with a front end load balancer, so a single URL is already highly available.

I'm also a newbie in Spring Cloud but I agree with him since Eureka is a Service Discovery, IMHO it should function on it's problem domain only. It would make a complicated logic for Eureka servers who are asking the Config servers for it's configuration. I can't imagine how the Eureka Server would know which config server to get if the Config Server is also the Server of Eureka to get its list of defaultZone.

It would be much more simpler for me to separate the Config Server's HA.

Ogle answered 1/11, 2016 at 4:42 Comment(0)
B
6

Based on @Mideel's answer

Eureka and Config Client configuration (needs to be Bootstrap):

# bootstrap.yml
cloud:
    config:
      discovery:
        enabled: true # This is required
        service-id: configserver # Config Server's eureka registry name
      enabled: true # This is default true already

Config Server configuration:

spring:
  application:
    name: configserver # Needs to match client configuration

Register the Config Server with the annotation @EnableEurekaClient (it should be Auto Configured to register with Eureka already though)

Benedicite answered 28/2, 2020 at 19:32 Comment(1)
I think normalized name should be serviceId service-id is .properties file syntaxCairn
R
5

The Spring Cloud Config service provides configuration info for various other microservices, of which the Eureka service is one.

Each app/microservice is pointed to its configuration (from the Config service) via bootstrap.properties/.yml, which is loaded in the parent context for that application, before the app "recognizes" that it is a discovery/Eureka client per its annotated main class. This bit of documentation provides a bit more detail on that process.

Cheers, Mark

Rakeoff answered 22/3, 2016 at 15:22 Comment(1)
Your link is broken, can you update it?Shel
E
3

EDIT1: I think this is a wrong answer, see the replies

If you use Spring Boot:

I'm using Spring Microservices in Action as my guide book and based on the source code example there, we make the configuration server as the Eureka Client with the @EnableEurekaClient annotation and in the config server application.yml, we need to add this property:

spring: 
  cloud: 
    config: 
      discovery: 
        enabled: true

And in the other Eureka client that uses this config server, you need to add this property to the application.yml :

spring: 
  cloud: 
    config: 
      enabled: true

That's it, just set up the config server normally, I think behind the scene the config libraries from spring cloud will take care of the rest using Eureka.

Eckenrode answered 1/8, 2018 at 3:40 Comment(4)
This answer is not correct. spring.cloud.config.discovery.enabled is not for the config server, it's for every application needing to use the config server. The second property spring.cloud.config.discovery.service-id is the config server's application name registered with eureka.Benedicite
@Benedicite yeah after Googling around I think you're right. But I misunderstood because everything still works even without the client specifying spring.cloud.config.discovery.enabledEckenrode
Your answer pointed me in the right direction anyways. That's good. Googling about eureka and cloud config brings me here so I threw in my own answer. Thanks.Benedicite
Here is the link to the documentation explaining what @Benedicite called out.Fermat

© 2022 - 2024 — McMap. All rights reserved.