2

I know the advantages of implementing a remote configuration management system, and specifically of the Spring Cloud configuration server. From Spring Microservices in Action book, Chapter 2:

When a microservice starts, any environment-specific information or application configuration information data should be

  • Passed into the starting service as environment variables
  • Read from a centralized configuration management repository

As I understand, when you use a Config First Bootstrap approach, the only piece of configuration that should be in any other microservice is related to the config server (e.g. specifying the spring.application.name in bootstrap.yml and passing the spring.cloud.config.uri and spring.profiles.active as environment variables). No need for application.yml at all.

So, I'm a little confused after seeing some people asking (here, here and here) how to overwrite the remote configurations locally and read this Overriding the Values of Remote Properties section in Spring Cloud documentation:

The property sources that are added to you application by the bootstrap context are often "remote" (e.g. from a Config Server), and by default they cannot be overridden locally, except on the command line. If you want to allow your applications to override the remote properties with their own System properties or config files, the remote property source has to grant it permission by setting spring.cloud.config.allowOverride=true (it doesn’t work to set this locally). (...)

Is there a valid case in Spring Cloud to set a partial local configuration or even override the remote configuration?

Community
  • 1
  • 1
lcnicolau
  • 3,252
  • 4
  • 36
  • 53

1 Answers1

1

You can refer this https://github.com/spring-cloud/spring-cloud-config/issues/359, as the author said: an app can't decide on its own that it can override configuration from the remote source

So, you can't set spring.cloud.config.allowOverride=true locally.

You can check the source code of PropertySourceBootstrapProperties.java. There are three params to control the config.

If you want override the remote configuration, just set spring.cloud.config.overrideNone=true in remote git config.

Chao Jiang
  • 483
  • 3
  • 13
  • Thanks @ChaoJiang, but this does not answer the question at all, not even try to answer it. It seems an answer to [this other question](https://stackoverflow.com/q/43800256/4071001) I refer in this question. Most of this information is in the question itself, and the rest in [my own answer](https://stackoverflow.com/a/55222171/4071001) to that other question. I know how to override the remote configuration, the question here is if there is a valid case in Spring Cloud to set a partial local configuration or even override the remote configuration. – lcnicolau Mar 21 '19 at 20:33
  • Sorry for misunderstanding your question, but I'm a little confused, are you want to override the remote config locally or something else ? – Chao Jiang Mar 22 '19 at 10:05
  • I want to know if it's ok (_if it's a good practice_) to set a partial local configuration or even override the remote configuration, or if this should be avoided whenever possible (as I believe). – lcnicolau Mar 23 '19 at 04:47