<p>Is there any way to expose the deployment name from helm to a container? It is usually available as part of the hostname, but I'd rather not parse that if I can help it.</p>
<p>I know you can set certain metadata as specific environment variables according to the docs: <a href="https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/</a>
However, that doesn't seem to include deployment name directly. Is there a way to get this info?</p>

Garrett Motzner
<p>You can't directly echo the deployment name into an environment variable, but you can duplicate the deployment name, including whatever template code generated it.</p>
<p>For example, let's say your deployment looks like the <a href="https://github.com/helm/helm/blob/master/pkg/chartutil/create.go#L242" rel="nofollow noreferrer">standard template</a>:</p>
<pre class="lang-yaml prettyprint-override"><code>kind: Deployment
metadata:
  name: {{ include &quot;chartname.fullname&quot; . }}
</code></pre>
<p>In the pod spec part of the deployment, you can repeat that same invocation to get the same name.</p>
<pre class="lang-yaml prettyprint-override"><code>env:
  - name: DEPLOYMENT_NAME
    value: {{ include &quot;chartname.fullname&quot; . }}
</code></pre>
<p>You'd have to manually include this in your YAML, or in a set of standard environment variables in the <code>_helpers.tpl</code> file.  It will produce the correct values if you change the Helm release name and get a different deployment name.  It won't produce the correct values if you change the name at the top of the YAML file and forget to update it in the second place.</p>
