<p>Can environment variables passed to containers be composed from environment variables that already exist? Something like:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80
        env:
        - name: URL
          value: $(HOST):$(PORT)
</code></pre>

Marko Galesic
<p>Helm with it's <a href="https://helm.sh/docs/chart_template_guide/variables/" rel="nofollow noreferrer">variables</a> seems like a better way of handling that kind use cases.
In the example below you have a deployment snippet with values and variables:</p>
<pre class="lang-yaml prettyprint-override"><code>    spec:
      containers:
        - name: {{ .Chart.Name }}
          image: &quot;image/thomas:{{ .Values.image.tag }}&quot;
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          env:
            - name: URL
              value: {{ .Values.host }}:{{ .Values.port }}
</code></pre>
<p>And here is one of the ways of deploying it with some custom variables:</p>
<pre class="lang-sh prettyprint-override"><code>helm upgrade --install  myChart . \
  --set image.tag=v2.5.4 \
  --set host=example.com \
  --set-string port=12345 \
</code></pre>
<p>Helm allows you also to use template functions. You can have <code>default</code>functions and this will go to default values if they're not filled. In the example above you can see <code>required</code> which display the message and fails to go further with installing the chart if you won't specify the value. There is also <code>include</code> function that allows you to bring in another template and pass results to other template functions.</p>
