Skip to main content
A GameServer is the fundamental building block of Agones. It represents a single dedicated game server instance and manages its lifecycle from creation through allocation to shutdown.

API Version

agones.dev/v1

Kind

GameServer

Resource Structure

apiVersion: agones.dev/v1
kind: GameServer
metadata:
  name: gds-example
spec:
  container: simple-game-server
  ports:
    - name: default
      portPolicy: Dynamic
      containerPort: 7654
      protocol: UDP
  health:
    disabled: false
    initialDelaySeconds: 5
    periodSeconds: 5
    failureThreshold: 3
  sdkServer:
    logLevel: Info
    grpcPort: 9357
    httpPort: 9358
  counters:
    rooms:
      count: 1
      capacity: 100
  lists:
    players:
      capacity: 10
  template:
    metadata:
      labels:
        myspeciallabel: myspecialvalue
    spec:
      containers:
        - name: simple-game-server
          image: us-docker.pkg.dev/agones-images/examples/simple-game-server:0.41

Spec Fields

The spec field defines the desired configuration for the GameServer.

container

spec.container
string
Specifies which Pod container is the game server. Only required if there is more than one container defined in the pod template.Example: "simple-game-server"

ports

spec.ports
array
Array of ports that can be exposed via the game server. Each port configuration includes:

health

spec.health
object
Configures health checking for the running game server.

scheduling

spec.scheduling
string
default:"Packed"
Scheduling strategy for the GameServer pod. Options:
  • Packed - Aimed at dynamic Kubernetes clusters (cloud providers), bin packs resources onto nodes
  • Distributed - Aimed at static Kubernetes clusters, distributes resources across the entire cluster

sdkServer

spec.sdkServer
object
Parameters for the Agones SDK Server sidecar container.

template

spec.template
object
required
Pod template that will be created for the GameServer. This is a standard Kubernetes PodTemplateSpec.

players

spec.players
object
Alpha Feature (PlayerTracking flag)Configuration for player tracking features.

counters

spec.counters
map[string]CounterStatus
Beta Feature (CountsAndLists flag)Configuration for tracking int64 counter values. Keys must be declared at GameServer creation time and cannot be added later.

lists

spec.lists
map[string]ListStatus
Beta Feature (CountsAndLists flag)Configuration for tracking lists of values (up to 1000 values per list). Keys must be declared at GameServer creation time and cannot be added later.

eviction

spec.eviction
object
Specifies the eviction tolerance of the GameServer.

Status Fields

The status field reflects the current state of the GameServer.

state

status.state
string
Current state of the GameServer. Possible values:
  • PortAllocation - Dynamically allocating GameServer is being created, port needs allocation
  • Creating - Before the Pod is being created
  • Starting - Pod is being created but not yet scheduled
  • Scheduled - Pod has been scheduled (has a NodeName)
  • RequestReady - GameServer has declared it is ready
  • Ready - GameServer is ready to accept connections from game clients
  • Reserved - GameServer is reserved and can be allocated but not removed
  • Allocated - GameServer has been allocated to a session
  • Shutdown - GameServer has shutdown, everything needs deletion
  • Error - Something went wrong, cannot be resolved
  • Unhealthy - GameServer has failed health checks

ports

status.ports
array
Array of ports with their allocated host ports.

address

status.address
string
Primary address at which the GameServer can be reached.

addresses

status.addresses
array
Array of addresses at which the GameServer can be reached. Copy of Node.Status.addresses.

nodeName

status.nodeName
string
Name of the Kubernetes node hosting this GameServer.

reservedUntil

status.reservedUntil
timestamp
Timestamp until which the GameServer is reserved. Only set when state is Reserved.

players

status.players
object
Alpha Feature (PlayerTracking flag)Current player tracking status.

counters

status.counters
map[string]CounterStatus
Beta Feature (CountsAndLists flag)Current counter values and capacities.

lists

status.lists
map[string]ListStatus
Beta Feature (CountsAndLists flag)Current list values and capacities.

eviction

status.eviction
object
Current eviction configuration (may differ from spec if pod annotations override it).

Lifecycle

The GameServer follows this lifecycle:
  1. PortAllocation/Creating - Initial creation
  2. Starting - Pod is being created
  3. Scheduled - Pod is scheduled to a node
  4. RequestReady - Game server signals readiness via SDK
  5. Ready - Available for allocation
  6. Reserved (optional) - Temporarily reserved
  7. Allocated - Assigned to a game session
  8. Shutdown - Terminating
Terminal states (no recovery):
  • Shutdown
  • Error
  • Unhealthy

Notes

Unlike Fleet and other Agones resources, GameServer does not define status as a subresource. This allows changing multiple aspects of a GameServer in a single atomic operation, which is particularly useful for allocation.
Counter capacity should not be set to max(int64) as this may lead to issues. See GitHub issue #3636 for details.
Keys for counters and lists must be declared at GameServer creation time and cannot be dynamically added later.

Build docs developers (and LLMs) love