Skip to main content
BlogComputeNo Lag, All Frag: Level Up Your Gaming with Xonotic, K3s, and Edge Computing

No Lag, All Frag: Level Up Your Gaming with Xonotic, K3s, and Edge Computing

No_Lag_All_Frag_Level_Up_Your_Gaming

Let’s set the scene for a gamer: you’re having the game of your life (and you wish you were streaming today of all days). You’re lining up the perfect winning headshot, and you’re already picturing the win-screen display popping up…and then the game lags. You’re taken out by your opponent. Game over.

We’ve all been there when a small glitch in real time playing costs you your moment of glory and victory lap. Frustration with this exact experience has led to a resurgence in popularity for playing entirely self-hosted games so you can control your own destiny as a player. But, unfortunately, self-hosting isn’t an option for every game or every gamer. But what if we told you there’s a way to banish lag to the shadow realm without having to purchase and maintain your own hardware?

With just a little development, you can build your own distributed gaming paradise by bringing the server closer to you (the player) and creating your own low-latency experience. Enter the power trio: Xonotic, K3s, and the power of edge computing with Akamai Cloud.

What’s the Edge, Anyway?

Instead of relying on massive, centralized data centers that might be hundreds (or even thousands) of miles away, edge computing brings the processing power closer to the source of data – in this case, that’s you. This dramatically reduces the latency that creates that dreaded lag, simply because the data doesn’t need to travel as far.

Why K3s? Keeping it Lightweight and Nimble

K3s is a lightweight Kubernetes distribution. Think of Kubernetes (or K8s) as an incredibly smart and efficient manager for your applications that handles the deployment, scaling, and making sure everything runs smoothly. K3s is an offshoot of K8s specifically designed for resource-constrained environments. It’s small, fast, and incredibly effective – and can be your gaming infrastructure helper.

And Agones? The Game Server Maestro

Agones is an open-source, Kubernetes-native project specifically designed for managing dedicated game servers. It handles the complexities of scaling, allocating, and running game server instances so you can focus on fragging, not fiddling with server configurations.

Let’s Get Building! (The Fun Part)

We’re going to set up a Xonotic server (a fast-paced, free, open-source FPS) on a Linode instance, managed by K3s and Agones. Get ready to experience Xonotic like never before! If you’d like to follow our full guide, go to the docs.

Step 1: Terraform Time – Laying the Foundation

Terraform is our “Infrastructure as Code” tool. It lets us define our server setup in a file, making it repeatable and easy to manage. First, install it:

brew install terraform

(Note: If you’re not on macOS, check the Terraform website for installation instructions for your OS.)

Step 2: Project Setup – Your Gaming HQ

Let’s create a directory for our project:

mkdir xonotic

cd xonotic

Step 3: The Terraform Script – Building Your Server (and Firewall!)

Create a file named main.tf and paste in the following code. 

This is where the magic happens! We’re defining our Linode instance, setting up a firewall, and configuring everything we need. 

In this case, we’re deploying a dedicated compute instance in Denver, one of Akamai’s distributed compute regions. We recommend using the 8GB Dedicated instance which has 4 vCPUs, which is appropriate for several challengers.

Note: You will need to gain access to the distributed compute regions that are currently in limited availability for this sample code to work as-is.

# Specify the required Terraform provider

terraform {

  required_providers {

    linode = {

      source = "linode/linode"

      version = ">= 1.27.0"  # Ensure a version that supports metadata

    }

  }

}

# Define variables for sensitive information

variable "linode_token" {

  description = "Linode API token"

  type        = string

  sensitive   = true

}

variable "root_password" {

  description = "Root password for the instance"

  type        = string

  sensitive   = true

}

variable "admin_ip" {

  description = "IPv4 address to be used to access the instance"

  type        = string

  sensitive   = true

}

# Configure the Linode provider

provider "linode" {

  token = var.linode_token

}

# Define the cloud-init configuration

data "template_file" "cloud_init" {

  template = <<EOF

#cloud-config

package_update: true

package_upgrade: true

runcmd:

  - apt update -y

  - apt upgrade -y

EOF

}

# Create a 8GB dedicated Linode instance in Denver

resource "linode_instance" "my_instance" {

  label     = "xonotic-game-server"

  region    = "us-den-1"

  type      = "g6-dedicated-edge-4"

  image     = "linode/ubuntu20.04"

  root_pass = var.root_password

  booted    = true

  metadata {

    user_data = base64encode(data.template_file.cloud_init.rendered)

  }

}

# Create a firewall to allow incoming traffic on port 22 and 7000-8000

resource "linode_firewall" "my_firewall" {

  label = "xonotic-firewall"

# Drop everything that is not covered by an explicitly rule

  inbound_policy = "DROP"

# Allow all outbound traffic

  outbound_policy = "ACCEPT"

  # Rule to allow SSH (port 22)

  inbound {

    label    = "allow-ssh"

    action   = "ACCEPT"

    protocol = "TCP"

    ports    = "22"

    ipv4     = [var.admin_ip]

  }

  # Rule to allow custom port range (7000-8000)

  inbound {

    label    = "allow-custom-ports"

    action   = "ACCEPT"

    protocol = "UDP"

    ports    = "7000-8000"

    ipv4     = ["0.0.0.0/0"]

    ipv6     = ["::/0"]

  }

  # Rule to allow Agones port 8080

  inbound {

    label    = "allow-custom-ports"

    action   = "ACCEPT"

    protocol = "TCP"

    ports    = "8080"

    ipv4     = ["0.0.0.0/0"]

    ipv6     = ["::/0"]

  }

  # Associate the firewall with the instance

  linodes = [linode_instance.my_instance.id]

}

# Output the instance's IP address

output "instance_ip" {

  value = linode_instance.my_instance.ip_address

}

Now, create a file named terraform.tfvars and add your Linode API token and a root password (don’t forget to replace the placeholders!):

linode_token  = "your_linode_api_token"

root_password = "your_root_password"

admin_ip = "your_ipv4_address/32"

Important Security Note: Keep your terraform.tfvars file safe and never commit it to a public repository!

If you’re not sure of your current IP address you can use the following command which will return your current public IP address.

curl http://whatismyip.akamai.com

Step 4: Initialize and Apply – Let Terraform Do Its Thing!

First, initialize Terraform:

terraform init

This downloads the Linode Provider. Then, apply the configuration:

terraform apply

You’ll be prompted to confirm the changes. Type yes and hit Enter. Terraform will now provision your Linode instance and set up the firewall. This might take a few minutes. Grab a coffee (or, you know, practice your aim…).

Step 5: SSH In – Your Server Awaits!

Once Terraform is finished, it will output the IP address of your instance. You can also find the reverse DNS name in the network tab of your newly created instance on the Linode Cloud Manager. Use SSH to connect:

ssh root@your_instance_ip_or_dns

Replace your_instance_ip_or_dns with the actual IP address or DNS name. You’ll be prompted for the root password you set in terraform.tfvars.

Step 6: Install K3s – The Lightweight Kubernetes Powerhouse

This is surprisingly easy! Just run this command on your Linode instance:

curl -sfL https://get.k3s.io | sh -

This downloads and installs K3s. It’ll take a minute or two.

Step 7: Install Agones – Game Server Orchestration Time!

Now we’ll install Agones, which will manage our Xonotic game servers. Run these commands:

kubectl create namespace agones-system

kubectl apply --server-side -f https://raw.githubusercontent.com/googleforgames/agones/release-1.47.0/install/yaml/install.yaml

This creates a dedicated namespace for Agones and deploys it to your K3s cluster.

Step 8: Confirm Agones is Running – Check the Status

Let’s make sure everything is running smoothly:

kubectl describe --namespace agones-system pods

You should see an output indicating that the Agones pods are running.

Step 9: Deploy and fetch the Xonotic Game Server status.

kubectl apply -f https://raw.githubusercontent.com/googleforgames/agones/release-1.47.0/examples/xonotic/fleet.yaml

 watch kubectl describe gameserver

Step 10: Get the Game Server IP – Ready to Connect!
Get a list of your game servers and their IP addresses:

kubectl get gs

Step 11: Xonotic Client – Download and Install

If you don’t have it already, download the Xonotic client for your operating system from https://xonotic.org/.

Step 12: Connect and Play! – Frag Time!

  1. Launch Xonotic: Start the client.
  2. Multiplayer Mode: Go to “Multiplayer”.
  3. Server Connection: Choose to join a server manually.
  4. Enter IP and Port: Input the IP address and port you got from the kubectl get gs command.
  5. Join the Game: Connect and enjoy your low-latency Xonotic experience!

Cleaning Up (When You’re Done Dominating)

To remove the Agones fleet and the game server instances:

kubectl delete -f https://raw.githubusercontent.com/googleforgames/agones/release-1.47.0/examples/xonotic/fleet.yaml

You can then use terraform destroy in your project directory to remove the Linode instance and firewall to prevent any further costs.

Conclusion: The Future of Gaming is in Your Hands

You just built a powerful, low-latency gaming setup using edge computing, K3s, and Agones. This demonstrates how you can move away from completely relying on gaming provider-owned servers and bring your gaming experience closer to home. This makes gaming smoother, more responsive, and more fun – and no more latency-induced losses. 

Akamai has over 25 globally distributed core compute regions available to our cloud computing customers. To bring workloads even closer to home, you can leverage our distributed compute regions to deploy dedicated instances in major metros underserved by cloud providers, including Auckland, Johannesburg, and Bogotá. Sign up for an account, check out the full list of available distributed regions, and get in touch with our cloud consultants to see if you’re eligible to access resources in your location or create a support ticket.

If you want to learn more, check out our guide on how to set up a Xonotic server with K3s and Agones.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *