NGINX Handling JSON POST Requests to Pass to Python Flask Containers on Kubernetes

8/8/2017

I am new to the usage of load balancers and still trying to wrap my head around how load balancers, as NGINX can be utilized for JSON POST requests to my python flask containers in Kubernetes cluster.

I have nginx and python flask containers set up in my Kubernetes cluster, with nginx as my load balancer and I exposed both sets of containers as services with port # on Kubernetes cluster. I have given a Static IP to nginx.

I am very confused, as I am new to this, how when I pass JSON body POST requests to NGINX Static IP, how will it be routed to run intended .py files in the python flask containers (which contain .py files, I am trying to pass the JSON text to. The .py files are setup for handling GET, POST requests via Restful API within the flask code setup. I have a request URL setup, but not sure if that should be NGINX static IP).

Am I missing configuration a layer in NGINX to route the JSON POST body data over to the python Flask container in Kubernetes?

Should I use an Ingress API controller?

Ideally I would like to ping the load balancer with my JSON POST body request and have my Flask python container output the run of the .py files within the container. I am expecting to scale these services for more requests.

Thanks.

-- Yuvraj Singh
docker
docker-ingress
flask
kubernetes
nginx

1 Answer

8/8/2017

It really depends on your requirements.

To answer how this would potentially work:

HTTP requests get sent to the nginx container, which then passes the request on to one of the multiple containers. More information about how to achieve this with nginx can be found here: http://nginx.org/en/docs/http/load_balancing.html

-- Chris Stryczynski
Source: StackOverflow