Creating a config

Stay organized with collections Save and categorize content based on your preferences.

This page explains how to register, edit, list, and view details of a Game Servers config in a deployment. This config defines the Agones fleet specification, which includes information on game server count, buffer, and game server version. This config also defines the scaling configuration, which specifies how the fleet is automatically scaled up and down to meet demand.

Before you begin

Before you start, we recommend you familiarize yourself with key concepts in the Game Servers Overview. Make sure you have also performed the following tasks:

  • Ensure that you have enabled the Game Services API.
  • Enable Game Services API
  • Either choose a shell with gcloud CLI installed, or use an API client:
  • Cloud Shell

    To launch Cloud Shell, perform the following steps:

    1. Go to Google Cloud console.

      Google Cloud console

    2. 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 commands.

    Local shell

    Install the gcloud CLI.

    Verify that you have set desired default project for Google Cloud CLI (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 CLI. Game Servers requires version 306.0.0 or higher of the gcloud CLI.

    gcloud version
    

    To update your installation, run the following command:

    gcloud components update
    

    curl / PowerShell

    To use the REST API with curl or Windows PowerShell, do the following:

    1. Create a service account.
    2. Download a private key as a JSON file.
    3. Set the environment variable GOOGLE_APPLICATION_CREDENTIALS to the path of the JSON file that contains your service account key. This variable only applies to your current shell session, so if you open a new session, set the variable again.

    Client Library

    Google Cloud Game Servers can be controlled programmatically using a client library. See Client Libraries Overview for instructions on using the library and authenticating.

Creating a config

Make sure you have created a Game Servers deployment.

Console

  1. In the Google Cloud console, go to the Game Server Deployments page.

    Go to Game Servers

  2. Find a deployment in the table. In the last table column, click the ellipses and select List configs. You can view the active and inactive configs for the deployment from this page.

  3. To create a new config for the deployment, click Create Config.

  4. In the Config name box, enter a unique identifier for this config.

  5. (Optional) In the Description box, enter a description for this config.

  6. In the Fleet config name box, enter a unique identifier for this fleet config.

  7. In the Fleet spec box, enter the fleet specification.

  8. (Optional) Under Scaling config, you can specify one or more configs that automatically scale the fleet up or down. Click Add to add a scaling config.

    1. In the Scaling Config Name box, enter a unique identifier for this scaling config.
    2. (Optional) In the Start Time and End Time boxes, schedule the time period for when this scaling config will be active. See Creating scaling schedules for more information.
    3. In the Autoscaper spec box, enter the scaling specification.

gcloud

You can create a Game Servers config in a deployment using the Google Cloud CLI.

To create a game server config:

  1. Copy this fleet specification into a file.

    - name: fleet-spec-1
      fleetSpec:
       replicas: 10
       scheduling: Packed
       strategy:
         type: RollingUpdate
         rollingUpdate:
           maxSurge: 25%
           maxUnavailable: 25%
       template:
         metadata:
           labels:
             gameName: udp-server
         spec:
           ports:
           - name: default
             portPolicy: Dynamic
             containerPort: 7654
             protocol: UDP
           health:
             initialDelaySeconds: 30
             periodSeconds: 60
           sdkServer:
             logLevel: Info
             grpcPort: 9357
             httpPort: 9358
           template:
             spec:
               containers:
               - name: dedicated
                 image: gcr.io/agones-images/udp-server:0.21
                 imagePullPolicy: Always
                 resources:
                   requests:
                     memory: 200Mi
                     cpu: 500m
                   limits:
                     memory: 200Mi
                     cpu: 500m
    
  2. Run the following command and replace the placeholder values, such as deploymentID and configID, with appropriate values:

    gcloud game servers configs create configID --deployment deploymentID --fleet-configs-file fleetSpecFile
    

    The variable placeholders correspond to the following descriptions:

  • configID is a unique identifier that you can specify for this config.
  • deploymentID is the unique identifier for the deployment.
  • fleetSpecFile is the path to the file with the Agones Fleet specification.

REST & CMD LINE

Before using any of the request data, make the following replacements:

  • PROJECT_ID: your Google Cloud project ID listed in the IAM Settings
  • DEPLOYMENT_ID: the user-defined identifier for the deployment
  • CONFIG_ID: a user-defined identifier for the config

Request JSON body:

{
  "fleetConfigs": [
    {
      "name": "fleet-spec-1",
      "fleetSpec": "{
        \"replicas\": 10,
        \"scheduling\": \"Packed\",
        \"template\": {
          \"metadata\": {
            \"labels\": {
              \"gameName\": \"udp-server\"
            }
          },
          \"spec\": {
            \"ports\": [
              {
                \"name\": \"default\",
                \"portPolicy\": \"Dynamic\",
                \"containerPort\": 7654,
                \"protocol\": \"UDP\"
              }
            ],
            \"health\": {
              \"periodSeconds\": 60,
              \"initialDelaySeconds\": 30
            },
            \"sdkServer\": {
              \"logLevel\": \"Info\",
              \"grpcPort\": 9357,
              \"httpPort\": 9358
            },
            \"template\": {
              \"spec\": {
                \"containers\": [
                  {
                    \"name\": \"dedicated\",
                    \"image\": \"gcr.io/agones-images/udp-server:0.21\",
                    \"imagePullPolicy\": \"Always\",
                    \"resources\": {
                      \"requests\": {
                        \"memory\": \"200Mi\",
                        \"cpu\": \"500m\"
                      },
                      \"limits\": {
                        \"memory\": \"200Mi\",
                        \"cpu\": \"500m\"
                      }
                    }
                  }
                ]
              }
            }
          }
        }
      }"
    }
  ]
}

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

{
  "name": "projects/PROJECT_ID/locations/global/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.gaming.v1.OperationMetadata",
    "createTime": CREATE_TIME,
    "target": "projects/PROJECT_ID/locations/global/gameServerDeployments/DEPLOYMENT_ID/configs/CONFIG_ID",
    "verb": "create",
    "requestedCancellation": false,
    "apiVersion": "v1"
  },
  "done": false
}

Editing configs

You can't edit a Game Servers config because configs are immutable. If you want to edit a config, copy the config (view config details), edit it locally, and use the updated version to create a new config.

Listing configs

Console

  1. In the Google Cloud console, go to the Game Server Deployments page.

    Go to Game Servers

  2. Find a deployment in the table. In the last table column, click the ellipses and select List configs. You can view the active and inactive configs for the deployment from this page.

gcloud

You can list configs using the Google Cloud CLI.

To list all configs, run the following command:

gcloud game servers configs list

To list all configs in a deployment, run the following command and replace deploymentID with the parent deployment that you want to list the configs in:

gcloud game servers configs list --deployment=deploymentID

REST & CMD LINE

Before using any of the request data, make the following replacements:

  • PROJECT_ID: your Google Cloud project ID listed in the IAM Settings
  • DEPLOYMENT_ID: the user-defined identifier for the deployment

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

{
  "gameServerConfigs": [
    {
      "name": "projects/PROJECT_ID/locations/global/gameServerDeployments/DEPLOYMENT_ID/configs/MY-CONFIG-1",
      "createTime": CREATE_TIME,
      "updateTime": UPDATE_TIME,
      "fleetConfigs": [
        {
          "fleetSpec": ...
          "name": "MY-CONFIG-1"
        }
      ],
      "description": "Config 1"
    },
    {
      "name": "projects/PROJECT_ID/locations/global/gameServerDeployments/DEPLOYMENT_ID/configs/MY-CONFIG-2",
      "createTime": CREATE_TIME,
      "updateTime": UPDATE_TIME,
      "fleetConfigs": [
        {
          "fleetSpec": ...
          "name": "MY-CONFIG-2"
        }
      ],
      "description": "Config 2"
    },
  ]
}

Viewing details about a config

Console

  1. In the Google Cloud console, go to the Game Server Deployments page.

    Go to Game Servers

  2. Find a deployment in the table. In the last table column, click the ellipses and select List configs. You can view the active and inactive configs for the deployment from this page.

  3. Find a config in the table. In the last table column, click the ellipses and select View config.

gcloud

You can find details about a config, such as the creation time, using the Google Cloud CLI:

To view the details of a config, run the following command and replace the placeholder values, such as deploymentID and configID, with appropriate values:

gcloud game servers configs describe configID --deployment deploymentID

The output gives you the details of the config.

The variable placeholders correspond to the following descriptions:

  • configID is the unique identifier that you specified for this game server config.
  • deploymentID is a unique identifier for the parent deployment.

REST & CMD LINE

Before using any of the request data, make the following replacements:

  • PROJECT_ID: your Google Cloud project ID listed in the IAM Settings
  • DEPLOYMENT_ID: the user-defined identifier for the deployment
  • CONFIG_ID: the user-defined identifier for the config

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

{
  "name": "projects/PROJECT_ID/locations/global/gameServerDeployments/DEPLOYMENT_ID/configs/CONFIG_ID",
  "createTime": CREATE_TIME,
  "updateTime": UPDATE_TIME,
  "fleetConfigs": [
    {
      "fleetSpec": ...
      "name": "CONFIG_ID"
    }
  ],
  "description": "My config"
}

What's next