In this quickstart, you learn how to work with game server realms, clusters, deployments, configs,
and rollouts in Game Servers using the
gcloud command-line tool.
Before you begin
Sign in to your Google Account.
If you don't already have one, sign up for a new account.
In the Cloud Console, on the project selector page, select or create a Cloud project.
Make sure that billing is enabled for your Google Cloud project. Learn how to confirm billing is enabled for your project.
- Ensure that you have enabled the Game Services API. Enable Game Services API
Choosing a shell
To complete this quickstart, you can use either Cloud Shell or your local shell.
Cloud Shell is a shell environment for managing resources hosted
on Google Cloud. Cloud Shell comes preinstalled with the
gcloud command-line tool. The
gcloud tool provides the primary command-line interface for
To launch Cloud Shell, perform the following steps:
Go to Google Cloud Console.
From the upper-right corner of the console, click the Activate Cloud Shell button:
A Cloud Shell session opens inside a frame lower on the console.
You use this shell to run
gcloud, install the Cloud SDK,
which includes the
gcloud command-line tool.
Verify that you have set desired default project for
gcloud command-line tool (otherwise you need to specify flag
--project explicitly for each command later):
gcloud config list project
If not you can run the following command to set a default project, replacing
project-id with your desired project ID :
gcloud config set project project-id
Run the following command to verify your version of the Google Cloud SDK.
Game Servers requires version
306.0.0 or higher of the SDK.
To update your installation, run the following command:
gcloud components update
If you select local shell, then you might need to install
gcloud components install kubectl
Creating a Google Kubernetes Engine cluster
To create a Google Kubernetes Engine cluster:
Enable the Kubernetes Engine API by visiting the Google Kubernetes Engine page in the Google Cloud Console.
Run the following command to create a cost-optimized cluster with one node in the
gcloud container clusters create gcgs-quickstart \ --cluster-version=1.15 \ --tags=game-server \ --scopes=gke-default \ --num-nodes=1 \ --no-enable-autoupgrade \ --machine-type=e2-standard-2 \ --zone=us-central1-a
Run the following command to retrieve the credentials for the GKE cluster you created in the previous step:
gcloud container clusters get-credentials gcgs-quickstart --zone=us-central1-a
Installing Agones on GKE
In this section, you install the open source Agones gaming infrastructure platform. To install Agones:
Run the following command to create the
kubectl create namespace agones-system
Run the following command to install Agones:
kubectl apply -f https://raw.githubusercontent.com/googleforgames/agones/release-1.7.0/install/yaml/install.yaml
You can validate that Agones system is running by checking the status of the Kubernetes pods:
kubectl get --namespace agones-system pods
All the pods are expected to be in a
NAME READY STATUS RESTARTS AGE agones-allocator-6694dcc89-7r75d 1/1 Running 0 28s agones-allocator-6694dcc89-m7ghq 1/1 Running 0 28s agones-allocator-6694dcc89-qp6cm 1/1 Running 0 28s agones-controller-56c98db844-llzzc 1/1 Running 0 22s agones-ping-d9d74c5c6-8kmt6 1/1 Running 0 24s agones-ping-d9d74c5c6-xwn4h 1/1 Running 0 24s
Creating Game Servers resources
To create Game Servers resources:
Create a realm in the same location as the GKE cluster:
gcloud game servers realms create realm-quickstart --time-zone EST --location us-central1
Register your Agones GKE cluster with Game Servers and attach it to the realm you created in the previous step:
gcloud game servers clusters create cluster-quickstart \ --realm=realm-quickstart \ --gke-cluster locations/us-central1-a/clusters/gcgs-quickstart \ --namespace=default \ --location us-central1 \ --no-dry-run
Create a game server deployment, which you use to store all your game server configurations, and then roll them out to your game server clusters:
gcloud game servers deployments create deployment-quickstart
Now that you have a game server deployment, you can add a game server config to it using the
Copy the following example Agones fleet spec manifest to a new file named
fleet_configs.yamlin the current directory:
- name: fleet-spec-1 fleetSpec: replicas: 2 template: metadata: labels: foo: bar spec: ports: - name: default portPolicy: Dynamic containerPort: 7654 template: spec: containers: - name: simple-udp image: gcr.io/agones-images/udp-server:0.17
To create the game server config, run the following command:
gcloud game servers configs create config-1 --deployment deployment-quickstart --fleet-configs-file fleet_configs.yaml
To update the rollout, run the following command:
gcloud game servers deployments update-rollout deployment-quickstart --default-config config-1 --no-dry-run
To validate the rollout of one fleet under default namespace, run the following command:
kubectl get fleet
The following illustrates the expected output:
NAME SCHEDULING DESIRED CURRENT ALLOCATED READY AGE fleet-deployment-quickstart-config-1 Packed 2 2 0 2 4s
The output confirms that you have deployed a fleet with two simple UDP server replicas in your cluster that are ready to accept connections.
Testing connectivity to the UDP server
To test connectivity to the UDP server:
Create a firewall rule to open the UDP ports required to connect to the cluster:
gcloud compute firewall-rules create gcgs-quickstart-firewall \ --allow udp:7000-8000 \ --target-tags game-server \ --description "Firewall to allow game server udp traffic"
Next, get the IP address and port number for an individual game server:
kubectl get gameserver
The command returns output similar to the following:
NAME STATE ADDRESS PORT NODE AGE fleet-deployment-quickstart-config-1-nndvr-5gvch Ready IP_address port_number gke-gcgs-quickstart-default-pool-db3d2ee8-dlg7 11s fleet-deployment-quickstart-config-1-nndvr-vqwpl Ready IP_address port_number gke-gcgs-quickstart-default-pool-db3d2ee8-dlg7 11s
To test connectivity, you run the Netcat command. To install Netcat on Linux, run the following command:
sudo apt install netcat
To start the test, run the following command:
nc -u IP_address port_number
Helloand the command returns output similar to the following:
Hello > ACK: Hello
To avoid incurring charges to your Google Cloud account for the resources used in this quickstart, follow these steps.
If you don't want to keep any of the resources you created in this quickstart, you can delete the project:
- In the Cloud Console, go to the Manage resources page.
- In the project list, select the project that you want to delete and then click Delete delete.
- In the dialog, type the project ID and then click Shut down to delete the project.
Alternatively, if you want to keep the project, complete the following steps to manually delete the resources you created in this quickstart:
To delete the firewall rule, run the following command:
gcloud compute firewall-rules delete gcgs-quickstart-firewall
To clear the default rollout, run the following command:
gcloud game servers deployments update-rollout deployment-quickstart --clear-default-config --no-dry-run
To delete the game server config, run the following command:
gcloud game servers configs delete config-1 --deployment deployment-quickstart
To delete the game server deployment, run the following command:
gcloud game servers deployments delete deployment-quickstart
To delete the game server cluster, run the following command:
gcloud game servers clusters delete cluster-quickstart --realm=realm-quickstart --location=us-central1 --no-dry-run
To delete the realm, run the following command:
gcloud game servers realms delete realm-quickstart --location=us-central1
To disable the Game Services API, run the following command:
gcloud services disable gameservices.googleapis.com
To delete the GKE cluster, run the following command:
gcloud container clusters delete gcgs-quickstart --zone=us-central1-a
For a technical introduction to Game Servers concepts, see the Overview of Game Servers.
Learn about specific Game Servers tasks in the How-to guides.