Some configurations may be common to several microservices. In our example, we are duplicating the same values for the database connection. Instead of repeating the values on each of the deployment files, we can use ConfigMap and share it across the different deployments.
We've seen how to add ConfigMap to include files in Chapter 10, Monitoring Logs and Metrics, under the Setting up metrics section. It was used for a single service, though.
A ConfigMap is a group of key/value elements. They can be added as environment variables or as files. In the next section, we will add a general configuration file that includes all the shared variables in the cluster.