Restricting Kubernetes pod to one process

8/21/2019

I am having a Kubernetes cluster with docker images. I am having some app and each set of app is having a service. Load balancing and path routing is done by Nginx Ingress. Now I have one app which is very specific in its use. I want to restrict it's use to only one process/request at a time. That process can run up to half hour as well. How can I do this in a Kubernetes cluster? It will be great if kubernetes have such solution to track the process running in pod and not to allocate request to that process. It can also be done by auto scaling. If we can delete the pod which are not used, and to scale the application as we get request.

-- Sanket Lad
docker
kubernetes
microservices

1 Answer

8/21/2019

This problem isn't so much one to be solved by Kubernetes, but rather by your application design - in this case it sounds like you have a good use-case for a messaging queue. Instead of exposing the service as REST API (I'm assuming this is what you're doing), you can setup a messaging queue for requests to be placed in and your service can read in new requests when it's ready instead of on-demand. This would allow you to ensure your service only subscribes to one queue event at a time without blocking future requests.

Feel free to check out solutions like RabbitMQ or AWS SQS.

-- David T.
Source: StackOverflow