Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to store config parameters?

Tags:

12factor

Reading Config section for 12 factor app : https://12factor.net/config it states "Another approach to config is the use of config files which are not checked into revision control" . Instead "The twelve-factor app stores config in environment variables " If not store config in source/revision control then where should config for environment variables be stored ?

For example a new developer joins a team how does that same developer access the environment variables in order to run the app ? Is it assumed an environment is provided that contains variables that allows app to run?

like image 589
blue-sky Avatar asked Sep 19 '17 20:09

blue-sky


People also ask

Where should I store config files?

These config files are typically placed under separate root directory than the rest of application code. For example, in case of Java they are typically under src/main/resources .

Is it better to keep configurations in config file or database?

Multiple versions may require different key values. The bottom line is that if it's a large scale distributed environment, database is the way to go unless you have automated config file management system in place.

Where do I put config files in Linux?

The vast majority of Linux config files can be found in the /etc/ directory or a sub-directory. Most of the time these configuration files will be edited through the command line, so get comfortable with applications like Nano or Vi.


1 Answers

The suggestion to “use of config files which are not checked into revision control” is probably a little misleading. You could read it as “config files which are not revisioned together with the app”.

That means you can use revision X of the app with revision Y and revision Z of the configuration (or maybe even an unrevisioned configuration), and can use revision X1 and X2 of the app with revision Y of the configuration.

What is addressed that some apps have configuration baked in, so that for example you need a different release for staging and production.

How you would store the configuration is a detail that isn't addressed in detail. You could use ConfigMaps on Kubernetes (which can be consumed as environment variables), store configuration in a database (i.e. etcd), use Hashicorp Vault and Consul or store them in git (i.e. GitOps).

Generally there will be static parts of you configuration (i.e. tax rates) and dynamic one (i.e. names or IP addresses of external services). You don't have to store everything in one place, and defining some of the on the same git server as you app is totally fine. Whether your app accessed the configuration on the git server or gets it injected via another mechanism is up to your deployment methods.

like image 164
eik Avatar answered Oct 21 '22 09:10

eik