<p>How do I pass in a variable inside another string value in k8s deployments.</p>
<p><a href="https://i.stack.imgur.com/LUMMR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LUMMR.png" alt="enter image description here" /></a></p>

edmamerto
<p>Variable references are possible using the <code>$(ENV_VAR)</code> format.
So, in this example, it would be:</p>
<pre><code>containers:
 - env: 
     - name: DATA_SOURCE_PASS
       valueFrom:
         secretKeyRef:
           name: app-secrets
           key: DB_DOCKER_USER_PASSWORD
     - name: PG_EXPORTER_URL
       value: postgres://postgres:$(DATA_SOURCE_PASS)@localhost:5432/postgres
</code></pre>
<ul>
<li>This question has already been answered <a href="https://stackoverflow.com/questions/49582349/kubernetes-how-to-refer-to-one-environment-variable-from-another">here</a>, which is where I got this answer from.</li>
<li>Kubernetes documentation on <a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#envvar-v1-core" rel="nofollow noreferrer">variable references</a>, also linked from article above.</li>
</ul>
