<p>We have an app that runs on GKE Kubernetes and which expects an auth url (to which user will be redirected via his browser) to be passed as environment variable.</p>

<p>We are using different namespaces per environment </p>

<p>So our current pod config looks something like this:</p>

<pre><code>  env:
    - name: ENV
      valueFrom:
        fieldRef:
          fieldPath: metadata.namespace
    - name: AUTH_URL
      value: https://auth.$(ENV).example.org 
</code></pre>

<p>And all works amazingly, we can have as many dynamic environments as we want, we just do apply -f config.yaml and it works flawlessly without changing a single config file and without any third party scripts.</p>

<p>Now for production we kind of want to use different domain, so the general pattern <code>https://auth.$(ENV).example.org</code> does not work anymore.</p>

<p>What options do we have?</p>

<ol>
<li>Since configs are in git repo, create a separate branch for <code>prod</code> environment</li>
<li>Have a default ConfigMap and a specific one for prod environment, and run it via some script (if exists <code>prod-config.yaml</code> then use that, else use <code>config.yaml</code>) - but with this approach we cannot use kubectl directly anymore</li>
<li>Move this config to application level, and have separate config file for <code>prod</code> env - but this kind of goes against 12factor app?</li>
<li>Other...?</li>
</ol>

<p>This seems like an ideal opportunity to use <a href="https://helm.sh/" rel="noreferrer">helm</a>!</p>

<p>It's really easy to get started, simply install tiller into your cluster.</p>

<p>Helm gives you the ability to create "charts" (which are like packages) which can be installed into your cluster. You can template these really easily. As an example, you might have you config.yaml look like this:</p>

<pre><code>env:
  - name: AUTH_URL
    value: {{ .Values.auth.url }} 
</code></pre>

<p>Then, within the helm chart you have a <code>values.yaml</code> which contains defaults for the url, for example:</p>

<pre><code>auth:
  url: https://auth.namespace.example.org
</code></pre>

<p>You can use the <code>--values</code> option with helm to specify per environment <code>values.yaml</code> files, or even use the <code>--set</code> flag on helm to override them when using <code>helm install</code>.</p>

<p>Take a look at the documentation <a href="https://github.com/kubernetes/helm/blob/master/docs/charts.md#values-files" rel="noreferrer">here</a> for information about how values and templating works in helm. It seems perfect for your use case</p>
