Pod通讯 [英] Pod Communication
问题描述
在Kubernetes中如何在两个不同的Pod之间进行通信?
How does the communication between two different pods happen in Kubernetes?
在我的情况下,我有两个Pod: frontend 和 backend ,它们都有不同的容器. 我希望前端Pod与后端Pod通信,但是我不想使用后端Pod的IP(即硬编码).
In my case I have two pods: frontend and backend, both have different containers. I want my frontend pod to communicate with the backend pod but I don't want to use backend pod's IP( i.e. hard coded).
通过服务有可能吗?
推荐答案
可以通过服务吗?
Is it possible through services?
是的,推荐使用服务.为每个Pod(或建议的复制控制器)设置服务后,即可通过
Yes, services are the recommended way to handle this. Once you have your services set up for each pod (or replication controller, as is recommended), you can find the service IP via the service environment variable, e.g. BACKEND_SERVICE_HOST
and BACKEND_SERVICE_PORT
for a "backend" service.
这篇关于Pod通讯的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!