Kubernetes : is it possible to broadcast message from one service to another service?

5/26/2020

I am working on a building a distributed system where I need to refresh a particular configuration to all the pods of two services, service-A and service-B. This configuration is handled by another service-C. A user can send an api request to service-C which needs to be propagated to all the pods of service-A and service-B.

  1. Service A and Service B works on grpc and are not exposed to the world.
  2. These services can be running on different nodes (so we cannot have a file system shared between these).
  3. The configuration will be around 100KB on average and there will be around 100K such configurations.

Possible ideas:

  1. I can create a message bus using kafka and push these configuration on that bus which is then listened by different pods. Problem with this approach is service A and service B will have 100s of pods running so there will be like 100s of consumer groups, also if a new pod comes up it has to consume the queue from the beginning which will be time consuming.

  2. Using a light weight transient key value store like consul or etcd, so Service-C will push the data in consul which can then be read by Service-A and Service-B. The issue with this approach, so many pods listening to consul can cause latency.

Can someone please help me with some ideas how i can achieve this on kubernetes natively?

Thanks.

-- Udit Sarin
kubernetes
kubernetes-networking

1 Answer

5/26/2020

You could use configMap for this. From application C create or update a configMap by calling kubernetes API using kubernetes go client library and volumeMount the configMap in service A and service B.The service A and service B can have a mechanism to check if anything has changed in those configMaps and if yes then reload config in the memory. The mechanism in service B and service A could just be calculating a hash of the configMap and keep comparing that periodically with what is there in the Filesystem(via volumeMount of the configMap) and when there is a change reload the configMap in memory.

-- Arghya Sadhu
Source: StackOverflow