GameServerAllocation is used to allocate a GameServer from a Fleet, GameServerSet, or any set of GameServers that match specified selectors. The allocation process finds a suitable GameServer, marks it as Allocated, and returns its connection information.
API Version
allocation.agones.dev/v1
Kind
GameServerAllocation
Resource Structure
Spec Fields
Thespec field defines the allocation criteria and actions.
selectors
Ordered list of GameServer label selectors. If the first selector finds no match, the allocation attempts the second selector, and so on. This is useful for fallback scenarios like canary testing.Note: Either use
selectors or the deprecated required/preferred fields, not both.required (Deprecated)
Deprecated: Use
selectors instead.GameServer selector from which to choose GameServers. If selectors is set, this field is ignored.preferred (Deprecated)
Deprecated: Use
selectors instead.Ordered list of preferred GameServer selectors. If selectors is set, this field is ignored.scheduling
Defines how GameServers are organized for selection:
Packed- Aimed at dynamic clusters (cloud), bin packs onto nodes for efficient resource usageDistributed- Aimed at static clusters, distributes across nodes for fault tolerance
priorities
Beta Feature (CountsAndLists flag)Alters the order in which GameServers are searched. Priority sorting is in descending importance (position 0 checked first).
- For
Packed: Priority list is the tie-breaker within least-utilized infrastructure - For
Distributed: Entire selection is sorted by this priority list
metadata
Custom metadata added to the GameServer at allocation time. Useful for passing session-specific data.
counters
Beta Feature (CountsAndLists flag)Counter actions to perform during allocation.
lists
Beta Feature (CountsAndLists flag)List actions to perform during allocation.
multiClusterSetting
Configuration for multi-cluster allocation. If specified, allocation can span multiple clusters.
Status Fields
Thestatus field contains the allocation result.
state
Allocation state. Possible values:
Allocated- Allocation successfulUnAllocated- No suitable GameServer foundContention- Allocation failed due to race condition/contention
gameServerName
Name of the allocated GameServer. Empty if allocation failed.
ports
Array of ports exposed by the allocated GameServer.
address
Primary IP address or hostname to connect to the GameServer.
addresses
All available addresses for the GameServer (internal IP, external IP, hostname).
nodeName
Kubernetes node hosting the allocated GameServer.
source
Source of the allocation:
local- Allocated from local cluster<endpoint>- Allocated from remote cluster (endpoint of remote agones-allocator)
metadata
Metadata from the allocated GameServer at allocation time.
counters
Beta Feature (CountsAndLists flag)Counter values from the allocated GameServer after allocation actions.
lists
Beta Feature (CountsAndLists flag)List values from the allocated GameServer after allocation actions.
Allocation Process
The allocation process follows these steps:- Selector Evaluation: Iterate through
selectorsin order until a match is found - Filtering: Apply all selector criteria (labels, state, counters, lists, players)
- Sorting: Sort matching GameServers by:
- Scheduling strategy (Packed or Distributed)
- Priorities (if specified)
- Default tie-breakers
- Selection: Choose the first GameServer from sorted list
- State Update: Atomically update GameServer to Allocated state
- Metadata Application: Apply labels/annotations from
spec.metadata - Counter/List Actions: Perform counter/list operations
- Response: Return GameServer connection details in status
Contention Handling
If multiple allocations target the same GameServer simultaneously:- Only one succeeds (winner of the race condition)
- Others receive
state: Contention - Client should retry the allocation
Selector Fallback
With multiple selectors:Use Cases
Basic Fleet Allocation
Allocate any Ready GameServer from a Fleet:Canary Deployments
Try new version first, fall back to stable:Session Management
Allocate GameServer with room for specific player count:Re-connection
Find already allocated GameServer for reconnection:Geographic Distribution
Allocate from preferred region with fallback:Notes
GameServerAllocation is a create-only resource. Each allocation creates a new GameServerAllocation object in the cluster that persists as a record of the allocation.
The allocation process is atomic at the GameServer state transition level. However, metadata updates and counter/list actions happen in separate operations.
Multi-cluster allocation requires additional setup with agones-allocator service and AllocationEndpoint/GameServerAllocationPolicy resources. See multi-cluster documentation for details.
