Describe the bug
When using a spring profile (e.g. SPRING_PROFILES_ACTIVE as kubernetes), the configuration YAML file unique to that profile (e.g. application-kubernetes.yml) doesn't seem to be sought-by or provided-to the spring boot client as expected. In addition, the ConfigDataLoader doesn't report the profile on boot which contradicts the application's report of which profiles are active, as shown here:
│ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) │
│ ' |____| .__|_| |_|_| |_\__, | / / / / │
│ =========|_|==============|___/=/_/_/_/ │
│ :: Spring Boot :: (v2.4.1) │
│ 2021-01-07 12:05:08.048 INFO [vets-service,,] 1 --- [ main] o.s.s.p.vets.VetsServiceApplication : Starting VetsServiceApplication v2.4.1 using Java 11.0.9.1 on vets-service-deployment-5bbb4bb84f-kws4z with PID 1 (/workspace/BOOT-INF/classes started by cnb in /workspace) │
│ 2021-01-07 12:05:08.052 INFO [vets-service,,] 1 --- [ main] o.s.s.p.vets.VetsServiceApplication : The following profiles are active: kubernetes │
│ 2021-01-07 12:05:08.295 INFO [vets-service,,] 1 --- [ main] o.s.b.context.config.ConfigDataLoader : Fetching config from server at : http://config-server-service.default.svc.cluster.local:8888 │
│ 2021-01-07 12:05:08.296 INFO [vets-service,,] 1 --- [ main] o.s.b.context.config.ConfigDataLoader : Located environment: name=vets-service, profiles=[default], label=null, version=668cd0749018689e9c1cd5419fac6420482deea9, state=null
Software versions
Spring Boot 2.4.1 Spring Cloud BOM 2020.0.0
Sample
-
K8s deployment YAML for the 2020.0.0 version of my petclinic-microservices demo is here. All images are in public docker hub.
-
Config server's config files repo is here.
-
Spring codebase for this sample is here.
Comment From: benwilcock
Supplementary info
If a profile based config file (e.g. application-kubernetes.yml) is included locally on the classpath, then the application appears to use it as expected. Also, config files made available the config server named to reflect the application's spring.application.name property (e.g. vets-service.yml) also seem to be picked up as expected. The issue seems to only affect profile based names hosted remotely on the config server and required by the application via the config client.
Comment From: spencergibb
please try with version 3.0.1 https://github.com/spring-cloud/spring-cloud-release/wiki/Spring-Cloud-2020.0-Release-Notes#known-issues
Comment From: kuberr
@benwilcock You can explicitly tell the config server what profiles to look for using a property in your application.yml (the one inside your app, not the one in the cloud server). This can serve as a temporary workaround while the cloud team fixes this issue (or presumably it is already fixed in 3.0.1). For instance, to tell the config server to use your active profiles instead of pointless default profile use this:
server.port: 9003
spring:
application.name: user-repository
config.import: configserver:http://localhost:8888
cloud.config.profile: ${spring.profiles.active}
Comment From: spencergibb
we can reopen if 3.0.1 didn't fix things.