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.
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.