Notify containers of updated pods in Kubernetes

6/27/2019

I have some servers I want to deploy in Kubernetes. The clients of those servers will also be in Kubernetes. Clients and servers can independently be deployed or scaled.

The clients must know the list of the servers (IPs). I have an HTTP endpoint on the clients to update the list of the servers while the clients are running (hot config reload).

All this is currently running outside of Kubernetes. I want to migrate to GCP.

What's the industry standard regarding pods updates and notifications? I want to get notified when servers are updated to call the endpoints on the clients to update the list of the servers.

Can't use a LoadBalancer since the clients really need to call a specific server (business logic are in the clients).

Thanks

-- Mike Gleason jr Couturier
kubernetes

2 Answers

6/27/2019

The standard for calling a group of pods that offer a functionality is services. If you don't want automated load-balancing or a single IP address, which regular services do, you should look into headless services. Calling headless services returns a list of DNS A records that point to the pods behind the service. This list is automatically updated as pods become available/unavailable.

-- Alassane Ndiaye
Source: StackOverflow

6/27/2019

While I think modifying an existing script to just pull a list from a headless is much simpler, it might be worth mentioning CRDs (Custom Resource Definitions) as well.

You could build a custom controller that listens to service events and then posts the data from that event to an HTTP endpoint of another Service or Ingress. The custom resource would define which service to watch and where to post the results.

Though, this is probably much heavier weight solution that just having a sidecar / separate container in a pod polling the service for changes (which sounds closer to you existing model).

I upvoted Alassane answer as I think it is the correct first path to something like this before building a CRD.

-- Andy Shinn
Source: StackOverflow