Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
152 views
in Technique[技术] by (71.8m points)

How to make two pods, located on different Kubernetes nodes, communicate

I'm looking for some advice.

I've created my Kubernetes cluster, with multiple worker nodes and the control plane. I've also executed multiple pods with docker images.

What I'm looking for now is to make two pods, located on different nodes, communicate with each other. What is the easiest way to make it happen? I can figure out the details once I know how to do that, but I've tried to set up a pod running up as a service and then accessing its IP:port from the browser, to no avail. I've tried using the cluster IP, the Node IP, but that just doesn't work.

So say I want to send data x from the docker image running in Pod A, located in Node A, to Pod B in Node B. Then I want the program located in Pod B to process that data. How would you proceed?

Thanks in advance.

question from:https://stackoverflow.com/questions/66051630/how-to-make-two-pods-located-on-different-kubernetes-nodes-communicate

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

So say I want to send data x from the docker image running in Pod A, located in Node A, to Pod B in Node B. Then I want the program located in Pod B to process that data. How would you proceed?

Don't access the Pod directly. Deploy your application as a Deployment and also create a Service for the application. The other application should send the request to the Service for the application it want to access.

When you update your application, with e.g. changed code - new Pods will be created for that application, but the Service is the same.

If both application is deployed in the same namespace, you typically can access the other application with e.g. http://<service-name>


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...