<p>Is there a way to specify a <code>hostPath</code> volume so that it includes the pod's name? For example, something like the following:</p>
<pre><code>  volumes:
    - name: vol-test
      hostPath:
        path: /basedir/$(POD_NAME)
        type: Directory
</code></pre>
<p>Simply using /basedir directly and then have the pod itself query for its name and create the directory doesn't satisfy my needs: I specifically want to map each of my containers' /tmp folders to specific volumes.</p>
<p>I know that something similar works with <code>valueFrom</code> for environment variables (see <a href="https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/" rel="nofollow noreferrer">here</a>), but so far I haven't been able to find anything similar for volumes.</p>
<p>Please let me know if anyone has any ideas. Thanks!</p>

Behram Mistree
<p>You set it as an env var first via valueFrom and then certain fields understand <code>$(FOO)</code> as an env var reference to be interpolated at runtime.</p>
<p>EDIT: And <code>path</code> is not one of those fields. But <code>subPathExpr</code> is.</p>
