1

I am using Spring Cloud Config Server first time and have a basic query.

Spring Config server externalises the configuration to a separate git repository.

Why would I create a separate repository just for the configurations?

Is not it advisable to have mono repository with all application code and configurations in a single repo than creating a separate one just for configurations.

We have multiple micro services all present in the same repository. Should not the config server to be one of the micro service present in the same repository where the other application code is?

So, in my multi-module gradle project, I can make config-server as one of the module and give the same repository name as git backed url in config-server. Is this advisable? If yes, where should I keep the configurations in config-server? Inside resources?

Thank you.

Rahul
  • 21
  • 3
  • 1
    No, definitely NOT advisable to keep it in the same repo as code. If someone hacks your server and gets your github credentials, do you want them to have full access to your source code? – SledgeHammer May 24 '21 at 19:45
  • 2
    @SledgeHammer If someone gets access to my github credentials then he will have access to all my repositories. How does it make a difference if I keep all code in a single repo or multiple? – Rahul May 25 '21 at 02:58
  • 1
    You don't use *your* personal credentials to access the config repo in your application, you create a machine (service) account that only has read access to your config repo. – SledgeHammer May 25 '21 at 03:50

1 Answers1

2

When working with microservices it is advisible to have one repository for each microservice. The config server is a microservice as well, therefore it should be put in a separate repository.

Each microservice should have its own independent code repository and your application configuration should never be in the same repository as your source code.

You can read more about this here: Heroku's The Twelve-Factor App. Here you can find 12 best practices to use when building microservices, but for this question I recommend looking at

Marina
  • 41
  • 6
  • What are your recommendations for configuration servers? – Lucian Aug 11 '21 at 14:06
  • 1
    @LucianNut If you are using Spring Cloud, the best solution is the Spring Cloud Configuration Server. This open source project is providing many implementations for storying configuration data such as: Git (which in my opinion is the most popular), Eureka, Consul, or a shared filesystem (not recommended for medium or large cloud applications). – Marina Aug 11 '21 at 14:30
  • 1
    @Marina: FYI, I've heard Facebook & Google use monorepos for production microservices (as opposed to a separate repos for each microservice). – Kode Charlie Dec 09 '21 at 17:23