Containerized Django application works on local, but not on GKE
Any containerized Django applications work in local, but only return "no healthy upstream" when run on GKE.
I tried with this django example: https://github.com/mukulmantosh/cloud-code-helloworld
on which I only commented out the mysqlclient in the requirements.txt file.
In GKE the application runs behind an ingress internal load balancer (I have no access to Cloud Run for some corporate reason).
What I get in local mode:
(base) C:\Users\path\to\app>docker run -p 8080:8080 helloworld:1
[21/Feb/2024 10:54:17] "GET / HTTP/1.1" 200 3968
[21/Feb/2024 10:54:17] "GET /static/KE-hello-world.svg HTTP/1.1" 200 116030
[21/Feb/2024 10:54:17] "GET /static/cloud_bg.svg HTTP/1.1" 200 7213
[21/Feb/2024 10:54:17] "GET /static/kubernetes-engine-icon.png HTTP/1.1" 200 6967
[21/Feb/2024 10:54:19] "GET / HTTP/1.1" 200 3968
What I get in the Workload logs on GCP:
2024-02-21 12:03:40.613 CET
Not Found: /
2024-02-21 12:03:40.613 CET
[21/Feb/2024 11:03:40] "GET / HTTP/1.1" 404 2272
You need to have a VPC firewall rule that allows the load balancer health check probe IP ranges to connect to the kubernetes nodes running your deployment. Per https://cloud.google.com/load-balancing/docs/health-check-concepts#ip-ranges for internal load balancers they are:
35.191.0.0/16
130.211.0.0/22