Kubernetes getting sibling-pod IP/properties from the same deployment/replicaset

喜夏-厌秋 提交于 2021-02-11 14:21:38

问题


Need to set the ip and/or any metadata of the deployment to be available as env vars to each pod under the same deployment...

ex: having a 3 replica deploment. need to set env var for other IP address for each of the two other pods. need to set the host name for each other two pods. as of having

HOSTNAME=deplymentNAME-d74cf6f77-q57jx
deplymentNAME_PORT=tcp://10.152.183.27:13000

need to add:

HOSTNAME2=deplymentNAME-d74cf6f77-y67kl
HOSTNAME3=deplymentNAME-d74cf6f77-i90ro
deplymentNAME_PORT2=tcp://10.152.183.45:13000
deplymentNAME_PORT3=tcp://10.152.16.28:13000

those should be available on the three pods relatively. as of now each pod have only its own data, we need to spread others data to the other replicas in the same deployment.


回答1:


Well, I figured out that my application is a stateful and not stateless application, that requires fixed/stable hostname/storage etc...

I have decided to use the statefulset controller

references:

  • https://kubernetes.io/docs/tutorials/stateful-application/basic-stateful-set/
  • https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/
  • https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.11/#statefulset-v1-apps


来源:https://stackoverflow.com/questions/51235932/kubernetes-getting-sibling-pod-ip-properties-from-the-same-deployment-replicaset

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!