Centralized Configuration using Spring Cloud Config Server

By -
Share:

There always a chance in which we have to put some properties employed in the application in the form of hard coded files. For instance, database connection properties, external file paths to read/write file from file system where we are required to put these values in a file and deploy the application, but in an environment like Microservices and rapid development, we will need putting this outside from the application. Because, in case of a change in the property file, the ideal case is not to redeploy the application. It also, fulfills many purposes, for instance,

  • For multiple instances of the application like prod and UAT, it is easy to replicate and maintain outside the application.
  • We do need to restart/redeploy the application in case of a change in a single property.
  • All the artifacts will be identical in this case

RC usage of Config Server

Spring has provided us an out of the box solution for this purpose. The config server is available off the shelf for this requirement to fulfill. For a client, we have developed a server in which all configurations are available for each application. Also, the customer is not required to restart the application whenever he is changing any property of an application. All the apps are getting the configuration values from the config server on the fly. The server is based on annotations as spring is recommending to use it for ease of development.

Components of Config Server

Repository area
It stores all property files in a version control system. You can use any traditional version control available, or you can save on file system as well.

REST endpoint
Each Microservice needs to talk to the config server so that it can resolve the property value. It has a REST endpoint through which Microservices can talk; you can also look into the resources using a browser.

Actuator
The Actuator refreshes REST endpoint in case of the change in a property. It updates the property without restarting the application.

In this brief article, we discussed the usefulness of configuration server nowadays. RC has immense knowledge around spring framework and its uses, you can contact us anytime. We will suggest you how to improve the environment and make it entirely cloud based.

Share: