Dimuthu
Dimuthu

Reputation: 8576

Kubernetes - Getting IPs of pods of a proxy service

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?

Upvotes: 3

Views: 1888

Answers (1)

Alex Robinson
Alex Robinson

Reputation: 13377

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.

Upvotes: 4

Related Questions