Kubernetes - Sending message to all pods from service or from Ingress

5/10/2018

Is it possible to send requests to all pods behind a service/ingress controller based on the requests?

My requirement is to send requests to all the pods if the request is /send/all.

Thanks

-- user1578872
kubernetes

1 Answer

5/13/2018

It's not possible because ingress controller can't do this (for sure nginx and GLBC based ingress can't do it, bud due to the way how to http works I assume this is the case for all ingress controllers).

Depending what your exact case is you have few options.

If your case is just monitoring and you can afford using control on number of request sending to your pods you can just set http liveness probe for your pods. Then you will be sure that if pod doesn't return correct response k8s won't send traffic to it.

If you need to trigger some action on all pods you have few options:

Use messaging - for example you can use rabbitmq chart to deploy rabbitmq and write some application that will handle your traffic.

Using DB - create some app that will set some flag in DB abd add some logic to your app to monitor the flag, or create cron job and to monitor the flag and trigger and trigger required actions on pods (in this case you can use service account to give your cron job pod to k8s API to list pods.

-- Maciek Sawicki
Source: StackOverflow