4 Externalized Configuration Management

 

This chapter covers

  • Configuring Spring with properties and profiles
  • Leveraging external configuration with Spring Boot
  • Implementing a configuration server with Spring Cloud Config Server
  • Configuring applications with Spring Cloud Config Client

In the previous chapter, you built a RESTful application for managing a catalog of books. As part of the implementation, you defined some data to configure certain aspects of the application (in an application.yml file), for example, the Tomcat thread pool or connection timeout. The next step might be to deploy the application to different environments: first on a test environment, then staging, and finally production. What if you needed a different Tomcat configuration for each of these environments? How would you achieve that?

Traditional applications were usually packaged as a bundle, including both the source code and a series of configuration files containing data for different environments and selected through a flag at runtime. The implication was that every time you needed to update configuration data for a specific environment, you had to make a new application build. A variant to this process was to create a different build for each environment, meaning that you had no guarantee whether what you run in a staging environment would have worked in the same way in production because they would be different artifacts.

4.1 Configuration in Spring: properties and profiles

4.1.1 Properties: Key/value pairs for configuration

4.1.2 Profiles: Feature flags and configuration groups

4.2 Externalized configuration: one build, multiple configurations

4.2.1 Configuring an application through command-line arguments

4.2.2 Configuring an application through JVM system properties

4.2.3 Configuring an application through environment variables

4.3 Centralized configuration management with Spring Cloud Config Server

4.3.1 Using Git to store your configuration data

4.3.2 Setting up a configuration server

4.3.3 Making the configuration server resilient

4.3.4 Understanding the configuration server REST API

4.4 Using a configuration server with Spring Cloud Config Client

4.4.1 Setting up a configuration client

4.4.2 Making the configuration client resilient

4.4.3 Refreshing configuration at runtime

4.5 Summary