Kubernetes从同一部署/复制包中获取同级Pod IP/属性 [英] Kubernetes getting sibling-pod IP/properties from the same deployment/replicaset

查看:73
本文介绍了Kubernetes从同一部署/复制包中获取同级Pod IP/属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要将部署的ip和/或任何元数据设置为可在同一部署下的每个pod用作环境变量...

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

例如: 具有3个副本部署. 需要为其他两个Pod的每个IP地址设置env var. 需要为彼此设置两个Pod的主机名. 截至

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

需要添加:

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

在三个豆荚上应该相对可用. 截至目前,每个Pod仅具有自己的数据,我们需要将其他数据散布到同一部署中的其他副本中.

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.

推荐答案

好吧, 我发现我的应用程序是有状态非无状态应用程序,需要固定/稳定的主机名/存储等...

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

我决定使用statefulset控制器

I have decided to use the statefulset controller

参考:

  • 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

这篇关于Kubernetes从同一部署/复制包中获取同级Pod IP/属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆