<p>I am trying to configure  a persistent disk for Kafka in Kubernetes, I need to set the mount path to /kafka/POD_NAME/. </p>

<p>I can get the pod name as explained <a href="https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/" rel="nofollow noreferrer">here</a> from: </p>

<pre><code>  env:
    - name: POD_NAME
      valueFrom:
        fieldRef:
          fieldPath: metadata.name
</code></pre>

<p>I am asking how to use this <code>POD_NAME</code> inside the <code>mountPath</code> value, something like: `/</p>

<p>The Downward API, as the name indicates, is used to expose extra kubernetes related information to the containers. What you want is for your yaml file definitions to have variable or dynamic values based on the runtime pods being launched. This is currently not possible.</p>

<p>You might want to try to do something with <a href="https://github.com/kubernetes/helm" rel="nofollow noreferrer">Helm</a> templates which in a StatefulSet with a PVC would allow you to have predictable pod+volume names and maybe insert a dynamic mountpath, but I haven't tried this myself.</p>

<p>Further, if you're setting this up as recommended, which is in a StatefulSet, it is preferable that the inner spec template for the containers are exactly the same.</p>
