menu
arrow_back

Running Dedicated Game Servers in Google Kubernetes Engine

90m access · 60m completion
Connection Details

9 Credits

info_outline
This lab costs 9 Credits to run. You can purchase credits or a subscription under My Account.

01:30:00

Running Dedicated Game Servers in Google Kubernetes Engine

GSP133

Google Cloud Self-Paced Labs

Packaging server applications as containers is quickly gaining traction across the tech landscape, and game companies are no exception. Many game companies are interested in using containers to improve VM utilization as well as take advantage of their isolated run-time paradigm. Despite high interest, many companies don't know where to start.

This lab will show you how to use an expandable architecture for running a real-time, session-based multiplayer dedicated game server using Kubernetes on Google Kubernetes Engine. A scaling manager process is configured to automatically start and stop virtual machine instances as needed. Configuration of the machines as Kubernetes nodes is handled automatically by managed instance groups. The online game structure presented in this lab is intentionally simple, and places where additional complexity might be useful or necessary are pointed out where appropriate.

Objectives

  • Create a container image of a popular open-source dedicated game server (DGS) on Linux using Docker. This container image adds only the binaries and necessary libraries to a base Linux image.

  • Store the assets on a separate read-only persistent disk volume and mount them in the container at run-time.

  • Setup and configure basic scheduler processes using the Kubernetes and Google Cloud APIs to spin up and down nodes to meet demand.

Before you begin start the download of the game client

In this lab you'll be creating a game server, and to test the server, you need to connect to a game client. The OpenArena game client is available for many operating systems, as long as you can install it on your local machine. If you cannot install a game client on the machine you're currently using, consider taking this lab when you are using a machine you can install a game client on. Validating your work by connecting to a game client is not required, you can choose not to. Taking this lab will still show you how to create a dedicated game server, you just won't be able to confirm it works.

Install the OpenArena game client on your computer to test the connection to the game server at the end of the lab :

http://openarena.wikia.com/wiki/Manual/Install

This will take a while. Start working on the lab while it downloads, and check back in about 30 min to see if it's finished. Then install the game client.

Architecture overview

The Overview of Cloud Game Infrastructure discusses the high-level components common to many online game architectures. In this lab you implement a Kubernetes DGS cluster frontend service and a scaling manager backend service. A full production game infrastructure would also include many other frontend and backend services which are outside the scope of this solution.

68b111517057146c.png

Constructive constraints

In an effort to produce an example that is both instructive and simple enough to extend, this lab assumes the following game constraints:

  • This is a match-based real-time game with an authoritative DGS that simulates the game State.
  • The DGS communicates over UDP.
  • Each DGS process runs one match.
  • All DGS processes generates approximately the same amount of load.
  • Matches have a maximum length.
  • DGS startup time is negligible, and 'pre-warming' of the dedicated game server process isn't necessary.
  • Customer experience impact should be avoided as much as possible:
  • Once peak time has passed, matches should not be ended prematurely in order to scale down the number of VM instances.
  • However, if the dedicated game server process encounters an issue and cannot continue, the match state is lost and the user is expected to join a new match.
  • The DGS process loads static assets from disk but does not require write access to the assets.

These constraints all have precedent within the game industry, and represent a real-world use case.

Setup and Requirements

Qwiklabs setup

What you'll need

To complete this lab, you’ll need:

  • Access to a standard internet browser (Chrome browser recommended).

  • Time. Note the lab’s Completion time in Qwiklabs. This is an estimate of the time it should take to complete all steps. Plan your schedule so you have time to complete the lab. Once you start the lab, you will not be able to pause and return later (you begin at step 1 every time you start a lab).

  • The lab's Access time is how long your lab resources will be available. If you finish your lab with access time still available, you will be able to explore the Google Cloud Platform or work on any section of the lab that was marked "if you have time". Once the Access time runs out, your lab will end and all resources will terminate.

  • You DO NOT need a Google Cloud Platform account or project. An account, project and associated resources are provided to you as part of this lab.

  • If you already have your own GCP account, make sure you do not use it for this lab.

  • If your lab prompts you to log into the console, use only the student account provided to you by the lab. This prevents you from incurring charges for lab activities in your personal GCP account.

Start your lab

When you are ready, click Start Lab. You can track your lab’s progress with the status bar at the top of your screen.

Find Your Lab’s GCP Username and Password

To access the resources and console for this lab, locate the Connection Details panel in Qwiklabs. Here you will find the account ID and password for the account you will use to log in to the Google Cloud Platform:

Open Google Console

If your lab provides other resource identifiers or connection-related information, it will appear on this panel as well.

Log in to Google Cloud Console

Using the Qwiklabs browser tab/window or the separate browser you are using for the Qwiklabs session, copy the Username from the Connection Details panel and click the “Open Google Console” button.

You'll be asked to choose an account. Click Use another account. Google_choose_Account

Paste in the Username, and then the Password as prompted:

Sign in to continue to Google Cloud Platform

Accept the terms and conditions.

Since this is a temporary account, which you will only have access to for this one lab:

  • Do not add recovery options
  • Do not sign up for free trials

Activate Google Cloud Shell

Google Cloud Shell provides command-line access to your GCP resources.

From the GCP Console click the Cloud Shell icon on the top right toolbar:

Cloud Shell Icon

Then click START CLOUD SHELL:

Start Cloud Shell

It takes a few moments to provision and connect to the environment:

Cloud Shell Terminal

The Cloud Shell is a virtual machine loaded with all the development tools you’ll need. It offers a persistent 5GB home directory, and runs on the Google Cloud, greatly enhancing network performance and authentication.

Once connected to the cloud shell, you'll see that you are already authenticated and the project is set to your PROJECT_ID:

gcloud auth list

Output:

Credentialed accounts:
 - <myaccount>@<mydomain>.com (active)
gcloud config list project

Output:

[core]
project = <PROJECT_ID>

Join Qwiklabs to read the rest of this lab...and more!

  • Get temporary access to the Google Cloud Console.
  • Over 200 labs from beginner to advanced levels.
  • Bite-sized so you can learn at your own pace.
Join to Start This Lab
home
Home
school
Catalog
menu
More
More