DEV Community

Krish Kishan
Krish Kishan

Posted on

shared configuration in microservices

Spring Boot with Spring Cloud Config Server, shared configuration is achieved by placing common properties in a central repository (like Git, Vault, CredHub, or JDBC) under the application.* scope so that all client applications can inherit them. Application-specific files then override these shared defaults.

let me explain the scenario, assume few applications are running under config server, each application has it's own config(.properties) file placed in config server, expected retrieve it on demand while spring boot initializes , like this property files contains n number of common properties for Ex.. database config, kafka config, logging ....this is exactly moment, where we can customize the configuration data, place them(common properties) in specific file(.properties) under the same config server, if we can make it available to all other components/applications, it can make easier to manage them further change/updates.

Key Concepts of Shared Configuration

  1. File-Based Repositories (Git, SVN, Native) Shared files: application.properties, application.yml, application-*.properties

These files apply to all client applications under config server. this files should be placed under ROOT folder of config repository

Overrides: Each service can have its own {app-name}.properties to override shared defaults.no other setup is required.

Drawback: Every component/application will get access of properties from above files, it is impossible to restrict them in case not required/no use

Best practice: Keep global defaults in application.yml and override them in service-specific files.

Top comments (0)