-
Notifications
You must be signed in to change notification settings - Fork 898
Direct connection to a GameServer/Pod without NAT #3804
Description
Is your feature request related to a problem? Please describe.
We have a use case where we want to send traffic directly (via Quilkin) to gameserver instances.
On a single node, we want to have multiple gameservers/pods and be able to send traffic to them via their publicly routable IP address (ipv4 or ipv6) where each gameserver has the same fixed ContainerPort (7777 is the default for Unreal) and without port forwarding or NAT.
A previous issue and PR added the pod IP addresses to the Gameserver Addresses but it is still not possible to directly communicate with a Gameserver instance on Agones. The three port policies (Dynamic, Passthrough and Static) all assume that the HostPort is used in some way and GameServer.Status.Port always shows the HostPort.
Describe the solution you'd like
To directly connect to a Gameserver instance with a publicy routable address and a fixed port without any NAT, the first item in Gameserver.Status.Ports should be the ContainerPort. Ideally no HostPorts would be set as they are not needed. A new PortPolicy called DirectToPod, NoNAT or similar would be one way to configure this.
The places in the code that would need to change:
Describe alternatives you've considered
We have tried configuring Agones a few different ways to get around this issue.
No PortPolicy and no ports configured. This is the closest we got to get it working. No ports are defined in the Gameserver.Spec or the Gameserver.Status. But if you know that port 7777 is exposed then you can access the gameserver instance directly. For us to get this to work with Quilkin, Quilkin would have to default/fall back to port 7777 as Agones doesn't know anything about what ContainerPort is set. Also, that it is possible to work around the Port Policy this way seems like an undocumented, non-obvious feature.
Additional context
Here is an example of how you cannot get around HostPort if a PortPolicy is set.
In the Gameserver Spec:
- Port Policy is set to Dynamic
- ContainerPort is set to 7654
- HostPort was not defined
Output from running kubectl describe gameservers:
Spec:
Container: simple-game-server
...
Ports:
Container: simple-game-server
Container Port: 7654
Host Port: 7133
Name: default
Port Policy: Dynamic
Protocol: UDP
The Gameserver Status - returns the HostPort and not the ContainerPort.
Status:
Address: xxx
Addresses:
Address: xxx
Type: InternalIP
Address: xxx
Type: Hostname
Address: xxx
Type: PodIP
Address: xxx
Type: PodIP
...
Ports:
Name: default
Port: 7133
We tested with the PortPolicy options but none of them worked for us:
- Dynamic PortPolicy with a ContainerPort configured. Agones sets a HostPort and that is the port that is set in GameServer.Status.Ports - and that breaks the communication with Quilkin.
- Static PortPolicy with same port defined for HostPort and ContainerPort. Agones spins up one Gameserver instance/pod per node and is not possible to allocate more pods on that port per node.
- Passthrough PortPolicy. Sets a different port for every gameserver instance so would have to do some sort of mapping to get this to work with Quilkin and our games.