Google Kubernetes Engine

Follow these steps to create a Google Kubernetes Engine (GKE) cluster for your Agones install.

Before you begin

Take the following steps to enable the Kubernetes Engine API:

  1. Visit the Kubernetes Engine page in the Google Cloud Platform Console.
  2. Create or select a project.
  3. Wait for the API and related services to be enabled. This can take several minutes.
  4. Enable billing for your project.
  • If you are not an existing GCP user, you may be able to enroll for a $300 US Free Trial credit.

Choosing a shell

To complete this quickstart, we can use either Google Cloud Shell or a local shell.

Google Cloud Shell is a shell environment for managing resources hosted on Google Cloud Platform (GCP). Cloud Shell comes preinstalled with the gcloud and kubectl command-line tools. gcloud provides the primary command-line interface for GCP, and kubectl provides the command-line interface for running commands against Kubernetes clusters.

If you prefer using your local shell, you must install the gcloud and kubectl command-line tools in your environment.

Cloud shell

To launch Cloud Shell, perform the following steps:

  1. Go to Google Cloud Platform Console
  2. From the top-right corner of the console, click the Activate Google Cloud Shell button: cloud shell
  3. A Cloud Shell session opens inside a frame at the bottom of the console. Use this shell to run gcloud and kubectl commands.
  4. Set a compute zone in your geographical region with the following command. An example compute zone is us-west1-a. A full list can be found at Available regions and zones.
    gcloud config set compute/zone [COMPUTE_ZONE]
    

Local shell

To install gcloud and kubectl, perform the following steps:

  1. Install the Google Cloud SDK, which includes the gcloud command-line tool.
  2. Initialize some default configuration by running the following command.
    • When asked Do you want to configure a default Compute Region and Zone? (Y/n)?, enter Y and choose a zone in your geographical region of choice.
    gcloud init
    
  3. Install the kubectl command-line tool by running the following command:
    gcloud components install kubectl
    

Choosing a GKE cluster mode

A cluster consists of at least one control plane machine and multiple worker machines called nodes. In Google Kubernetes Engine, nodes are Compute Engine virtual machine instances that run the Kubernetes processes necessary to make them part of the cluster.

Agones supports GKE Standard mode and has alpha support for GKE Autopilot mode. Agones GameServer and Fleet manifests that work on Standard are compatible on Autopilot with some constraints, described in the following section. You can’t convert existing Standard clusters to Autopilot; create new Autopilot clusters instead.

Agones on GKE Autopilot

Autopilot is GKE’s fully-managed mode. GKE configures, maintains, scales, and upgrades nodes for you, which can reduce your maintenance and operating overhead. You only pay for the resources requested by your running Pods, and you don’t pay for unused node capacity or Kubernetes system workloads.

This section describes the Agones-specific considerations in Autopilot clusters. For a general comparison between Autopilot and Standard, refer to Choose a GKE mode of operation.

Autopilot nodes are, by default, optimized for most workloads. If some of your workloads have broad compute requirements such as Arm architecture or a minimum CPU platform, you can also choose a compute class that meets that requirement. However, if you have specialized hardware needs that require fine-grained control over machine configuration, consider using GKE Standard.

Agones on Autopilot has pre-configured opinionated constraints. Evaluate whether these constraints impact your workloads:

  • Operating system: No Windows containers.
  • Resource requests: Autopilot has pre-determined minimum Pod resource requests. If your game servers require less than those minimums, use GKE Standard.
  • Scheduling strategy: Packed is supported, which is the Agones default. Distributed is not supported.
  • Host port policy: Dynamic is supported, which is the Agones default. Static and Passthrough are not supported.
  • Seccomp profile: Agones sets the seccomp profile to Unconfined to avoid unexpected container creation delays that might occur because Autopilot enables the RuntimeDefault seccomp profile.
  • Pod disruption policy: eviction.safe: Never is supported, which is the Agones default. eviction.safe: Always is supported. eviction.safe: OnUpgrade is not supported. If your game sessions exceed one hour, refer to Considerations for long sessions.

Creating the firewall

We need a firewall to allow UDP traffic to nodes tagged as game-server via ports 7000-8000. These firewall rules apply to cluster nodes you will create in the next section.

gcloud compute firewall-rules create game-server-firewall \
  --allow udp:7000-8000 \
  --target-tags game-server \
  --description "Firewall to allow game server udp traffic"

Creating the cluster

Create a GKE cluster in which you’ll install Agones. You can use GKE Standard mode or GKE Autopilot mode (Alpha).

Create a Standard mode cluster for Agones

gcloud container clusters create [CLUSTER_NAME] --cluster-version=1.24 \
  --tags=game-server \
  --scopes=gke-default \
  --num-nodes=4 \
  --no-enable-autoupgrade \
  --enable-image-streaming \
  --machine-type=e2-standard-4

Flag explanations:

  • cluster-version: Agones requires a supported Kubernetes version.
  • tags: Defines the tags that will be attached to new nodes in the cluster. This is to grant access through ports via the firewall created in the next step.
  • scopes: Defines the Oauth scopes required by the nodes.
  • num-nodes: The number of nodes to be created in each of the cluster’s zones. Default: 4. Depending on the needs of your game, this parameter should be adjusted.
  • no-enable-autoupgrade: Disable automatic upgrades for nodes to reduce the likelihood of in-use games being disrupted.
  • enable-image-streaming: Use Image streaming to pull container images, which leads to significant improvements in initialization times. Limitations apply to enable this feature.
  • machine-type: The type of machine to use for nodes. Default: e2-standard-4. Depending on the needs of your game, you may wish to have smaller or larger machines.

(Optional) Creating a dedicated node pool

Create a dedicated node pool for the Agones resources to be installed in. If you skip this step, the Agones controllers will share the default node pool with your game servers, which is fine for experimentation but not recommended for a production deployment.

gcloud container node-pools create agones-system \
  --cluster=[CLUSTER_NAME] \
  --no-enable-autoupgrade \
  --node-taints agones.dev/agones-system=true:NoExecute \
  --node-labels agones.dev/agones-system=true \
  --num-nodes=1

where [CLUSTER_NAME] is the name of the cluster you created.

(Optional) Creating a metrics node pool

Create a node pool for Metrics if you want to monitor the Agones system using Prometheus with Grafana or Cloud Logging and Monitoring.

gcloud container node-pools create agones-metrics \
  --cluster=[CLUSTER_NAME] \
  --no-enable-autoupgrade \
  --node-taints agones.dev/agones-metrics=true:NoExecute \
  --node-labels agones.dev/agones-metrics=true \
  --num-nodes=1

Flag explanations:

  • cluster: The name of your existing cluster in which the node pool is created.
  • no-enable-autoupgrade: Disable automatic upgrades for nodes to reduce the likelihood of in-use games being disrupted.
  • node-taints: The Kubernetes taints to automatically apply to nodes in this node pool.
  • node-labels: The Kubernetes labels to automatically apply to nodes in this node pool.
  • num-nodes: The Agones system controllers only require a single node of capacity to run. For faster recovery time in the event of a node failure, you can increase the size to 2.

(Optional) Creating a node pool for Windows

If you run game servers on Windows, you need to create a dedicated node pool for those servers. Windows Server 2019 (WINDOWS_LTSC_CONTAINERD) is the recommended image for Windows game servers.

gcloud container node-pools create windows \
  --cluster=[CLUSTER_NAME] \
  --no-enable-autoupgrade \
  --image-type WINDOWS_LTSC_CONTAINERD \
  --machine-type e2-standard-4 \
  --num-nodes=4

where [CLUSTER_NAME] is the name of the cluster you created.

Create an Autopilot mode cluster for Agones

Agones supports Autopilot clusters in alpha.

  1. Find a release channel that has a supported Kubernetes version for Agones:

    gcloud container get-server-config \
      --region=[COMPUTE_REGION] \
      --flatten="channels" \
      --format="yaml(channels)" \
      --filter="channels.channel~[RELEASE_CHANNEL]"
    

    Replace the following:

    • COMPUTE_REGION: the Google Cloud region for the cluster.
    • RELEASE_CHANNEL: the name of the release channel. Can be RAPID, REGULAR, or STABLE. Omit the --filter flag to view all channels.

    The output shows the default and available versions in the specified channel.

  2. Create the cluster:

    gcloud container clusters create-auto [CLUSTER_NAME] \
      --region=[COMPUTE_REGION] \
      --release-channel=[RELEASE_CHANNEL] \
      --autoprovisioning-network-tags=game-server \
    

    Replace the following:

  • CLUSTER_NAME: the name of your cluster.
  • RELEASE_CHANNEL: one of rapid, regular, or stable. The default is regular. To set a specific available version in the release channel, use the --cluster-version=[VERSION] flag.

Setting up cluster credentials

Finally, let’s tell gcloud that we are speaking with this cluster, and get auth credentials for kubectl to use.

gcloud config set container/cluster [CLUSTER_NAME]
gcloud container clusters get-credentials [CLUSTER_NAME]

Next Steps

GKE Standard

If you created a GKE Standard cluster, continue to Install Agones.

GKE Autopilot

If you created a GKE Autopilot cluster:

  1. Install Helm

  2. Install Agones:

    helm repo add agones https://agones.dev/chart/stable
    helm repo update
    helm install my-release \
      --namespace agones-system \
      --create-namespace agones/agones \
      --set agones.featureGates="SplitControllerAndExtensions=true"
    

    The SplitControllerAndExtensions=true feature gate is in the Alpha stage. You must specify this feature gate to enable Agones on an Autopilot cluster.

To verify the installation, create a GameServer.


Last modified April 4, 2023: Link to Global Scale Demo from Agones Examples page (#3064) (3fd7b72e2)