Google Kubernetes Engine
Before you begin
Take the following steps to enable the Kubernetes Engine API:
- Visit the Kubernetes Engine page in the Google Cloud Platform Console.
- Create or select a project.
- Wait for the API and related services to be enabled. This can take several minutes.
- 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.
To launch Cloud Shell, perform the following steps:
- Go to Google Cloud Platform Console
- From the top-right corner of the console, click the Activate Google Cloud Shell button:
- A Cloud Shell session opens inside a frame at the bottom of the console. Use this shell to run
- Set a compute zone in your geographical region with the following command. The compute zone will be something like
us-west1-a. A full list can be found here.
gcloud config set compute/zone [COMPUTE_ZONE]
kubectl, perform the following steps:
- Install the Google Cloud SDK, which includes the
- 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
Yand choose a zone in your geographical region of choice.
- When asked
- Install the
kubectlcommand-line tool by running the following command:
gcloud components install kubectl
Creating the cluster
A cluster consists of at least one control plane machine and multiple worker machines called nodes: Compute Engine virtual machine instances that run the Kubernetes processes necessary to make them part of the cluster.
gcloud container clusters create [CLUSTER_NAME] --cluster-version=1.18 \ --tags=game-server \ --scopes=gke-default \ --num-nodes=4 \ --no-enable-autoupgrade \ --machine-type=e2-standard-4
NoteIf you’re creating a cluster to run Windows game servers you’ll also need to add
Optional: Create a dedicated node pool for the Agones controllers. If you choose to skip this step, the Agones controllers will share the default node pool with your game servers which is fine for kicking the tires but is 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
Optional: Create a node pool for Metrics if you want to monitor the Agones system using Prometheus with Grafana or Stackdriver.
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
- cluster: The name of the 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.
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]
Creating the firewall
We need a firewall to allow UDP traffic to nodes tagged as
game-server via ports 7000-8000.
gcloud compute firewall-rules create game-server-firewall \ --allow udp:7000-8000 \ --target-tags game-server \ --description "Firewall to allow game server udp traffic"
Before planning your production GKE infrastructure, it is worth reviewing the different types of GKE clusters that can be created, such as Zonal or Regional, as each has different reliability and cost values, and ensuring this aligns with your Service Level Objectives or Agreements.
- Continue to Install Agones.
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.