Subscribe to our blog

In this article we will discuss how to install and run an open source cloud native dedicated game server platform on OpenShift Container Platform (OCP) using Helm. My hope is in the end you'll be inspired by the possibilities of open source technology when it comes to multiplayer gaming infrastructure.

Video games are a huge part of the media and entertainment industry. There is a lot of time and capital invested from both a development and consumer perspective. There is also a lot of time spent on reinventing the wheel when it comes to creating and deploying scalable dedicated multiplayer game server platforms. The Agones project was created in an attempt curb that insanity loop. Or at least be an inspiring open source alternative to reinventing the wheel.

To quote the Agones.dev website:

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.

Being that OpenShift is a tried and true enterprise Kubernetes platform used by many orginizations throughout the world it's a perfect fit to pair with the Agones platform.

This example assumes that you have an OpenShift cluster available to you. If not, consider using something like OpenShift Local.

Setting up the foundation

  1. To start we will need to create an OpenShift Project called agones-system by selecting Developer from the upper left hand pane > Project dropdown and Create Project

create-agones-system-openshift-project

  1. Continue on to create one more project called pc to house the GameServer resources we'll be using later.

  2. Switch back to the agones-system project for the next step.

Create Helm Repo

Next we will start a simple game server install via helm on the OpenShift Console UI. As a part of that process we will need to create a Helm repository. You can do this under Developer > Helm then select the Create drop down and choose Repository.

  1. Fill out the form with the following information and click Create:

agones-openshift-helm-repo

Alternatively if you want to save some typing select the yaml view and copy and paste this ProjectHelmChartRepository manifest there:

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
  1. Once created you should now see it under +Add > Developer Catalog > Helm Chart:

agones-openshift-helm-catalog

If you dive deeper into the catalog item you’ll see on the repo information:

agones-openshift-helm-repo-info

Installing Agones

Lets move on to actually installing Agones.

  1. Click on Install Helm Chart

  2. Within the yaml enter the namespace(s) that you want to put your game servers in the chart yaml. For this example lets replace default with pc:

See the gameservers section:

gameservers:
maxPort: 8000
minPort: 7000
namespaces:
- pc

For a full list of configurable parameters see the Agones Documentaion

install-agones-helm-chart

Note that you must create these gameserver projects/namespaces before hitting install.

Then hit Install.

Now you have a helm release installed and the pods should be ready in no time:

agones-successful-deployment

Command Line Interface

Let’s move to the command line. Make sure you’re logged in as a user with a cluster-admin cluster role and issue the following commands:

oc project agones-system
oc get pods -n agones-system

There you will see something similar to the the following 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

Now that we’re at the command line lets setup our game servers from here as well.

When the helm install ran it setup your game server namespace(s) “pc” etc. with a Kubernetes Service Account, RoleBinding and a Secret

  1. To see what I'm talking about run this command:
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

To learn more about the reason why see the Default Settings documentation

  1. Let’s go into our “pc” namespace:
oc project pc
  1. Here we will create a simple game server using the following command that utilizes a kubernetes manifest right from the agones source repo itself:
oc create -f https://raw.githubusercontent.com/googleforgames/agones/release-1.30.0/examples/simple-game-server/gameserver.yaml

Eventually you should see your GameServer kubernetes object come to life with a new home on your worker node along with a port:

oc get gameserver
NAME                       STATE   ADDRESS          PORT   NODE                      AGE
simple-game-server-4pr92 Ready 192.168.50.126 7277 ocp4-h86fb-worker-xwbhw 13m

If OpenShift was intalled on AWS via IPI you may need to give the agones-sdk service acccount the approprate permissions to utilize hostPort

Example:

oc adm policy add-cluster-role-to-user <custom cluster role> -z agones-sdk

Testing the Simple Game Server

Now lets put it to work!

  1. You can communicate with the GameServer via netcat nc:

Example:

nc -u <IP> <PORT>
  1. Type "Hello OpenShift!" and hit enter:
Hello OpenShift!

Note if you installed OpenShift via an IPI install on AWS you will need to add an additional rule to the automatically generated security group to allow for UDP traffic over the allocated hostPort

The GameServer should return an answer like:

ACK Hello OpenShift!
  1. Next type "EXIT" to tell the SDK to run the Shutdown command:
EXIT

Poof! The game server is now gone.

oc get gs
No resources found in pc namespace.

Summary

Now you know how to create a helm repo and use a helm chart to install and utilize Agones on OpenShift. For more information about the Agones project visit: https://agones.dev


About the author

Browse by channel

automation icon

Automation

The latest on IT automation that spans tech, teams, and environments

AI icon

Artificial intelligence

Explore the platforms and partners building a faster path for AI

open hybrid cloud icon

Open hybrid cloud

Explore how we build a more flexible future with hybrid cloud

security icon

Security

Explore how we reduce risks across environments and technologies

edge icon

Edge computing

Updates on the solutions that simplify infrastructure at the edge

Infrastructure icon

Infrastructure

Stay up to date on the world’s leading enterprise Linux platform

application development icon

Applications

The latest on our solutions to the toughest application challenges

Original series icon

Original shows

Entertaining stories from the makers and leaders in enterprise tech