Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubernetes - Getting IPs of pods of a proxy service

Tags:

kubernetes

I have a proxy service that wraps 3 pods (say pod A, pod B, pod C). Some container inside pod A needs to get virtual IPs of other two pods. How can I do this?

like image 916
Dimuthu Avatar asked Nov 30 '25 06:11

Dimuthu


1 Answers

Two options:

  1. Talk to the Kubernetes API to get the endpoints for the service. (either with kubectl get endpoints SVCNAME or by GETing the /api/v1/namespaces/{namespace}/endpoints/{svcname} path on the apiserver)
  2. Less likely to be of use, but if you create a service without a cluster IP, the DNS for that service will return a list of the IP addresses of the backing pods rather than a virtual IP address.

The IPs returned in either case are the IP addresses of all the pods backing the service.

like image 172
Alex Robinson Avatar answered Dec 02 '25 22:12

Alex Robinson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!