Kubernetes L7 入口是否可以用于非 HTTP 端口流量?

Can Kubernetes L7 ingress be used for non-HTTP port traffic?

我有两个不同的 Minecraft 服务器容器 运行,都设置为使用默认的 TCP 端口 25565。为了让外行连接起来简单,我想要一个专用于每个服务器的子域,比如说mc1.example.com 和 mc2.example.com,这样他们只输入地址,客户端就会连接。

对于 HTTP(s) 服务,NGINX L7 入口工作正常,但它似乎不适用于 Minecraft。 NodePort 运行良好,但每个服务器都需要不同的端口。

这也安装在裸机上 - 没有可用的云 L4 负载平衡器,IP 地址池非常有限(假设没有足够的地址来覆盖所有各种 Minecraft 服务器)。

是否可以修改 L7 入口以将 mc1.example.com 重定向到正确的容器端口 25565?我需要使用类似 MetalLB 的东西吗?

This is also installed on bare metal - there is not a cloud L4 load balancer available, and a very limited pool of IP addresses (assume there are not enough to cover all the various Minecraft servers).

如果您没有足够的 IP 地址,那么 MetalLB 将无济于事,因为它只是使用 BGP 为您虚拟主机,但您必须分配虚拟地址。根据您对情况和问题的描述,我敢说您正试图以低廉的成本做到这一点,而且正如人们可能预料的那样,没有资源很难开展工作。

也就是说:

据我所知,the modern Minecraft protocol, but interestingly enough during the Handshake the client does actually send the hostname to which it is attempting to connect. That may or may not be something that BungeeCord 中没有重定向,我没有研究它的源代码。

因此,理论上 可以制作特定于 Minecraft 的虚拟主机代理,因为该协议已经有相当多的实现。但是,可能必须研究协议中的所有消息以确保它们包含对实际连接 ID 的引用,否则您将不得不求助于 (client-ip, client-port) 标识元组,有效地将您的服务器变成反向 NAT/PAT执行。可能没问题,注意一下。