【问题标题】:Spring Cloud Config - Multiple Composite Repositories?Spring Cloud Config - 多个复合存储库?
【发布时间】:2018-08-08 01:46:56
【问题描述】:

是否可以使用多个复合存储库配置 Spring Cloud Config?我们的设置使用多个基于团队的存储库:

spring:
  cloud:
    config:
      server:
        git:
          repos:
            teamA:
              cloneOnStart: true
              pattern: teama-*
              searchPaths: '{profile}'
              uri: file:///etc/config/teama
            teamB:
              cloneOnStart: true
              pattern: teamb-*
              searchPaths: '{profile}'
              uri: file:///etc/config/teamb 

我们希望每个团队现在都从 2 个不同的 git 存储库中提取数据。我认为多个 Composite 存储库 (https://cloud.spring.io/spring-cloud-config/single/spring-cloud-config.html#composite-environment-repositories) 是我们想要的,但我不知道如何组合它们,或者是否可能。

澄清:

我希望每个团队都从 两个 repos 中提取配置数据,而不仅仅是 1. 在伪代码中:

spring:
  cloud:
    config:
      server:
        git:
          repos:
            teamA:
              repo1:
                key1: repo1
                key2: repo1
              repo2:
                key1: repo2
                key2: repo2

【问题讨论】:

    标签: spring-cloud-config


    【解决方案1】:

    在这种情况下,您可以使用复合配置。下一个配置对我有用,客户端服务正在使用来自 2 个存储库的属性

    spring:
      profiles:
        active: composite
      cloud:
        config:
          server:
            composite:
            -
              type: git
              cloneOnStart: true
              uri: https://github.com/..../test-config
            -
              type: git
              cloneOnStart: true
              uri: https://github.com/..../test-config-2
    

    您可能需要根据需要为每个配置“searchPaths”。配置文件应该是复合的(至少一个配置文件)

    【讨论】:

    • 我更新了我的问题。如果可能的话,我希望每个团队都能从 2 个存储库中获取信息。
    • 您是否有针对不同存储库中相同项目的团队特定配置,并希望根据客户资料进行配置?或者您只想为不同的项目使用 2 个具有不同配置的 git 存储库?您在使用主要问题中提到的复合配置时遇到了什么问题?
    • 实际用例是这样的:每个团队管理自己的仓库,但我们希望在所有团队的公共仓库中管理一些公共属性。所以我们希望 teamA 从 teamA repo 和 common repo 中读取。
    • 修改了响应。这个示例配置对我有用(刚刚尝试过)。一个存储库包含一些属性,同一服务的另一个不同属性。如果他们启动,服务需要所有。如果属性相同,优先级由配置文件中出现的顺序决定
    • 我刚刚回到这个话题。在您上面的测试配置中,您点击了什么休息 url 从两个 repos 中获取值。我只得到一个 404,但 acuator 端点显示配置正确加载,所以我肯定做错了什么。
    猜你喜欢
    • 2020-11-13
    • 2021-08-13
    • 2020-07-23
    • 2018-05-21
    • 2017-06-29
    • 2019-06-30
    • 2016-05-14
    • 2016-02-18
    • 2016-01-15
    相关资源
    最近更新 更多