How do we get something unique like pod id or container id in kubernetes deployment yamls

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.

  • how get env variables from docker in symfony yml config file
  • Pass folder between builds - GitLab CI with Docker
  • Dockerizing a gradle build on a Mac
  • Docker CMD executable 'not found' - LUA
  • Bind data to a db container
  • How to create named and latest tag in Docker?
  • Docker compose linking appears to not work
  • Starting Datalab from Cloud Shell
  • Data Space Used not matching docker images output
  • Dockers container source code mounting failed in Ubuntu
  • Using docker to compose a remote image with a local code base for *development*
  • Docker PostgreSQL - Scripts in /docker-entrypoint-initdb.d doesn't run
  • One Solution collect form web for “How do we get something unique like pod id or container id in kubernetes deployment yamls”

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

    If you need reliable IDs of your PODs you should use a StatefulSets (documentation) which bring predictable pod names which you could then use within your yaml.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.