<p>I'm working on setting up a kubernetes pod for a service.There is a need to use persistent volumes for logs,certs etc which should be available at some sub-path at host like service/log.Now i want to make this folder unique by changing to something like service/log_podID or log_podName.How can i get a pod name or pod id within in k8s deployments yamls. </p>

<p>Using something like this implies some kind of state which is contrary to the stateless nature of a <code>Deployment</code>. You could use the <code>hostname</code> within the container to have a unique ID, but that can't be used in the YAML.</p>

<p>If you need reliable IDs of your PODs you should use a <code>StatefulSets</code> (<a href="https://kubernetes.io/docs/tutorials/stateful-application/basic-stateful-set/" rel="nofollow noreferrer">documentation</a>) which bring predictable pod names which you could then use within your yaml.</p>
