-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
uWSGI support of nginx ingress controller? #143
Comments
@yue9944882 |
I'll explain this as I understand it. uwsgi has its own binary protocol to avoid the overhead of gratuitous http parsing. http://uwsgi-docs.readthedocs.io/en/latest/FAQ.html#why-not-simply-use-http-as-the-protocol When running uwsgi as an app server behind nginx, it is customary to use To be clear: nginx itself does NOT embed uwsgi in-process here, or get involved with WSGI or python: uwsgi is running in another process that may be somewhere else, to take care of the job of an (e.g.) python app server, and it simply talks to nginx as an upstream using the uwsgi protocol. This means all that is required on the nginx side is the ability to accept configuration of uwsgi as an upstream and the ability to speak that protocol as is often done with nginx. So, not speaking for yue9944882, the very typical use case would be:
Supporting uwsgi_pass should be analogous to supporting other protocols that are used for app servers to talk to nginx. Hope this helps. |
@harts-boundless However, for an edge load balancer, such as an Ingress controller, it is not typical to support uwsgi. |
What I'd rather do, is using the embedded HTTP server that uWSGI has: http://uwsgi-docs.readthedocs.io/en/latest/HTTP.html Your ingres can connect directly with that, so there is no need for a second nginx pod. This way you can run a single container that has uwsgi as main process. Use a config file like: (update April 2022: incorporated latest insights)
and set default values for your environment variables in your container:
When you use Django, you can use whitenoise (http://whitenoise.evans.io/) to serve media/static files from your container. In this example, I've used UWSGI directly for that. Preferably, those are cached at your loadbalancer / ingres / cloudfrond environment to avoid hitting the container each time. Thanks to the |
This is mostly for the sake of learning: the fact that the sqlite database is in container means it's fairly useless: you can't scale horizontally. Future work will explore different ways of dealing what that. The Dockerfile is update to reflect the latest placement extraction changes and to put config in the container rather than using a shared volume. The placement-uwsgi.ini is update so it runs http directly. There's no need for an nginx or apache setup, a k8s LoadBalancer in deployment.yaml takes care of that. The uwsgi ini is based on info at: nginx/kubernetes-ingress#143 (comment) Using minikube the steps are: eval $(minikube docker-env) docker build -t placedock:1.0 . kubectl apply -f deployment.yaml kubectl expose deployment placement-deployment --type=LoadBalancer minikube service placement-deployment --url
Other configurations come from nginx/kubernetes-ingress#143 (comment)
See docs at https://uwsgi-docs.readthedocs.io/en/latest/HTTP.html This paves the way for us to drop the nginx sidecar and instead directly use nginx-ingress as the web-facing server. Ideas for many configurations configurations come from nginx/kubernetes-ingress#143 (comment)
It's a shame that this issue was closed without any discussion. It would have opened up more nginx capability. OP probably knew about uwsgi http support already... Fcgi support would be also great. Another benefit of uwsgi is not needing any xforwarded and all the headers http puts. I also see static files depending on nginx is better, rather than relying on uwsgi with shorter history of supporting http than nginx. Hitting containers is no issue with k8s, if it is, the application should be fixed. |
Thank you @vdboor vdboor. Ive been contemplating editing uwsgi to do this, but your config was a great guide and working. Thanks for the assists. |
@vdboor , thanks, it is helpful |
I didn't find a usable configuration in the source code when rendering ingress to a nginx conf file, for example, "uwsgi_pass" option support?
Any one have a practice to integrate uWSGI to the controller ?
The text was updated successfully, but these errors were encountered: