我正在为服务设置kubernetes pod。需要使用永久卷来存储日志,证书等,这些卷应该在主机的某些子路径(例如service / log)上可用。现在我要创建此文件夹通过更改为service / log_podID或log_podName之类的值来唯一。如何在k8s部署Yamls中获取Pod名称或Pod ID。
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.