dockerkubernetescontainersfaas

Kubernetes - One request per container inside a pod


How can i control the distribute of requests inside a pod? For example: I have one pod with one container that runs NodeJs Hello world with 10sec sleep. At first without scaling, i just want to hold other requests until the container finish processing a request.

Im trying to implement a simple Function as a service with Kubernetes.


Solution

  • Since Kubernetes support ingress controller, you may configure nginx like this below:

    limit_req_zone $binary_remote_addr zone=mylimit:10m rate=10r/s;
    
    server {
    location /login/ {
        limit_req zone=mylimit;
    
    
        proxy_pass http://my_upstream;
    }
    }
    

    But if you want to limit rate by using kubernetes resource quota, the github issue: https://github.com/kubernetes/kubernetes/issues/2856 may be useful

    Configuring Basic Rate Limiting

    k8s Ingress