如何将Spring Cloud Config与Git and Vault复合环境存储库一起使用?

史蒂夫·珀金斯(Steve Perkins):

我一直在修改Spring Cloud Config,但是有一个用例,其中config属性分为两种类型:

  1. 非秘密值,开发人员应能够查看和维护(例如JDBC URL等)

  2. 秘密值,只有具有特殊访问权限的指定人员才能查看和维护(例如密码)

因此,我对快照版本中当前提供的对“ Composite Environment Repositories的支持非常感兴趣似乎我可以对开发人员管理的属性使用Git,对秘密属性使用Vault,并对其进行配置,以便在发生冲突时Vault始终优先于Git。

但是,我发现Vault不仅总是优先考虑……它还被用作独家后端。Git的任何属性都不会返回。

我的application.yml样子是这样的:

spring:
  profiles:
    active: git, vault
  cloud:
    config:
      server:
        vault:
          order: 1
        git:
          uri: https://github.com/spring-cloud-samples/config-repo
          basedir: target/config
          order: 2

我已经像这样将属性写入保险柜:

vault write secret/foo foo=vault

我这样调用我的配置服务器:

curl -X "GET" "http://127.0.0.1:8888/foo/default" -H "X-Config-Token: a9384085-f048-7c99-ebd7-e607840bc24e"

但是,JSON响应有效负载仅包含Vault属性。Git一无所有:

{
    "name": "foo",
    "profiles": [
        "default"
    ],
    "label": null,
    "version": null,
    "state": null,
    "propertySources": [
        {
            "name": "vault:foo",
            "source": {
                "foo": "vault"
            }
        }
    ]
}

如果我颠倒了中的order设置application.yml,则赋予Git优先于Vault的权限并不重要只要保管库配置文件处于活动状态,它就可以用作专有后端。

但是,如果我停用了保管库配置文件,则相同的curl操作确实会从Git后端返回结果:

{
    "name": "foo",
    "profiles": [
        "default"
    ],
    "label": "master",
    "version": "30f5f4a144dba41e23575ebe46369222b7cbc90d",
    "state": null,
    "propertySources": [
        {
            "name": "https://github.com/spring-cloud-samples/config-repo/foo.properties",
            "source": {
                "democonfigclient.message": "hello spring io",
                "foo": "from foo props"
            }
        },
        {
            "name": "https://github.com/spring-cloud-samples/config-repo/application.yml",
            "source": {
                "info.description": "Spring Cloud Samples",
                "info.url": "https://github.com/spring-cloud-samples",
                "eureka.client.serviceUrl.defaultZone": "http://localhost:8761/eureka/",
                "foo": "from-default"
            }
        }
    ]
}

我有什么想念的吗?为什么Git属性和Vault属性不...好吧,“复合”在一起?

文档中唯一的示例显示了Git和Subversion一起使用,并且有一条注释警告您所有存储库都应包含相同的标签(例如master)。我想知道这是否是问题所在,因为该标签始终null用于保险柜。

马库斯K:

我相信您的依赖项一定有问题。我还用git和Vault设置了一个Spring Cloud配置服务器,它工作得很好。我认为强制使用1.3.0-BUILD.SNAPSHOT是不够的。Spring cloud config 1.3.0-BUILD.SNAPSHOT取决于spring-vault-core。您可能缺少此依赖性。这可能会导致您在注释之一中提到的bean创建失败。这是带有git和Vault的示例项目的链接随时检查。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Spring Cloud Config-Git存储库错误

如何将Azure DevOps Git存储库与Azure静态Web应用一起使用?

如何将 vim-fugitive 与 git 裸存储库一起使用?

在Spring Cloud Config中使用@PropertySource-Git

Spring Cloud Config-多个复合存储库?

在没有Git存储库的情况下使用Spring Cloud Config

如何将Firebase存储映像与Google Cloud Vision API一起使用?

Spring Cloud Config自定义环境存储库

如何将Git的交互式rebase与仅本地存储库一起使用(无远程/源)?

Spring Cloud Config Service-Git与本机

如何将Spring Cloud与Logback集成在一起?

如何将git config存储为存储库的一部分?

如何设置 Pivotal Cloud Foundry Config Server 以使用来自我的 git 存储库的多个搜索路径?

如何将Google Cloud Functions与自定义Google Cloud端点一起使用?

如何将github存储库配置为Spring Cloud Server的配置存储库?

是否可以将docker.run命令与spring.cloud.config.uri一起传递?

使用SSH密钥进行Git并在Docker中运行的Spring Cloud Config Server

将Git存储库与安全数据一起使用

将 SourceTree (Git GUI) 与 Subversion (SVN) 存储库一起使用有哪些选项?

如何将本地更改与git中远程存储库上的更改集成在一起?

如何在github https存储库地址上将git与ssh一起使用?

如何将Spring Retry与带有VaultPropertySource的Spring Vault配置一起使用?

带有Vault和git后端的spring-cloud-config服务器中的logback.xml

如何将PNPM与Google Cloud Build一起使用?

如何将Python OpenID Connect模块与IBM Cloud App ID一起使用?

如何将 RLS 与复合字段一起使用

如何使用Cloud 9更改git存储库

Spring Config Server Vault 后端:cloud.config.server.vault 或 cloud.vault

将spring-cloud和netflix Eureka一起使用时,如何使Discovery Client工作?