3 Configuring microservices

 

This chapter covers

  • Externalized configuration
  • MicroProfile Config
  • Accessing application configuration
  • Configuration sources
  • Quarkus configuration features
  • Using Kubernetes ConfigMaps and Secrets

Chapter 2 introduced the Account service, which runs both locally and in Kubernetes. It can run in many more than two contexts, as shown next. Each context varies, having external services like a database, messaging system, and backend business microservices. The Account service has to interact with each service in its context, each with configuration requirements.

Figure 3.1 represents how enterprises may use different databases depending on the context. The developer uses a local desktop database during development, like the H2 embedded database. Integration testing uses a low-cost database like PostgreSQL. Production uses a large-scale enterprise-grade database like Oracle, and staging mimics production as closely as possible, so it also uses Oracle. The application needs a way to access and apply a configuration specific to each context without having to recompile, repackage, and redeploy for each context. What is required is externalized configuration, where the application accesses the configuration specific to the context in which it is running.

Figure 3.1 Example microservice contexts

3.1 MicroProfile Config architecture overview

3.2 Accessing a configuration

3.3 The Bank service

3.3.1 Creating the Bank service

3.3.2 Configuring the Bank service name field

3.4 Configuration sources

3.5 Configuring the mobileBanking field

3.6 Grouping properties with @ConfigProperties

3.7 Quarkus-specific configuration features

3.7.1 Quarkus configuration profiles

3.7.2 Property expressions

3.7.3 Quarkus ConfigMapping

3.7.4 Run-time vs. build-time properties

3.8 Configuration on Kubernetes

3.8.1 Common Kubernetes configuration sources

Summary