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.
Possible ideas:
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.
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.
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.