<p>The example on the documentation (<a href="http://kubernetes.io/docs/user-guide/configmap/" rel="noreferrer">http://kubernetes.io/docs/user-guide/configmap/</a>) for consuming values is based on a ConfigMap where each data entry is a single pair/value. Example:</p>

<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: special-config
  namespace: default
data:
  special.how: very
  special.type: charm
</code></pre>

<p>However when we create a ConfigMap from property files, every data entry value is itself a list of key/pair values. Example:</p>

<pre><code>$ kubectl get configmaps game-config -o yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: game-config
  [...]
data:
  game.properties: |-
    enemies=aliens
    lives=3
    enemies.cheat=true
    enemies.cheat.level=noGoodRotten
    secret.code.passphrase=UUDDLRLRBABAS
    secret.code.allowed=true
    secret.code.lives=30
  [...]
</code></pre>

<p>In such a case:</p>

<ol>
<li>How do we consume a single entry (example: enemies.cheat) as an
environment variable?</li>
<li>How do we consume all the entries (example: all game.properties entries)
as a set of environment variables, assuming we just use each key as
the environment variable name?</li>
</ol>

<p>You can't consume a single entry since it is just one big blob of text. You have two options that I see:</p>

<ol>
<li><p>Don't create the config map from a file. Instead create each entry in the ConfigMap manually. You'll have to consume each key separately though, at least until <a href="https://github.com/kubernetes/kubernetes/issues/26299" rel="nofollow noreferrer">this issue</a> is resolved.</p></li>
<li><p>Don't use the ConfigMap as environment variables. Instead mount that key as a volume and have your application read the key/values.</p></li>
</ol>

<p>It seems like the second option would work nicely for you. It would let you continue to generate your ConfigMap from a file, and also allow you to consume all declared key/values without having to constantly change your Kubernetes manifests.</p>

<p>Another advantage of mounting your ConfigMap as a volume is that it will allow you to perform in-place updates to your configs (assuming that your app tolerates that). If you mount ConfigMap keys as environment variables the only way to update them is to restart the app.</p>
