Yup, check out this project, it's recommended. An alternative project that does the same task is here.
Check out a project that I worked on some time ago. This uses Azure Container Instances and Azure Functions to scale dedicated game servers on Azure. Making a similar mechanism with Kubernetes was the next logical step.
DGSs are crated on each Node on a specific port (or set of ports, depending on the server requirements) (conceptually similar to the command docker run dedicatedgameserver -p X:Y
). Port assignment and mapping is managed by our project.
How did you end up using this networking solution? I know that Kubernetes has a thing called 'Service' that allows exposing applications on the Internet (and a lot more).
Kubernetes Services is a way to expose a set of Pods via a DNS name (and more). Traffic sent to a Service is distributed to a corresponding set of Pods via a specified Load Balancing algorithm. A certain type of Service, called Load Balancer allows exposing a set of Pods over the Internet, via the cloud provider's Load Balancer Service. On Azure, a service called Azure Load Balancer is used for this purpose.
In our case, each DGS is a single entity. There is no need for an extra layer for the Load Balancing and network traffic management, since game clients are connecting directly to the DGS. Moreover, the use of a Load Balancer Service was also discouraged because a) it would be an overkill to have a unique Load Balancer for each Dedicated Game Server and b) (most importantly) the presense of a Load Balancer would potentially add unnecessary network hops, thus probably increasing the network latency. Another solution we tested was this of a NodePort Service. This was abandoned as well because of the overhead of managing the Service entities. Consequently, the solution was to expose the Nodes to the Internet via Public IPs. AKS does not allow that by default in the time of writing, so we created this utility to implement this functionality.
Moreover, on the port assignment, our first effort was to use hostNetwork
functionality for each Pod link, so we would hook up the container to each Node's network layer (=> no software NAT for our containers). This would require us to have the DGS listen to a specific port (assigned by our project). As you can easily understand, this could disqualify DGSs that can only listen to hardcoded ports. So, we ended up using Kubernetes hostPort
for each Pod. What we do is set a manual port (or more, depending on the DGS) for each Pod that is mapped to the game server's original listening port. Mapping is made possible via software NAT (container networking).
Check here.
Check here.
How did you mock time in your code for the autoscaler tests? [or, what is this 'clock' field in some objects]
We needed to mock time
object for our tests, check this blog post for instructions.
Apart from the Kubernetes dashboard, you can also use Weave Scope.
# install Weave Scope
kubectl apply -f "https://cloud.weave.works/k8s/scope.yaml?k8s-version=$(kubectl version | base64 | tr -d '\n')"
# port-forward the dashboard
kubectl port-forward -n weave "$(kubectl get -n weave pod --selector=weave-scope-component=app -o jsonpath='{.items..metadata.name}')" 4040
# open localhost:4040 on your browser
I see that you have a self-signed certificate for authentication with WebhookServer. How can I generate my own?
Easy enough, use openssl (source)
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -nodes -subj '/CN=aks-gaming-webhookserver.default.svc' -days 365
Run this command (source):
kubectl get configmap -n kube-system extension-apiserver-authentication -o=jsonpath='{.data.client-ca-file}' | base64 | tr -d '\n'
Check this bash script. These script might help in troubleshooting as well.
Yes, but unfortunately at the time of writing it is hardcoded into the application (check the constants.go file), so you would need to recompile and redeploy the solution.
You could potentially move some of your static assets out of the container image and have it hosted elsewhere, e.g. on an Azure File Storage account. This will allow you to have a smaller image. Beware though that you should pay attention when you upgrade your image.
Project installation creates an external Load Balancer that opens public access to the API Server. How could I make the Load Balancer internal?
Project (mainly for demonstration purposes) creates a LoadBalancer Kubernetes Service for the project's API Server. Even though its methods are protected by a code (the one that's stored in a Secret), it would be wise to hide it from the public internet. To accomplish this, you can use an internal Load Balancer using the instructions here.
Check Azure Container Registry
A lot!
- for a fully managed approach, you might want to check PlayFab Multiplayer Servers
- if you want to use Azure Container Instances service, check this project
- if you want to use Azure Batch service, check this project to get started
- Google and Ubisoft are working on project Agones which runs absolutely fine on AKS