<p>Kubernetes has the ability to set (in a deployment definition) environment variables from a config file. According to the <a href="https://12factor.net/config" rel="nofollow noreferrer">Twelve Factor App guide</a>, one should only store secrets/config vars in the environment variables, not in a file.</p>

<p>What are the arguments in support of using the Kubernetes ConfigMap to set environment variables?</p>

<p>The Twelve Factor App guide <a href="https://12factor.net/config" rel="nofollow noreferrer">advocates the use of environment variables because when using configuration files</a></p>

<blockquote>
  <p>it’s easy to mistakenly check in a config file to the repo; there is a tendency for config files to be scattered about in different places and different formats, making it hard to see and manage all the config in one place. Further, these formats tend to be language- or framework-specific.</p>
</blockquote>

<p>You could mount a <code>ConfigMap</code> as a volume in your application's file system, but then your application is responsible of knowing how to read that file during the start up of the app. Normally, it's just easier to read environment variables passed when starting the application.</p>

<p>In both cases (reading from a file and reading from env vars) you would be following the Twelve Factor App recommendation. But when reading the configuration from a file, I believe is harder to run that application somewhere else, because it requires that we create that file first, which is a process that may be different for different platforms. On the other hand, passing environment variables it's usually always the same on all platforms.</p>

<p>Being able to easily run the application on different platforms is the key goal of the Twelve Factor App guide, so I'd choose directly passing environment variables from a <code>ConfigMap</code>.</p>
