I have a service called my-service
with an endpoint called refreshCache
. my-service
is hosted on multiple servers, and occasionally I want an event in my-service
on one of the servers to trigger refreshCache
on my-service
on all servers. To do this I manually maintain a list of all the servers that host my-service
, pull that list, and send a REST request to <server>/.../refreshCache
for each server.
I'm now migrating my service to k8s. Similarly to before, where I was running refreshCache
on all servers that hosted my-service
, I now want to be able to run refreshCache
on all the pods that host my-service
. Unfortunately I cannot manually maintain a list of pod IPs, as my understanding is that IPs are ephemeral in k8s, so I need to be able to dynamically get the IPs of all pods in a node, from within a container in one of those pods. Is this possible?
Note: I'm aware this information is available with kubectl get endpoints ...
, however kubectl
will not be available within my container.