I'm working on an implementation of config-server as per Manning's book Spring microservices in action 2e and I encountered a problem that the config server doesn't read properties from the default profile.
My vault path is secret/licensing-service/default
, I'm able to read the vault config for a default profile via this command
curl -X GET -H "X-Vault-Token:myroot" http://127.0.0.1:8200/v1/secret/data/licensing-service/default | jq
However when I enable debug logging and issue a request:
curl -X "GET" "http://localhost:8071/licensing-service/default" -H "X-Config-Token: myroot" | jq
{
"name": "licensing-service",
"profiles": [
"default"
],
"label": null,
"version": null,
"state": null,
"propertySources": []
}
I see that spring tries to issue the following HTTP requests:
2022-11-13 15:41:41.272 DEBUG 92277 --- [nio-8071-exec-9] o.s.web.client.RestTemplate
: HTTP GET http://127.0.0.1:8200/v1/secret/data/licensing-service
2022-11-13 15:41:42.100 DEBUG 92277 --- [nio-8071-exec-9] o.s.web.client.RestTemplate
: HTTP GET http://127.0.0.1:8200/v1/secret/data/application
As can be seen it strips a default keyword from the URL, I found that it does so in the following class - https://github.com/spring-cloud/spring-cloud-config/blob/main/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/AbstractVaultEnvironmentRepository.java In particular here:
private List<String> scrubProfiles(String[] profiles) {
List<String> scrubbedProfiles = new ArrayList<>(Arrays.asList(profiles));
scrubbedProfiles.remove("default");
return scrubbedProfiles;
}
What am I doing wrong and how do I make it read data from the default profile? Everything described above works for dev profile with vault path secret/licensing-service/dev
This is the config of my configuration server:
spring:
application:
name: config-server
profiles:
active: vault
cloud:
config:
server:
vault:
port: 8200
host: 127.0.0.1
kv-version: 2
profile-separator: /
server:
port: 8071