<p>I want to bind some variables based on the return of an HTTP request. I imagine something like this:</p>
<pre><code>name: {{ curl -s 'https://something.com/users/1' | jq -r '.name' }}
</code></pre>
<p>Is there a suitable way to do something like this or equivalent?</p>

Alexandre Queiroz de Oliveira
<p>Helm has no way to run shell commands or other subprocesses, and no general way to make HTTP callouts.</p>
<p>The closest you can come to this is using command substitution in your host shell in combination with the <a href="https://docs.helm.sh/docs/intro/using_helm/#the-format-and-limitations-of---set" rel="nofollow noreferrer"><code>--set</code> option</a>:</p>
<pre class="lang-yaml prettyprint-override"><code>name: {{ .Values.name }}
</code></pre>
<pre class="lang-sh prettyprint-override"><code>helm install ... \
  --set name=$(curl -s 'https://something.com/users/1' | jq -r '.name')
</code></pre>
<p>This will create a fixed value across the entire installation; <code>helm get values</code> would show you what that is.</p>
<p>Since this does create essentially a fixed install-time value, you can also run the <code>curl</code> command, add the result to the chart's <code>values.yaml</code> file or another <code>helm install -f</code> YAML file, and commit the result to source control.  This would give you a trackable history of what deployment values were used at a given point in time.</p>
<p>Depending on how you're using the value, you could also have your application make the HTTP call itself as part of its startup sequence, or use an init container to make the call and leave its result in an <code>emptyDir</code> volume.  Those approaches would make the call at pod startup time rather than at deployment time, and would repeat the call for each replica, but if the remote value changed, you could more easily restart the pods without redeploying.</p>
