我一直在擺弄春季雲配置,但有一個使用情況配置屬性分爲兩種類型:如何在Git和Vault複合環境存儲庫中使用Spring Cloud Config?
非祕密值,開發人員應該能夠查看和維護(如JDBC網址等)
祕密值,這應被視爲只有通過具有特殊訪問指定的人(如密碼)
所以我的支持「很感興趣保持「,目前在快照版本中可用。似乎我可以將Git用於開發人員管理的屬性,保管庫用於保密屬性,並對其進行配置,以便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"
}
}
]
}
,如果我在application.yml
扭轉order
設置,給Git的優先級高於庫沒關係。只要Vault配置文件處於活動狀態,它將作爲獨佔後端。
但是,如果我停用Vault配置文件,那麼同樣的捲曲操作不從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
)。我想知道是否這是問題,因爲標籤總是爲Vault提供null
。
您好Steve感謝這份報告。我會在下個禮拜看看。 –
您使用的是什麼版本的Spring Cloud?我只是試過這個,得到了這個,它爲我工作。 –
1.2.3(快照)。我只是在https://github.com/spring-cloud-samples/configserver –