Kubernetes - hosting game server with UDP. How to connect/route traffic to POD?

8/25/2017

Fore few days I've been playing with Kubernetes cluster on Azure Container Service, with goal to host Unreal game servers on it.

After days of experiments and few questions on SO I got to the point where I can host few servers on single node and connect to them with clients.

In my latest setup I deployed PODs directly with hostNetwork: true. Added LoadBalancer with public IP and manually mapped ports from agent node where pods are deployed to NAT load balancer.

While works I'm not entirely convinced it is good solution. While it can be automated I'm not sure it will be scalable under load.

  1. I need to wait until pod is created. I can assume what port is needed, because unreal aromatically open on 7777 port and then increment by one until it find one.

  2. Once pod is created I need to add NAT port forwarding to load balancer (but I can't do it until I know on which Node pod is located).

  3. Adding new NAT rules to load balancer takes time. Quite a bit of time, from what I have seen so far.

  4. I'm using external load balancer to route traffic at particular PODs. It probabaly would be better to do it from within Kubernetes.

There few things that must be meet:

  1. Client connect to server trough UDP.

  2. It would be best keep amount of public IPs to minimum.

What would be best way to directly expose PODs trough UDP to external clients ? Port Forwarding is not that bad option (although is limited in the amount of PODs I can expose trough single public ip, at least I think so). What I'd like to achive is to either connect client directly to server, or route client traffic to particular POD (ie router->service->pod scenario is acceptable, but the less indirection the better).

I have read this: http://www.compoundtheory.com/scaling-dedicated-game-servers-with-kubernetes-part-1-containerising-and-deploying/ And it is nice source on information although I'm not sure if the server is connected trough UDP (which is must have requirement for me). Or how exactly does unity client connect directly to internal POD IP.

-- Ɓukasz Baran
azure
azure-acs
azure-container-service
kubernetes

1 Answer

8/25/2017

I suggest you to take a look on Ingresses controller, I know that the Nginx one support UDP routing.

So, you expose Nginx-ingress with load-balancer IP and you create UDP configmap to route directly on your pods.

You should give it a try.

https://github.com/kubernetes/contrib/tree/master/ingress/controllers/nginx/examples/udp

-- Valentin Ouvrard
Source: StackOverflow