Skip to main content

Service Definition

The AllocationService provides game server allocation capabilities through a gRPC interface.
service AllocationService {
  rpc Allocate(AllocationRequest) returns (AllocationResponse);
}

Allocate

Allocates a game server from the available fleet based on the specified criteria.

Request: AllocationRequest

namespace
string
required
The Kubernetes namespace hosting the target fleet of game servers to be allocated.
multiClusterSetting
MultiClusterSetting
Configuration for multi-cluster allocation. If specified, multi-cluster policies are applied. Otherwise, allocation happens locally within the cluster.
scheduling
SchedulingStrategy
default:"Packed"
The scheduling strategy for selecting nodes. Available strategies:
  • Packed (0): Allocates game servers on the least number of nodes to maximize resource efficiency
  • Distributed (1): Spreads allocations across nodes for load distribution
metadata
MetaPatch
Custom metadata (labels and annotations) to add to the game server at allocation time. Use this to pass session-specific data to the server.
gameServerSelectors
GameServerSelector[]
Ordered list of game server label selectors. The allocator tries each selector in order until a match is found. Useful for smoke testing new game server versions or implementing fallback logic.
priorities
Priority[]
[Stage: Beta] [FeatureFlag: CountsAndLists]Priority configuration for sorting game servers. Priorities are evaluated in descending order of importance (position 0 is checked first).
  • For Packed strategy: Acts as a tie-breaker within least-utilized infrastructure
  • For Distributed strategy: Determines the complete sort order for allocation
counters
map<string, CounterAction>
[Stage: Beta] [FeatureFlag: CountsAndLists]Actions to perform on Counters during allocation.
lists
map<string, ListAction>
[Stage: Beta] [FeatureFlag: CountsAndLists]Actions to perform on Lists during allocation.
requiredGameServerSelector
GameServerSelector
deprecated
Deprecated: Use gameServerSelectors instead. This field is ignored if gameServerSelectors is set.
preferredGameServerSelectors
GameServerSelector[]
deprecated
Deprecated: Use gameServerSelectors instead. This field is ignored if gameServerSelectors is set.
metaPatch
MetaPatch
deprecated
Deprecated: Use metadata instead. This field is ignored if metadata is set.

Response: AllocationResponse

gameServerName
string
The name of the allocated game server resource.
ports
GameServerStatusPort[]
The network ports exposed by the allocated game server.
address
string
The primary IP address at which the game server can be reached.
addresses
GameServerStatusAddress[]
All addresses at which the game server can be reached (copy of Node.Status.addresses).
nodeName
string
The name of the Kubernetes node hosting the game server.
source
string
The source cluster if multi-cluster allocation was used.
metadata
GameServerMetadata
The metadata of the allocated game server.
counters
map<string, CounterStatus>
[Beta, CountsAndLists feature flag]Status of Counters on the allocated game server.
lists
map<string, ListStatus>
[Beta, CountsAndLists feature flag]Status of Lists on the allocated game server.

Supporting Types

MultiClusterSetting

Specifies settings for multi-cluster allocation.
enabled
bool
default:"false"
If set to true, multi-cluster allocation is enabled.
policySelector
LabelSelector
Selects which multi-cluster allocation policies to apply. If not specified, all policies are applied.

MetaPatch

Metadata to patch the game server at allocation time.
labels
map<string, string>
Labels to add or update on the game server.
annotations
map<string, string>
Annotations to add or update on the game server.

Example Usage

import (
    "context"
    pb "agones.dev/agones/pkg/allocation/go"
)

client := pb.NewAllocationServiceClient(conn)

req := &pb.AllocationRequest{
    Namespace: "default",
    GameServerSelectors: []*pb.GameServerSelector{
        {
            MatchLabels: map[string]string{
                "game": "my-game",
                "version": "1.0",
            },
            GameServerState: pb.GameServerSelector_READY,
        },
    },
    Scheduling: pb.AllocationRequest_Packed,
    Metadata: &pb.MetaPatch{
        Labels: map[string]string{
            "session-id": "abc123",
        },
    },
}

resp, err := client.Allocate(context.Background(), req)
if err != nil {
    // Handle error
}

// Connect players to resp.Address and resp.Ports

HTTP Gateway

The Allocate RPC is also available via HTTP/JSON:
POST /gameserverallocation
Content-Type: application/json

{
  "namespace": "default",
  "gameServerSelectors": [
    {
      "matchLabels": {
        "game": "my-game"
      },
      "gameServerState": "READY"
    }
  ],
  "scheduling": "Packed"
}

Build docs developers (and LLMs) love