Overview
Metadata methods allow game servers to dynamically update their Kubernetes labels and annotations at runtime. This enables dynamic tagging for matchmaking, monitoring, and operational purposes. These methods are part of the stable SDK service (agones.dev.sdk.SDK).
Use Cases
Dynamic Game Mode Tags
Update labels to reflect the current game mode, allowing matchmakers to filter servers by active mode:game-mode=deathmatchmap=desert_stormdifficulty=hard
Match State Tracking
Tag servers with match progress information:match-id=abc123round=3match-state=in-progress
Performance Metrics
Store performance annotations for monitoring:last-tick-time=16.7msplayer-count=32cpu-usage=high
Version and Build Tags
Dynamically mark server versions for gradual rollouts:version=1.2.3build=2024-03-10canary=true
SetLabel
Applies a label to the game server’s metadata. Labels are key-value pairs used for selection and filtering.Behavior
- Creates a new label if the key doesn’t exist
- Updates the value if the key already exists
- Labels are immediately visible to the Kubernetes API
- Labels can be used by selectors in the Allocation API
Label keys and values must follow Kubernetes label requirements:
- Keys: max 63 characters (prefix optional, max 253 chars)
- Values: max 63 characters
- Valid characters: alphanumeric,
-,_,. - Must start/end with alphanumeric character
Request
The label key. Must be a valid Kubernetes label key.
The label value. Must be a valid Kubernetes label value.
Response
Returns empty on success.
Example Usage
SetAnnotation
Applies an annotation to the game server’s metadata. Annotations are key-value pairs used for storing arbitrary metadata.Behavior
- Creates a new annotation if the key doesn’t exist
- Updates the value if the key already exists
- Annotations are immediately visible to the Kubernetes API
- Unlike labels, annotations are not used for selection
- Annotations can store larger values and more complex data
Annotation keys follow the same rules as labels, but values can be:
- Larger than labels (no hard limit, but keep under 256KB total)
- Contain arbitrary string data
- Include structured data like JSON
Request
The annotation key. Must be a valid Kubernetes annotation key.
The annotation value. Can contain arbitrary string data.
Response
Returns empty on success.
Example Usage
Health
Sends health pings to signal that the game server is healthy. This is a streaming RPC where the client sendsEmpty messages at regular intervals.
Behavior
- Opens a client-streaming connection
- Client sends
Emptymessages periodically - If health pings stop for longer than the failure threshold, the game server is marked as unhealthy
- Unhealthy servers are terminated and replaced by Agones
Health checking is enabled by default. Configure health check parameters in the GameServer spec:
health.periodSeconds: How often to expect pings (default: 5)health.failureThreshold: Failed checks before unhealthy (default: 3)health.initialDelaySeconds: Delay before first check (default: 5)
When to Use
Always implement health checking unless:- You have external health monitoring
- Your game server has a very short lifecycle
- You’re explicitly disabling health checks in the spec
Request
Stream of empty messages sent periodically to indicate health.
Response
Returns empty when the stream closes.
Example Usage
Supporting Types
KeyValue
Represents a key-value pair for labels and annotations.Duration
Represents a time duration in seconds (used by Reserve in lifecycle methods).Empty
An empty message used for RPCs that don’t require parameters or return values.HTTP Gateway
Metadata methods are available via HTTP/JSON:Best Practices
Label vs Annotation Guidelines
Use labels for:- Values used in selectors (game mode, version, region)
- Short, simple key-value pairs
- Data that changes infrequently
- Metadata used by the Allocation API
- Structured data (JSON, timestamps)
- Longer strings
- Data not used for selection
- Monitoring and debugging information
