<p>I have a generated config map</p>
<pre><code>configMapGenerator:
  - name: template-vars
    envs:
      - templateVars.env
</code></pre>
<p>and would like to use one of the contained values</p>
<pre><code>ROUTE_HOST=somewhere.else.org
</code></pre>
<p>as a variable</p>
<pre><code>vars:
  - name: ROUTE_HOST
    objref:
      kind: ConfigMap
      name: template-vars
      apiVersion: v1
    fieldref:
      fieldpath: data.ROUTE_HOST
</code></pre>
<p>in my OCP route</p>
<pre><code>apiVersion: route.openshift.io/v1
kind: Route
spec:
  host: $(ROUTE_HOST)
</code></pre>
<p>Is this possible?</p>
<p>I know that I can do some nearly equal thing with env vars:</p>
<pre><code>env:
  - name: ROUTE_HOST
    valueFrom:
      configMapKeyRef:
        name: template-vars
        key: ROUTE_HOST
</code></pre>

<p>Yes it's possible. I currently do it for most of my ingresses host. By default the var plugins doesn't work on all the fields of all the resources. In order for kustomize to interpolate the <code>$(ROUTE_HOST)</code> in your resource, you need to add a configuration to your <code>kustomization.yaml</code> file:</p>
<p><code>kustomization.yaml</code>:</p>
<pre class="lang-yaml prettyprint-override"><code>configMapGenerator:
  - name: template-vars
    envs:
      - templateVars.env

vars:
  - name: ROUTE_HOST
    objref:
      kind: ConfigMap
      name: template-vars
      apiVersion: v1
    fieldref:
      fieldpath: data.ROUTE_HOST

configurations:
  - transformer_config.yaml
</code></pre>
<p>and <code>transformer_config.yaml</code>:</p>
<pre class="lang-yaml prettyprint-override"><code>varReference:
  - path: spec/host
</code></pre>
