<p>I'm using config maps to inject env variables into my containers. Some of the variables are created by concatenating variables, for example:</p>

<p>~/.env file</p>

<pre><code>HELLO=hello
WORLD=world
HELLO_WORLD=${HELLO}_${WORLD}
</code></pre>

<p>I then create the config map</p>

<p><code>kubectl create configmap env-variables --from-env-file ~/.env</code></p>

<p>The deployment manifests reference the config map.</p>

<pre><code>apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: my-app
spec:
  template:
    spec:
      containers:
      - name: my-image
        image: us.gcr.io/my-image
        envFrom:
        - configMapRef:
            name: env-variables
</code></pre>

<p>When I exec into my running pods, and execute the command</p>

<p><code>$ printenv HELLO_WORLD</code></p>

<p>I expect to see <code>hello_world</code>, but instead I see <code>${HELLO}_${WORLD}</code>. The variables aren't expanded, and therefore my applications that refer to these variables will get the unexpanded value.</p>

<p>How do I ensure the variables get expanded?</p>

<p>If it matters, my images are using alpine.</p>

<p>I can't find any documentation on interpolating environment variables, but I was able to get this to work by removing the interpolated variable from the configmap and listing it directly in the deployment. It also works if all variables are listed directly in the deployment. It looks like kubernetes doesn't apply interpolation to variables loaded from configmaps.</p>

<p>For instance, this will work:</p>

<p>Configmap</p>

<pre><code>apiVersion: v1
data:
  HELLO: hello
  WORLD: world
kind: ConfigMap
metadata:
  name: env-variables
  namespace: default
</code></pre>

<p>Deployment:</p>

<pre><code>apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: my-app
spec:
  template:
    spec:
      containers:
      - name: my-image
        image: us.gcr.io/my-image
        envFrom:
        - configMapRef:
            name: env-variables
        env:
        - name: HELLO_WORLD
          value: $(HELLO)_$(WORLD)
</code></pre>
