Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Call Pod by IP from another Pod

I’ve developed a python script, using python kubernetes-client to harvest Pods’ internal IPs.

But when I try to make an http request to these IPs, from another pod, I get Connection refused error.

I spin up a temporary curl container:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

kubectl run curl --image=radial/busyboxplus:curl -it --rm

And having the internal IP of one of the pods, I try to make a GET request:

curl http://10.133.0.2/stats

and the response is:

curl: (7) Failed to connect to 10.133.0.2 port 80: Connection refused

Both pods are in the same default namespace and use the same default ServiceAccount.

I know that I can call the Pods thru the ClusterIP service by which they’re load-balanced, but this way I will only access a single Pod at random (depending which one the service forwards the call to), when I have multiple replicas of the same Deployment.

I need to be able to call each Pod of a multi-replica Deployment separately. That’s why I’m going for the internal IPs.

>Solution :

I guess you missed the port number here

It should be like this

curl POD_IP:PORT/stats

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading