Flask with Gunicorn on Kubernetes ingress yields 502 nginx error Flask with Gunicorn on Kubernetes ingress yields 502 nginx error flask flask

Flask with Gunicorn on Kubernetes ingress yields 502 nginx error


  1. IMO, you don't need gunicorn scaling (it's an overkill) since an HPA will do the scaling if your single application instances already. This depending on CPUs, memory or custom metrics.

  2. The 502 errors seem to me it's more of how gunicorn is configured issue (is there a limit on the workers? can you see the workers to just 1 to test? how is it scaling inside the container? What are the resource limits on the container?). Hard to tell without looking at logs or the environment, but it could be that you gunicorn workers are thrashing in the container thus returning an invalid response. You might want to try --log-level debug on the gunicorn command line.

Hope it helps.