2个Kubernetes Pod在不知道公开地址的情况下进行通信 [英] 2 Kubernetes pod communicating without knowing the exposed address

查看:82
本文介绍了2个Kubernetes Pod在不知道公开地址的情况下进行通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我计划使用NodePort服务部署2个Kubernetes Pod,以将其公开到网络中.现在,我希望pod 1能够通过他的服务访问pod 2.

I plan to deploy 2 kubernetes pods with a NodePort service to expose them into the network. Now i want pod 1 be able to access the pod 2 by his service.

问题是我写了部署文件,但我不知道从集群获得的IP地址pod 2,但是我需要将地址设置到pod 1的文件中.多变的. kubernetes集群中是否还有其他方法可以使它们通过sth访问.例如服务名称或某物.这样吗?

The Problem is i write the Deployment files and i don't know the ip address pod 2 will get from the cluster, but i need to set the address into the file from pod 1 wiva a env. variable. Is there a other way in a kubernetes cluster to make them accessible by sth. like the name of the service or sth. like this?

在这种情况下无法通过Google搜索,希望你们中的任何人都能给我提示.

failed to google for this case, and hope anyone of you can give me a hint.

问候, 马丁.

推荐答案

所有kubernetes资源都应由kubeDNS引用,您应该能够使用资源名称在Pod之间进行通信.

All kubernetes resources should be referenced by the kubeDNS, you should be able to use the name of the resource to communicate between pods.

您应该能够使它与类似这样的东西一起使用:SERVICENAME.SERVICENAMESPACE:PORT,它可以毫无问题地用于ENV变量中.

You should be able to make it work with something like this: SERVICENAME.SERVICENAMESPACE:PORT and it can be used in an ENV variable without issue.

希望这个回答这个问题.

Hope this answer the question.

这篇关于2个Kubernetes Pod在不知道公开地址的情况下进行通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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