<p>I want my applications to write log files at a host location, so I'm mounting a <code>hostPath</code> volume. But all applications try to write logs using the same file name.</p>

<p>I'd like to separate the files into folders named after the Pod names, but I see nowhere in the documentation how to implement it:</p>

<pre><code>  volumes:
  - name: logs-volume
    hostPath:
      path: /var/logs/apps/${POD_NAME}
      type: DirectoryOrCreate
</code></pre>

<p>In the (not working) example above, apps should write files to the POD_NAME folder.</p>

<p>Is it possible?</p>

<p>As of kubernetes 1.17 this is supported using subPathExpr. See <a href="https://kubernetes.io/docs/concepts/storage/volumes/#using-subpath-expanded-environment" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/storage/volumes/#using-subpath-expanded-environment</a> for details.</p>
