Kubernetes 入口控制器公开到特定端口

Kubernetes ingress controller expose to specific port

我所在机构的防火墙设置阻止了大部分外部端口,目前,我有内部 Linux 虚拟机,例如 http://abc.xyz:5555 (this link can only be accessed in the internal network), and a Netscaler is set up by the admin so that the internal link is forward to a publicly available link: https://def.edu

现在我有多个 Web 服务器使用 5556,5557,5558 等端口。我想设置 Kubernetes 入口,所有流量首先进入入口控制器,入口将流量转发到我的多个 Web 服务。通常如下图所示。

我只有5555端口可用,但Ingress的所有教程似乎都只支持HTTP 80和HTTPS 443端口。我的问题是,我可以将 Ingress 控制器主机设置为 http://abc.xyz:5555? Or I should go for other approaches, like this said: An Ingress does not expose arbitrary ports or protocols. Exposing services other than HTTP and HTTPS to the internet typically uses a service of type Service.Type=NodePort or Service.Type=LoadBalancer.,如果可以,我应该使用什么 terms/techniques?

我建议使用入口,因为每个负载均衡器都会分配一个自己的外部 ip。您可以指定自定义端口和协议(tcp、udp、http)。我使用 nginx,但文档似乎已经过时(上周最后一次检查)。所以我们目前正在使用 Traefik。 Web 仪表板对调试它也有很大帮助。

我们是如何解决的:

  1. 通过 helm 使用自定义值安装 traefik,因此它会监听 80 和 443 以外的其他端口;在 values.yaml 中添加自定义入口点并使用以下命令安装 traefik: helm install --values values.yaml stable/traefik

  2. 安装你的入口http/tcp/udp路由

  3. 转发您的网络仪表板并转到 http://localhost:9000/dashboard

详细步骤请看官方文档:https://docs.traefik.io/getting-started/install-traefik/#use-the-helm-chart