Milkncookiez
Milkncookiez

Reputation: 7407

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:

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.

Upvotes: 1

Views: 967

Answers (1)

Dashrath Mundkar
Dashrath Mundkar

Reputation: 9222

I guess you missed the port number here

It should be like this

curl POD_IP:PORT/stats

Upvotes: 2

Related Questions