Harnessing GCP for Gaming: Deploying Xonotic with Agones on GKE
GCP Gaming eco-system
While Google Cloud Platform (GCP) doesn’t offer a dedicated gaming service, it provides a comprehensive set of tools for building a scalable gaming infrastructure. With components like Google Kubernetes Engine (GKE) for container orchestration, Compute Engine for virtual machines, and Cloud Storage for asset management, developers can create a powerful backend. Services like Cloud SQL manage player data, Cloud CDN speeds up asset delivery, and Load Balancing ensures smooth multiplayer experiences. Together, these GCP tools enable developers to create a scalable, reliable gaming ecosystem.
What is Agones
Agones is an open-source tool specifically built for managing game servers on Kubernetes. It offers a framework that streamlines the deployment, scaling, and overall management of multiplayer game servers, which is crucial given the unique challenges that come with gaming environments.
Key Features of Agones
- Game Server Management – Agones provides custom Kubernetes resources, such as GameServer and Fleet, tailored for game server deployment and management.
- Fleet Management – We can create fleets of game servers, allowing for efficient scaling and management. This means you can run multiple instances of the same game server and easily manage their lifecycle.
- Automatic Scaling – Agones support autoscaling based on player demand. As players join or leave, Agones can automatically spin up or down game servers to meet the needs of your player base.
- Health checks and Recovery – Agones include health checks to monitor the status of game servers. If a server becomes unhealthy, Agones can automatically restart it to ensure a smooth gaming experience.
- Session Management – The platform allows for session management, enabling you to track player sessions, matchmaking, and connections more effectively.
Read more: Building the Future of Multiplayer Games with AWS GameLift: Key Strategies for Success
Create Kubernetes Cluster and Setup Agones
Note – We will set up a Kubernetes cluster on Google Cloud Platform (GCP) and install the Agones components to manage game servers. Once the setup is complete, we’ll deploy a Xonotic game server on the cluster and connect to it using the Xonotic client.
Step 1 – Open Cloud Shell
Step 2 – Export CLUSTER_NAME
$export CLUSTER_NAME=game-server |
Step 3 – Now create Kubernetes cluster by using below command
$gcloud container clusters create $CLUSTER_NAME –no-enable-legacy-authorization –tags=game-server –scopes=gke-default –num-nodes=3 –machine-type=n1-standard-2 –region=us-central1-a |
Step 4 – Create Firewall Rule
$gcloud compute firewall-rules create game-server-firewall –allow udp:7000-8000 –target-tags game-server –description ‘Firewall to allow game server udp traffic’ |
Step 5 – Connect to Cluster
$gcloud config set container/cluster $CLUSTER_NAME $gcloud container clusters get-credentials –region=us-central1-a $CLUSTER_NAME $kubectl cluster-info |
Now, we will install Agnoes
Step 6 – Create agones-system Name Space
$kubectl create namespace agones-system |
Step 7 – Add agones repo
$helm repo add agones https://agones.dev/chart/stable $helm repo update |
Step 8 – Install agones
$helm install agones –namespace agones-system agones/agones |
$kubectl –namespace agones-system get pods -o wide |
Here, We can see all agones components are up and running.
Step 9 – Create Fleet
$kubectl apply -f https://raw.githubusercontent.com/googleforgames/agones/release-1.44.0/examples/xonotic/fleet.yaml |
$kubectl get fleet |
$kubectl get gameservers |
Install Xonotic Client on Linux Machine
Step 1 – Download Xonotic game binary & extract it.
$get http://dl.xonotic.org/xonotic-0.8.5.zip $unzip xonotic* |
Step 2 – Go to xonotic folder and execute the below file.
$cd xonotic $bash xonotic-linux-glx.sh |
Now, Xonotic client has been started
Step 3 – Click on Multiplayer > Servers
Get gameserver IP and port using this command (kubectl get gameservers)
Add paste here.
Click on Join, Here we go…
Conclusion
Integrating Google Cloud Platform (GCP) with Agones provides a scalable and efficient solution for managing multiplayer game servers. With GCP’s robust infrastructure and Agones’ specialized tools, developers can easily build seamless, responsive gaming experiences. Whether supporting a small community or millions of players, this combination offers the flexibility to scale as needed. As the gaming industry evolves, GCP and Agones give developers the edge to deliver high-quality, immersive gameplay at scale.
If you want to know more about the possibilities for your projects, do not hesitate to contact us. Our AWS Certified Architects and DevOps Engineers are committed to saving you time and resources while improving business efficiency and reliability.