[BETA] Consul

警告!这是BETA质量的一个新功能。使用它自己承担风险!反馈非常受欢迎!

Consul 概况 overview

作为替代JHipster注册表您可以选择使用 Consul, 从Hashicorp数据中心管理解决方案。 相比较 Eureka 相比,它具有很多优点:

  • 在多节点集群中操作比Eureka更容易。
  • 它有利于可用性的一致性,从而更快地传播集群状态的变化。
  • Consul 服务发现可以通过其 DNS interfaceHTTP API简单地与现有应用程序进行互操作。

要开始开发依赖于Consul注册表的应用程序,可以在docker容器中启动Consul实例:

  • run docker-compose -f src/main/docker/consul.yml up to start a Consul server in dev mode. Consul will then be available on port 8500 of your Docker host, so if it runs on your machine it should be at http://127.0.0.1:8500/.

You can also use the Docker Compose subgenerator to generate a docker configuration for several consul-enabled applications.

应用配置 Application configuration with Consul

如果您在生成JHipster微服务或网关应用程序时选择了Consul选项,那么它们将被自动配置为从Consul的 Key/Value store存储中检索其配置。.

Key/Value (K/V) store 可以通过两种方式被更改,一种是 UI available 在 http://localhost:8500/v1/kv/;另一种是 REST API. 但是,以这种方式进行的更改是临时的,并且将在Consul服务器/群集关闭时丢失。因此,为了帮助您轻松与Key / Value存储交互,并将您的配置管理为简单的YAML文件,JHipster Team开发了一个小工具:consul-config-loader. 在从consul.yml docker-compose文件启动Consul时, consul-config-loader 会自动配置,但也可以作为独立工具运行。它可以以两种模式运行:

  • a dev mode, where YAML files from the central-server-config directory are automatically loaded into Consul. Moreover any change to this directory will be immediately synchronized with Consul.
  • a prod mode, that uses Git2Consul to setup the YAML files contained in a Git repository as a configuration source for the Key/Value store.

Note that as with the JHipster Registry, your configuration files will need to be named appname-profile.yml where appname and profile correspond to the application’s name and profile of the service that you want to configure. For example, adding properties in a consulapp-prod.yml file will set those properties only for the application named consulapp started with a prod profile. Moreover, properties defined in application.yml will be set for all your applications.

results matching ""

    No results matching ""