Report this

What is the reason for this report?

How to set two Python flask apps talking to each other in k8s via SSL

Posted on September 26, 2022

Hi all,

I just migrated from k8s hosted on Azure to Digital Ocean. I have two pods - one back end, offering a REST API to another pod, a front web app. Both are Python 3.7 Flask applications. When I do a web call from Postman (from my PC) I can hit the REST api pod successfully. However when the web pod hits it, I get: File “/usr/local/lib/python3.7/ssl.py”, line 1139, in do_handshake self._sslobj.do_handshake() ConnectionResetError: [Errno 104] Connection reset by peer

I have installed a new wildcard certificate. There is also an nginx and gunicorn server that run in docker container. Does anyone have any clue why I am getting the 104 error? Thank you very much in advance.

Martin



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

The ConnectionResetError: [Errno 104] Connection reset by peer typically indicates that an established connection was closed by your peer (the server). It’s possible that this error could be originating from SSL handshake failure, network misconfiguration, firewall settings blocking the connection, or any issue with Gunicorn/Nginx.

I suggest you check the logs for your Flask application, Nginx, and Gunicorn. These might contain more information on what’s going wrong. Also, validate your Kubernetes network policies and ensure the pods are allowed to communicate with each other.

Additionally, you may want to verify the SSL certificates and keys used by Python in your Docker image. Ensure they are correctly installed and accessible.

If everything looks good there, you might also want to test your Gunicorn server separately to rule out any problems on that end.

For any further technical guidance, you may want to explore the following resource from DigitalOcean Documentation:

Setting Up an Nginx Ingress with Cert-Manager on DigitalOcean Kubernetes

Hope that this helps!

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

Dark mode is coming soon.