简体   繁体   English

Spring Cloud Consul配置Spring Cloud Config

[英]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. 我们希望使用Spring Cloud Consul进行服务发现,我的大学正在推动使用Spring Cloud Consul Config而不是Spring Cloud Config,我之前已经为相关项目实施过。 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. 问题是,Spring Cloud Config运行良好,并且具有无缝的开箱即用版本控制管道(git),用于动态集中管理属性。 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. 为了在Spring Cloud Consul Config中支持相同的功能,似乎需要重新发明已经融入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? 也就是说,让Spring Cloud Config Client指向Spring Cloud Config Server以获得更多“静态”环境属性(dev,qa,stage,production和static之间的内容不同)和Spring Cloud Consul Config用于纯动态属性(如服务)发现?

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 :/ 如果我错了,请有人纠正我,但是根据我的理解,为了使用Spring Cloud Consul Config支持“静态”属性的动态版本控制,我需要做些什么,我需要在git和物理之间进行某种管道“ / config“每个Spring Cloud Consul Config应用程序实例的运行实例的目录:/

tl;dr: I use spring cloud config and spring cloud consul but not spring cloud consul config. tl; dr:我使用spring cloud config和spring cloud consul但不使用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. 我没有专门使用spring cloud consul配置,因为我没有使用consul配置,但我使用的是一个Spring云配置服务器,它在领事中注册,我还有其他微服务通过consul访问spring cloud配置服务器进行服务发现。 Both server and client uses spring cloud consul to register and discover the config server. 服务器和客户端都使用spring cloud consul来注册和发现配置服务器。 And the config server and config clients both uses spring cloud config. 配置服务器和配置客户端都使用spring cloud配置。

Here is my setup: 这是我的设置:

Spring Cloud Config Server 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: bootstrap.properties:

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

application.properties: 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: Application.java:

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

Spring Cloud Client Application Spring Cloud Client应用程序

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: 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: Application.java:

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

So far as I understand, in case of configuration management, in compare with spring cloud config, Consul(with git2Consul) provides solution of data exchanging across multiple datacenter and failover of nodes. 据我了解,在配置管理的情况下,与spring cloud配置相比,Consul(与git2Consul)提供跨多个数据中心交换数据和节点故障转移的解决方案。

For single datacenter use, spring cloud config (with simple failover solution, eg LVS, master/slave, rsync mechanism etc) is enough. 对于单数据中心使用,spring cloud配置(具有简单的故障转移解决方案,例如LVS,主/从,rsync机制等)就足够了。

For service discovery, Consul has health check mechanism and can enable automatic switch of routings. 对于服务发现,Consul具有健康检查机制,可以自动切换路由。 In spring cloud config, extra work needs to be done to implement semi-automatic discovery. 在Spring cloud配置中,需要做额外的工作来实现半自动发现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM