Dedicated Game Server Platform on OpenShift by Agones
In this article, we’ll go over utilizing Helm to install and run a dedicated open-source cloud Game Server Platform on OpenShift by Agones. In the end, I hope you’ll be encouraged by the potential of open-source technologies in terms of the infrastructure for multiplayer gaming.
media and entertainment industries include video games in significant amounts. Both from a development and a consumer standpoint, much effort and money has been invested. When it comes to developing and implementing scalable dedicated multiplayer game server platforms, much time is spent reinventing the wheel. In an effort to break this insane cycle, the Agones project was developed. Or at the very least serve as a motivating open-source alternative to starting from scratch.
According to the website Agones.dev
Agones is an open source platform, for deploying, hosting, scaling, and orchestrating dedicated game servers for large scale multiplayer games, built on top of the industry standard, distributed system platform Kubernetes.
Given that OpenShift is a tried-and-true enterprise Kubernetes platform that is used by numerous organizations worldwide, it is the ideal partner for the Agones platform.
This example presupposes that you have access to an OpenShift cluster. If not, think about utilizing a tool like OpenShift Local.
Setting up the foundation
- To begin, select Developer from the upper left-hand pane > Project menu and click Create Project to create an OpenShift project called agones-system.
2. To house the GameServer resources we’ll utilize later, build one additional project named pc.
3. For the following step, return to the agones-system project.
Create Helm Repo
We will next launch a straightforward game server installation using Helm on the OpenShift Console UI. In order to complete that process, we must establish a Helm repository. You may do this by going to Developer > Helm, choosing Create from the drop-down menu, and selecting Repository.
- The following details into the form, then click “Create”:
The ProjectHelmChartRepository manifest can also be copied and pasted there if you want to save some time typing:
apiVersion: helm.openshift.io/v1beta1 kind: ProjectHelmChartRepository metadata: name: agones namespace: agones-system spec: connectionConfig: url: 'https://agones.dev/chart/stable' description: >- Agones is a library for hosting, running and scaling dedicated game servers on Kubernetes. name: Agones
2. The Helm Chart should now be shown under +Add > Developer Catalogue:
If you dive deeper into the catalog item you’ll see on the repo information:
Let’s begin installing Agones right away.
Install Helm Chart by clicking.
Enter the namespace(s) where you want your game servers to be located in the chart yaml. Let’s substitute pc for default in this example:
View the section on game servers:
gameservers: maxPort: 8000 minPort: 7000 namespaces: - pc
The Agones Documentation contains a complete list of the customizable parameters.
Note that before installing, you must build these game server projects and namespaces.
Next, click Install.
The pods should be ready in no time now that the helm release has been installed:
Command Line Interface
Now let’s access the command prompt. Then, execute the following commands while logged in as a user with the cluster-admin cluster role:
oc project agones-system oc get pods -n agones-system
You can find something resembling this in the agones-system project/namespace:
NAME READY STATUS RESTARTS AGE agones-allocator-f896b489-8kxrm 1/1 Running 0 102m agones-allocator-f896b489-cvlks 1/1 Running 0 102m agones-allocator-f896b489-t2bfz 1/1 Running 0 102m agones-controller-56469dff4f-dl4cr 1/1 Running 0 102m agones-ping-6d544ff796-t8t79 1/1 Running 0 102m agones-ping-6d544ff796-wn4tr 1/1 Running 0 102m
Create a GameServer
Let’s set up our game servers from the command line now that we are there.
Your gaming server namespace(s) “pc” and similar ones were set up with a Kubernetes Service Account, RoleBinding, and a Secret when the Helm install was completed.
- Run the following command to see what I mean:
oc get sa,secret,rolebinding -l app=agones -n pc
NAME SECRETS AGE serviceaccount/agones-sdk 1 30m NAME TYPE DATA AGE secret/allocator-client.default kubernetes.io/tls 2 30m NAME ROLE AGE rolebinding.rbac.authorization.k8s.io/agones-sdk-access ClusterRole/agones-sdk 30m
Consult the Default Settings manual for further information regarding the rationale.
2. Entering the “pc” namespace now
oc project pc
3. Here, we’ll use the command shown below to construct a straightforward gaming server using a Kubernetes manifest taken directly from the Agones source repository:
oc create -f https://raw.githubusercontent.com/googleforgames/agones/release-1.30.0/examples/simple-game-server/gameserver.yaml
A port and a new residence on your worker node should eventually appear on your GameServer Kubernetes object.
oc get gameserver
NAME STATE ADDRESS PORT NODE AGE simple-game-server-4pr92 Ready 192.168.50.126 7277 ocp4-h86fb-worker-xwbhw 13m
You may need to grant the agones-sdk service account the appropriate permissions to use hostPort if OpenShift was installed on AWS using IPI.
oc adm policy add-cluster-role-to-user <custom cluster role> -z agones-sdk
Testing the Simple Game Server
Let’s use it right away!
- The GameServer can be reached with netcat nc:
nc -u <IP> <PORT>
2. Enter the phrase “Hello OpenShift!”
Note: To allow for UDP communication over the designated hostPort, you must add an additional rule to the automatically produced security group if you installed OpenShift on AWS using an IPI setup.
The GameServer ought to respond with something like:
ACK Hello OpenShift!
3. To instruct the SDK to execute the Shutdown command, put “EXIT” after that:
Poof! There is no longer a gaming server.
oc get gs
No resources found in pc namespace.
You now understand how to establish an OpenShift helm repo and how to use a helm chart to install and use Agones.