How to set pod as unready without using readinessProbe?

10/2/2019

I have set up some HTTP GET readiness probes for some of my services running in Kubernetes. This is done to take off the pod from Kubernetes Service if it is busy (processing a long POST request). Instead of sending HTTP GET readiness probe every second, is there a way to set pod as unready when it starts to process a POST request.

-- backprop7
kubernetes

1 Answer

10/10/2019

I think you should implement some kind of logic that would for example create a file if request is being processed and removes it when there is no requests.

Depending on what kind of processing are you doing with the request, this might be added as a function while processing is running or a script that is checking if x process is active which means there is a requests being processed.

This can be then used in readiness probe as this will mark the Pod as Unready.

You can also change the whole architecture of processing the requests. Instead of pushing them to a pod you can spawn a job running till completion. This way you could handle many requests at the time using parallel jobs or setting a work queue.

-- Crou
Source: StackOverflow