容器化 Django 应用程序可以在本地运行,但不能在 GKE 上运行

问题描述 投票:0回答:1

任何容器化 Django 应用程序都可以在本地运行,但在 GKE 上运行时仅返回“

no healthy upstream
”。

我尝试了这个 django 示例:https://github.com/mukulmantosh/cloud-code-helloworld 我只注释掉了

mysqlclient
文件中的
requirements.txt
。我也只使用
src/
文件夹中的内容。

在 GKE 中,应用程序在入口内部负载均衡器后面运行(由于某些公司原因,我无法访问 Cloud Run)。

我在本地模式下得到的:

(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

我在 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
django google-cloud-platform google-kubernetes-engine
1个回答
0
投票

您需要有一个 VPC 防火墙规则,允许负载均衡器运行状况检查探测 IP 范围连接到运行您的部署的 kubernetes 节点。 根据 https://cloud.google.com/load-balancing/docs/health-check-concepts#ip-ranges 对于内部负载均衡器,它们是:

35.191.0.0/16
130.211.0.0/22
© www.soinside.com 2019 - 2024. All rights reserved.