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

3/7/2017

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.

-- Mikey
docker
kubernetes

1 Answer

3/7/2017

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.

-- pagid
Source: StackOverflow