Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Cloud Consul Config over Spring Cloud Config

I'm having a real tough time with this one. We want to use Spring Cloud Consul for service discovery and my colleges are pushing the idea to use Spring Cloud Consul Config over Spring Cloud Config, which I have already previously implemented for a related project. The thing is, Spring Cloud Config works great and has a seamless out-of-the-box version control conduit (git) for a dynamic centralized management of properties. In order to support this same functionality in Spring Cloud Consul Config it seems would require re-inventing the wheel already baked into Spring Cloud Config.

Does anyone have experience using both? Would it make sense to use both together? That is, have Spring Cloud Config Client pointing to a Spring Cloud Config Server for the more "static" environment properties (things that vary between dev, qa, stage, production both otherwise static) and Spring Cloud Consul Config for pure dynamic properties like service discovery?

Someone please correct me if I am wrong but from my understanding what I will need to do in order to support dynamic version control for "static" properties using Spring Cloud Consul Config, I would need some kind of conduit between say git and the physical "/config" directory of the running instance of each Spring Cloud Consul Config application instance :/

like image 285
Starlton Avatar asked Nov 17 '15 04:11

Starlton


People also ask

What is spring cloud consul?

Spring Cloud Consul provides Consul integrations for Spring Boot apps through autoconfiguration and binding to the Spring Environment and other Spring programming model idioms.

What are the default values for spring cloud consul host and spring cloud console port respectively?

The default service name, instance id and port, taken from the Environment , are ${spring.application.name} , the Spring Context ID and ${server. port} respectively. To disable the Consul Discovery Client you can set spring.

Which is better consul or Eureka?

Consul and Eureka can be categorized as "Open Source Service Discovery" tools. "Great service discovery infrastructure" is the primary reason why developers consider Consul over the competitors, whereas "Easy setup and integration with spring-cloud " was stated as the key factor in picking Eureka.

What is spring cloud configuration?

Spring Cloud Config provides server and client-side support for externalized configuration in a distributed system. With the Config Server you have a central place to manage external properties for applications across all environments.


1 Answers

tl;dr: I use spring cloud config and spring cloud consul but not spring cloud consul config.

I did not use spring cloud consul config specifically since I am not using consul config, but I am using a spring cloud config server that register itself in consul and I have other microservices accessing the spring cloud config server through consul for service discovery. Both server and client uses spring cloud consul to register and discover the config server. And the config server and config clients both uses spring cloud config.

Here is my setup:

Spring Cloud Config Server

Dependencies:

org.springframework.cloud:spring-cloud-config-server
org.springframework.cloud:spring-cloud-starter-consul-discovery
org.springframework.boot:spring-boot-starter-actuator

bootstrap.properties:

spring.application.name=config-server
spring.cloud.consul.host=CONSUL_HOSTNAME
spring.cloud.consul.port=CONSUL_PORT

application.properties:

spring.cloud.config.server.git.uri=GIT_REPO_URL
spring.cloud.config.server.git.username=GIT_REPO_USERNAME
spring.cloud.config.server.git.password=GIT_REPO_PASSWORD

Application.java:

@SpringBootApplication
@EnableConfigServer
@EnableDiscoveryClient
public class Application
{
    public static void main(String[] args)
    {
        SpringApplication.run(Application.class);
    }
}

Spring Cloud Client Application

Dependencies:

org.springframework.cloud:spring-cloud-starter-config
org.springframework.cloud:spring-cloud-starter-consul-discovery
org.springframework.boot:spring-boot-starter-web
org.springframework.boot:spring-boot-starter-actuator

bootstrap.properties:

spring.application.name=client-app-name
spring.cloud.consul.host=CONSUL_HOSTNAME
spring.cloud.consul.port=CONSUL_PORT
spring.cloud.config.discovery.enabled=true
spring.cloud.config.discovery.serviceId=config-server

Application.java:

@SpringBootApplication
@EnableDiscoveryClient
public class Application
{
    public static void main(String[] args)
    {
        SpringApplication.run(Application.class);
    }
}
like image 58
Nicolas Lacombe Avatar answered Oct 10 '22 15:10

Nicolas Lacombe