使用 nginx 入口控制器作为节点端口的 GCP 内部负载平衡器:连接被拒绝

GCP Internal Load Balancer with ngnix ingress controller as nodeport : Connection Refused

背景: 我们在 GKE 集群中托管应用程序,GKE 集群上的应用程序 运行 有一个入口资源,其中包含指向我们的应用程序服务的规则。我们使用 ingress-nginx 作为这个集群的入口控制器..

我们现在已经创建了一个 GCP 内部负载平衡器 (TCP) 以指向入口控制器服务正在侦听的节点端口。 (注:nginx ingress controller service”是节点端口类型)

  1. 当我们尝试使用 http://ILB-IP:80 (http-port), it throws connection refused exception but gets a desired response when we access directly with nodeport http://ILB-IP:31380 (nodeport)

  2. 访问应用程序时
  3. 当我们将入口服务作为类型负载均衡器提供时,GCP 会在后台创建一个 ILB。 在这种情况下,可以通过 http 端口访问应用程序,并且正在处理所有请求。

任何人都可以帮助我们弄清楚我们何时明确创建 ILB 并发送请求,为什么当我们在 http 端口上访问 ILB 前端时应用程序无法访问,而当 ILB 前端是 ILB- IP:?

提前致谢!

入口控制器需要配置为 type:LoadBalancer,如此 help center article 中所述,这将创建一个外部 LB 以将流量路由到通过入口资源公开的服务,这是预期的方式来做到这一点。

当将入口控制器公开为 type:NodePort 时,服务可以在每个节点的 IP 上的静态端口上访问,如 here 中所述。

通过与 google 支持人员的讨论了解到 LoadBalancer 的服务类型会在每个节点上创建一个 IP table 条目,这允许流量从端口 80 重定向到定义的节点端口。

因此,如果我们的用例需要显式创建 ILB 并且我们的应用程序可以通过节点端口访问, 然后"we have to manually edit the IP tables on each kubernetes node in order to traffic to be redirect from the port 80 to the node port"

检查这个:https://medium.com/google-cloud/internal-load-balancing-for-kubernetes-services-on-google-cloud-f8aef11fb1c4

GCP 已开始支持为 K8S 服务创建内部 LB。