<p>When am building the image path, this is how I want to build the image Path, where the docker registry address, I want to fetch it from the configMap.</p>
<p>I can't hard code the registry address in the values.yaml file because for each customer the registry address would be different and I don't want to ask customer to enter this input manually. These helm charts are deployed via argoCD, so fetching registryIP via shell and then invoking the helm command is also not an option.</p>
<p>I tried below code, it isn't working because the env variables will not be available in the context where image path is present.</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ template &quot;helm-guestbook.fullname&quot; . }}
spec:
  template:
    metadata:
      labels:
        app: {{ template &quot;helm-guestbook.name&quot; . }}
        release: {{ .Release.Name }}
    spec:
      containers:
        - name: {{ .Chart.Name }}
          {{- if eq .Values.isOnPrem &quot;true&quot; }}
          image: {{ printf &quot;%s/%s:%s&quot; $dockerRegistryIP .Values.image.repository .Values.image.tag }}
          {{- else }}
          env:
          - name: DOCKER_REGISTRY_IP
            valueFrom:
              configMapKeyRef:
                name: docker-registry-config
                key: DOCKER_REGISTRY_IP
</code></pre>
<p>Any pointers on how can I solve this using helm itself ?  Thanks</p>

<p>Check out the <code>lookup</code> function, <a href="https://helm.sh/docs/chart_template_guide/functions_and_pipelines/#using-the-lookup-function" rel="nofollow noreferrer">https://helm.sh/docs/chart_template_guide/functions_and_pipelines/#using-the-lookup-function</a></p>
<p>Though this could get very complicated very quickly, so be careful to not overuse it.</p>
