简体   繁体   English

Kubernetes:如何发现邻居豆荚

[英]Kubernetes: how to discover neighbor pods

I have started 3 different pods (in GKE): 我已经启动了3个不同的pod(在GKE中):

kubectl run ubuntu --image myimage --namespace misko -r 3 --command -- /some/binary --bind-to-port 1234

Now I need to discover hostnames/ip addresses of those pods from 4th pod which needs to connect to those 3 nodes. 现在我需要从第4个pod发现那些需要连接到这3个节点的pod的主机名/ IP地址。

Is it possible to do that? 有可能吗?

This is creating a Deployment that will control the pods behaviour and replicas but you have to create a service for this deployment in order to expose the ports inside or outside the cluster. 这将创建一个将控制pod行为和副本的Deployment ,但您必须为此部署创建服务,以便公开群集内部或外部的端口。

kubectl expose deployment ubuntu --port=1234 --target-port=1234

After that you can access the pods in round-robin using the service name and the port number: 之后,您可以使用服务名称和端口号以循环方式访问pod:

ububtu:1234

If the other pod it's on a different namespace, you may use the full DNS instead: 如果另一个pod位于不同的命名空间,则可以使用完整的DNS:

ubuntu.misko.svc.cluster.local:1234

Please take a look at kubectl expose for more examples 有关更多示例,请查看kubectl公开

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM