Last month I wrote a primer on concepts around 12 factor app. Before getting into the details of the Spring Cloud Config Server, I must refresh on the principle #3 from the list presented in that post.
The key takeaways from this postulate for a cloud-native microservices application are:
Key Features of Spring Cloud Config Server
Spring Cloud Config Server Alternatives
3 – Configuration |
Store config in the environments |
Configuration information must be separate from the source code. This may seem so obvious, but often we are guilty of leaving critical configuration parameters in the scattered in the code. Instead, applications should have environment specific configuration files. The sensitive information like database password or API key should be stored in these environment configuration files in encrypted format.
The key takeaways from this postulate for a cloud-native microservices application are:
- Do not store configuration as part of the deployable unit (in the case of lead microservice - inside the jar or war if you are still deploying war like the good old days). Instead, store it in an external location and make it easily accessible during run-time.
- Configuration files should be separated based on the environment where the microservice is going to run. For example - it is a common practice to maintain environment-specific configuration files like "DEVELOPMENT", "TEST","STAGING", "PRODUCTION" etc.
- It is a very common practice to store sensitive information like user id and password for database etc as hard coded in plain text format. It is advised to store such information in environment specific files but in an encrypted format.
- Change in the configuration should not result in application/service to go through the entire build, test, release and upgrade cycle.
Key Features of Spring Cloud Config Server
- Enables centralized configuration management for all environments and different applications.
- Provides server based configuration management accessible over HTTP/HTTPS
- Configuration information is stored in repositories managed by the config server.
- Provides client-side support for applications to access the configuration properties at startup and cache them.
- Configuration properties can be version controlled depending on the underlying repository support.
- Any changes to configuration properties/values can be propagated to all the client applications. The client side support allows these changes to be applied transparently / refreshed without the need to restart the application again.
- Confidential information can be encrypted.
- Maps to Spring core concepts of Environment, PropertySource, Profile and Value. Thus it is easy to use in Spring applications and microservices.
- Facilitates continuous delivery pipelines by supporting configuration for different environments.
- It can be used by applications running in any language as the config server is nothing more than a REST endpoint serving configuration managed by an underlying repository. For example.NET clients can also use Spring Cloud Config Server. (More details can be found here - https://steeltoe.io/).
- Supports Git as the primary storage repository for configuration. However other repositories like a file system, Hashicorp Vault are also supported out of the box. The support for MongoDB is in incubation as of this writing.
- Monitoring of the config server is also possible.
- Easy to configure and launch.
- Can be easily containerized.
- Properties are not cached on the server side.
- Each request leads to calls to the backing repository which can lead to multiple remote calls.
- High availability and failover features are limited.
- Dynamic update of configuration properties on the server is very cumbersome.
Spring Cloud Config Server Alternatives
Note that none of these alternatives map to Spring Environment, PropertySource or Profile. Hence it will require a lot of plumbing to provide the features provided by Spring Cloud Config Server. So Spring Cloud Config Server is our tool of choice for configuration data management in the cloud-native architecture.
Taking stock
So far I have covered only a few pieces of the Spring cloud-native application architecture jigsaw. I have only written about Spring Boot for microservices development and now I am going to write about Spring Cloud Config Server. I will gradually cover all the boxes in figure 1, to complete all the puzzles in the jigsaw.
Figure 1 - Spring Cloud Jigsaw |
Whats's next?
This post was dedicated to some theory behind, the Spring Cloud Config server. In the next post I will get back to hands-on work again and setup the Spring cloud config server and test it using a simple browser based client. Stay tuned for more exciting stuff.
Comments
Post a Comment