How to broadcast Message to all the POD

As i am using Load Balancer service to send the request to POD but LB is only passing to one POD at a time. Please let me know how i can send a Http request to multiple POD via service.

In My scenario i am doing a cache invalidation and application is sending a cache invalidation request to the service where it should invalidate the cache to all the POD.

Please help me to achieve it.

If the application that is sending the cache invalidation lives in the same Kubernetes cluster as the cache pods, then you could iterate over all the endpoints defined for the service.

If the service targeting your cache pods is named “cache”, then you could use, from the command line:

kubectl get endpoints cache -o yaml

and observe that each ready pod is listed here.

If your application lives outside the cluster, it’s more complicated since:

  • internal K8S DNS can not be queried from outside
  • pod IP address are generally not routable from outside

The first point could be circumvented by using an external service discovery tool, such as Consul, synchronized with your K8S state. The second point is highly dependant on how your network is architectured, thus I don’t see how I can help you.

Have a great day.

Thanks for your reply …POD’s are running on same cluster… we don’t have any cache POD
We have Apache+Dispatcher and Varnish POD having their local cache and we are trying to invalidate the cache whenever any changes on pages.

Here is the complete description

Use case

we are a running application (Apache + Dispatcher) POD in Kubernetes Cluster. we have another Running POD (Publisher). Each Apache+Dispatcher POD has it’s own Local Cache. We have Two POD running for apache and one POD Running for Publisher.

To access the application We have LoadBalancer Service for Apache and LoadBalancer Service for Publisher POD

Inside Publisher POD we have Apache+Disp Flush Agent running. whenever there is any changes on Pages on Publisher and as soon as we activate the page Flush agent gets trigger from Publisher and it calls the Apache+Disp POD to invalidate the cache.


If we use single POD for Apache+Disp cache invalidate is happening fine but as soon as we increase the POD from one to two cache invalidation is not getting equally distribute to each POD from LB service.

From Publisher it triggers the flush agent to invalidate the cache but it is not invalidating the cache on both the POD.

Please suggest how i can achieve

The best way, in my opinion, would be to modify the way the Flush Agent works. Instead of calling an URL through the LoadBalancer service, I would query the Kubernetes API to get the list of the pod registered as endpoints for this service.

Of course, this is only possible if you can modify the source code of the Flush Agent. If you are using a commercial product that you cannot modify, maybe you could configure a different URL in the Flush Agent, so that it sends a “flush” request not to a Apache+Disp pod, but to a pod running a simple script that will dispatch the flush request to each pod using the workflow I described (iterating over endpoints).

Load-balancer are not broadcasters. You have to solve the broadcast problem in your own domain (and authn/authz for who is allowed to doa cache-invalidation).

For example, you might have all your caches gossip to each other. Or you might have a re-broadcaster in your cluster. Or you might use a CRD (though is not the ideal usage model for declarative APIs).

You can create a secondary headless service with the same selector, then you can just use a DNS request to get all the IPs of the Pods, and don’t need to have K8s API access.

…But you still have to iterate that list - it is not a broadcast/multicast thing

Yes, you still have to iterate it, or whatever client you use has to do that.

Anyone Please summarize the steps i need to do to achieve this? Any external Tool can i use to achieve?