Managing configurations in microservices
Tags: microservices, springboot, kubernetes, consul
Published: 2020-10-23 15:33:41

*Disclaimer*
_This post is part of a weekly writing challenge. Two of my friends and I agreed on holding a writing challenge in order to gain the writing habit as well as improving our writing skills._
<br/>
###Introduction
In the age of cloud environments and microservices architecture, a need to different way to mange the configurations for application/application instances has appeared. 

<br/>
For that purpose, software architects have many options to choose from. In this article we will talk briefly about some of the available options. In the next parts of this article we will go through each option in some details.
<br/>
The solutions we will talk about are
* Spring cloud config server
* Central Dogma
* Consul
* Kubernetes ConfigMap and Secrets

<br/>
<br/>
### [Spring cloud config](https://spring.io/projects/spring-cloud-config)
![Spring cloud config server](https://dev-to-uploads.s3.amazonaws.com/i/t0jy0hczgzteq9qxh58y.png)
Spring cloud config is part of spring cloud tools that provides the ability to externalize the configurations in a distributed systems. The project consists of two parts, a config server and a config client. 
The config server is a simple spring boot application. It reads the configuration from a <u>configuration repository</u> and provides it to *clients*. The configuration server can be a directory on your file system, a git repository, or the [HashiCorp Vault](https://www.vaultproject.io/) tool.

You can store the configuration in either yaml or .properties and read it in yaml, properties, or json. 

Spring cloud config server also provides a REST API for the configuration, hence you can use it from any other technology. 


<br/><br/>
### [Central Dogma](https://line.github.io/centraldogma/index.html)
![Central dogma](https://dev-to-uploads.s3.amazonaws.com/i/d3ku2psa3nfqbbypx8l4.png)
Central dogma is an open source configuration server based on git and zookeeper. 
Central dogma works almost the same way as spring cloud config server. It reads the configurations from a <u>configuration repository</u> (git in this case) and provides them via REST Api, client library, and command line tool. 
Central dogma has some features that (in my opinion) makes it better than spring config server. 
Some of these features are
* The command line tool
* User interface.
* Access control and per-repository permission. (This part is achieved in spring config server via the Vault tool)
* high-availability.


<br/><br/>
###[Consul](https://www.consul.io/)
![Consul](https://dev-to-uploads.s3.amazonaws.com/i/lm0dr67bzmhqn9wx7nmo.png)
Consul is a big tool provided by HashiCorp. It is known as a service discovery tool. It is much more comparable to Eureka than to config server tools but it also provides a key/value store which can be used as an external configuration server. 
Consul allows the users to store indexed objects (configuration objects) and it also replicate the data across multiple server which provide a high availability feature. 

The key/value store in Consul is very simple. It is not intended to be used as a replacement to key/value stores like Redis.


<br/><br/>
###[Kubernetes ConfigMap and Secrets](https://kubernetes.io/docs/concepts/configuration/configmap/)
![Kubernetes ConfigMap](https://dev-to-uploads.s3.amazonaws.com/i/lp5tkgt99fy9epzo78wf.png)
Kubernetes ConfigMap is much like Consul key/value store. Pods can consume the configuration from the ConfigMap as environment variables, command line arguments, and configuration files. 
The problem with config map is that it does not provide secrecy or encryption. So, if you need to store sensitive configurations, it is advised to use [Kubernetes Secrets](https://kubernetes.io/docs/concepts/configuration/secret/) instead.


<br/><br/>
In the next parts we will get into more details about each option.