Config Server bootstrap.yml
:
spring:
application:
name: configserver
profiles:
active: vault
cloud:
config:
server:
vault:
host: ${vault_server_host:localhost}
port: ${vault_server_port:8200}
scheme: ${vault_server_scheme:https}
backend: ${vault_backend:configserver}
Vault secrets:
$ vault kv get configserver/configclient
=== Data ===
Key Value
--- -----
foo VAUUULT
So, I'm able to get config values using curl
:
$ curl -X GET http://localhost:8888/configclient/default -H "X-Config-Token: f7b238dd-425f-52f8-2104-1e37ecf65ede"
{
"name":"configclient",
"profiles":[
"default"
],
"label":null,
"version":null,
"state":null,
"propertySources":[
{
"name":"vault:configclient",
"source":{
"foo":"VAUUULT"
}
}
]
}
So, I've tried to get foo
value from Config server from Config client. Config client bootstrap.yml
:
spring:
application:
name: configclient
cloud:
config:
uri: http://localhost:8888
headers:
X-Config-Token: ${vault_token}
However, it seems that Config client is not able to locate Config server:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.3.RELEASE)
2018-07-12 10:03:53.809 INFO 15448 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8888
2018-07-12 10:03:54.239 WARN 15448 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: 400 null
2018-07-12 10:03:54.256 INFO 15448 --- [ main] c.t.i.t.s.t.TdevConfigclientApplication : No active profile set, falling back to default profiles: default
So then, it's getting me that:
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'foo' in value "${foo}"
foo
is configured as @Value("${foo}")
:
@SpringBootApplication
@RestController
public class TdevConfigclientApplication {
@RequestMapping("/")
public String home() {
return "Hello World! " + this.foo;
}
@Value("${foo}")
private String foo;
public static void main(String[] args) {
SpringApplication.run(TdevConfigclientApplication.class, args);
}
}
Here you can see a more detailed config client trace snippet:
2018-07-12 10:29:05.249 INFO 17299 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8888
2018-07-12 10:29:05.457 DEBUG 17299 --- [ main] o.s.web.client.RestTemplate : Created GET request for "http://localhost:8888/configclient/default"
2018-07-12 10:29:06.023 DEBUG 17299 --- [ main] o.s.web.client.RestTemplate : Setting request Accept header to [application/json, application/*+json]
2018-07-12 10:29:06.092 DEBUG 17299 --- [ main] s.n.www.protocol.http.HttpURLConnection : sun.net.www.MessageHeader@3bb6b7e25 pairs: {GET /configclient/default HTTP/1.1: null}{Accept: application/json, application/*+json}{User-Agent: Java/10.0.1}{Host: localhost:8888}{Connection: keep-alive}
2018-07-12 10:29:06.121 DEBUG 17299 --- [ main] s.n.www.protocol.http.HttpURLConnection : sun.net.www.MessageHeader@3b1892d05 pairs: {null: HTTP/1.1 400}{Content-Type: application/json;charset=UTF-8}{Transfer-Encoding: chunked}{Date: Thu, 12 Jul 2018 08:29:06 GMT}{Connection: close}
2018-07-12 10:29:06.145 DEBUG 17299 --- [ main] o.s.web.client.RestTemplate : GET request for "http://localhost:8888/configclient/default" resulted in 400 (null); invoking error handler
2018-07-12 10:29:06.162 WARN 17299 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: 400 null
Any ideas?