Dynamic Config Map Update

Dear Users,
I have a typical use-case and hence i wanted to check with you guys for best opinions.

We have a situation whereby we want to scale a deployment for a component (say component A). However, the component that consumes this deployment/component (say Component B) should have the POD IP addresses set within its configs (via configmap) so it can utilize all of the pods of the component A. So essentially, component B; that consumes Component A has its own load-balancing mechanism and we have to set the IPs of all the pods that are running for Compnent-A, into config of Component-B, dynamically. We can’t make use of the ‘kubernetes service’; atleast for now, until we do some code re-writing.

So what we want to check is if there was a way such that

whenever there is change in the Pods of Component-A’s deployment (no autoscaling but say when a pod restarts, or manual replica number increased),

then

  • The config-map of Component B is updated and the IP(s) of the PODs of Component-A is added/removed/updated according to the operation, and

  • Component-B is restarted.

The short answer is no, there is not a built-in way to do this.

The longer answer is that there are primitives for you to build this. Example: you can expose A thru a “headless” Service and put a sidecar in B which resolves A’s DNS name into IPs. Write those to a volume on an ‘emptyDir’ volume and SIGHUP the main app.

Obviously, I have not built this so some details may be lacking.

Tim