# agones-dev/agones architecture

> Architecture diagram of the GitHub repository agones-dev/agones, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/agones-dev/agones
- Repository: https://github.com/agones-dev/agones

## Overview

Agones hosts and scales dedicated game servers on Kubernetes through custom resources and controllers. A matchmaker requests a server allocation; Agones selects a GameServer and returns connection information. In parallel, controllers reconcile GameServer and Fleet lifecycles, and FleetAutoscalers adjust capacity. The SDK sidecar exposes game-server lifecycle and status operations to game processes; metrics export operational state. The tree and README establish these capabilities, while sampled controller excerpts show selected reconciliation behavior. Some service wiring is only partially visible, so uncertain links are omitted.

Main entry points: [`pkg/client/clientset/versioned/clientset.go`](https://github.com/agones-dev/agones/blob/main/pkg/client/clientset/versioned/clientset.go) (Kubernetes clients), [`pkg/gameserverallocations/controller.go`](https://github.com/agones-dev/agones/blob/main/pkg/gameserverallocations/controller.go) (Allocation endpoint), [`cmd/controller/main.go`](https://github.com/agones-dev/agones/blob/main/cmd/controller/main.go) (Controller service), [`pkg/apis/agones/v1/gameserver.go`](https://github.com/agones-dev/agones/blob/main/pkg/apis/agones/v1/gameserver.go) (Agones resources)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Kubernetes API"]
  node_crds["Agones resources<br/>[gameserver.go]"]
  node_allocationcrd["Allocation resource"]
  node_kubeclients["Kubernetes clients<br/>[clientset.go]"]
end

subgraph group_lifecycle["Server lifecycle"]
  node_controller["Controller service<br/>[main.go]"]
  node_gameservers["GameServer reconciliation<br/>[controller.go]"]
  node_fleets["Fleet reconciliation<br/>[controller.go]"]
  node_sets["GameServerSet reconciliation<br/>[controller.go]"]
  node_extensions["Admission extensions<br/>[main.go]"]
end

subgraph group_allocation["Allocation"]
  node_allocator["Allocator service<br/>[main.go]"]
  node_allocationapi["Allocation endpoint<br/>[controller.go]"]
  node_selection["Server selection<br/>[allocator.go]"]
  node_processor["Allocation processor<br/>[main.go]"]
end

subgraph group_runtime["Game runtime"]
  node_sdkserver["SDK sidecar server<br/>[sdkserver.go]"]
  node_sdkentry["SDK service entry<br/>[main.go]"]
end

subgraph group_operations["Scaling and metrics"]
  node_autoscaler["Fleet autoscaling<br/>[controller.go]"]
  node_metrics["Metrics controller<br/>[controller.go]"]
  node_exporter["Metrics exporter<br/>[exporter.go]"]
end

node_matchmaker(("Matchmaker"))
node_gameprocess(("Game process"))
node_kube[("Kubernetes")]

node_matchmaker -->|"requests server"| node_allocator
node_allocator -.->|"serves allocation"| node_allocationapi
node_allocationapi -.->|"selects server"| node_selection
node_allocationapi -.->|"delegates allocation"| node_processor
node_selection -.->|"reads and allocates"| node_kube
node_allocationapi -->|"returns allocation"| node_allocationcrd
node_controller -.->|"starts controllers"| node_gameservers
node_controller -.->|"starts controllers"| node_fleets
node_controller -.->|"starts controllers"| node_sets
node_gameservers -->|"updates resources"| node_kubeclients
node_fleets -->|"updates resources"| node_kubeclients
node_sets -.->|"updates resources"| node_kubeclients
node_gameservers -->|"updates status"| node_crds
node_fleets -->|"manages sets"| node_sets
node_extensions -.->|"validates resources"| node_crds
node_sdkentry -->|"registers service"| node_sdkserver
node_gameprocess -->|"uses SDK"| node_sdkserver
node_sdkserver -.->|"updates server state"| node_kubeclients
node_autoscaler -->|"reads fleet state"| node_crds
node_autoscaler -.->|"scales fleet"| node_kubeclients
node_metrics -->|"observes resources"| node_crds
node_metrics -.->|"exports metrics"| node_exporter
node_kube -->|"hosts services"| node_controller

click node_crds "https://github.com/agones-dev/agones/blob/main/pkg/apis/agones/v1/gameserver.go"
click node_allocationcrd "https://github.com/agones-dev/agones/blob/main/pkg/apis/allocation/v1/gameserverallocation.go"
click node_kubeclients "https://github.com/agones-dev/agones/blob/main/pkg/client/clientset/versioned/clientset.go"
click node_controller "https://github.com/agones-dev/agones/blob/main/cmd/controller/main.go"
click node_gameservers "https://github.com/agones-dev/agones/blob/main/pkg/gameservers/controller.go"
click node_fleets "https://github.com/agones-dev/agones/blob/main/pkg/fleets/controller.go"
click node_sets "https://github.com/agones-dev/agones/blob/main/pkg/gameserversets/controller.go"
click node_extensions "https://github.com/agones-dev/agones/blob/main/cmd/extensions/main.go"
click node_allocator "https://github.com/agones-dev/agones/blob/main/cmd/allocator/main.go"
click node_allocationapi "https://github.com/agones-dev/agones/blob/main/pkg/gameserverallocations/controller.go"
click node_selection "https://github.com/agones-dev/agones/blob/main/pkg/gameserverallocations/allocator.go"
click node_processor "https://github.com/agones-dev/agones/blob/main/cmd/processor/main.go"
click node_sdkserver "https://github.com/agones-dev/agones/blob/main/pkg/sdkserver/sdkserver.go"
click node_sdkentry "https://github.com/agones-dev/agones/blob/main/cmd/sdk-server/main.go"
click node_autoscaler "https://github.com/agones-dev/agones/blob/main/pkg/fleetautoscalers/controller.go"
click node_metrics "https://github.com/agones-dev/agones/blob/main/pkg/metrics/controller.go"
click node_exporter "https://github.com/agones-dev/agones/blob/main/pkg/metrics/exporter.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_crds,node_allocationcrd,node_kubeclients toneBlue
class node_controller,node_gameservers,node_fleets,node_sets,node_extensions,node_kube toneAmber
class node_allocator,node_allocationapi,node_selection,node_processor toneMint
class node_sdkserver,node_sdkentry toneRose
class node_autoscaler,node_metrics,node_exporter,node_matchmaker,node_gameprocess toneIndigo
```

## Components

### Kubernetes API

- [Agones resources](https://github.com/agones-dev/agones/blob/main/pkg/apis/agones/v1/gameserver.go): `pkg/apis/agones/v1/gameserver.go`
- [Allocation resource](https://github.com/agones-dev/agones/blob/main/pkg/apis/allocation/v1/gameserverallocation.go): `pkg/apis/allocation/v1/gameserverallocation.go`
- [Kubernetes clients](https://github.com/agones-dev/agones/blob/main/pkg/client/clientset/versioned/clientset.go): `pkg/client/clientset/versioned/clientset.go`

### Server lifecycle

- [Controller service](https://github.com/agones-dev/agones/blob/main/cmd/controller/main.go): `cmd/controller/main.go`
- [GameServer reconciliation](https://github.com/agones-dev/agones/blob/main/pkg/gameservers/controller.go): `pkg/gameservers/controller.go`
- [Fleet reconciliation](https://github.com/agones-dev/agones/blob/main/pkg/fleets/controller.go): `pkg/fleets/controller.go`
- [GameServerSet reconciliation](https://github.com/agones-dev/agones/blob/main/pkg/gameserversets/controller.go): `pkg/gameserversets/controller.go`
- [Admission extensions](https://github.com/agones-dev/agones/blob/main/cmd/extensions/main.go): `cmd/extensions/main.go`

### Allocation

- [Allocator service](https://github.com/agones-dev/agones/blob/main/cmd/allocator/main.go): `cmd/allocator/main.go`
- [Allocation endpoint](https://github.com/agones-dev/agones/blob/main/pkg/gameserverallocations/controller.go): `pkg/gameserverallocations/controller.go`
- [Server selection](https://github.com/agones-dev/agones/blob/main/pkg/gameserverallocations/allocator.go): `pkg/gameserverallocations/allocator.go`
- [Allocation processor](https://github.com/agones-dev/agones/blob/main/cmd/processor/main.go): `cmd/processor/main.go`

### Game runtime

- [SDK sidecar server](https://github.com/agones-dev/agones/blob/main/pkg/sdkserver/sdkserver.go): `pkg/sdkserver/sdkserver.go`
- [SDK service entry](https://github.com/agones-dev/agones/blob/main/cmd/sdk-server/main.go): `cmd/sdk-server/main.go`

### Scaling and metrics

- [Fleet autoscaling](https://github.com/agones-dev/agones/blob/main/pkg/fleetautoscalers/controller.go): `pkg/fleetautoscalers/controller.go`
- [Metrics controller](https://github.com/agones-dev/agones/blob/main/pkg/metrics/controller.go): `pkg/metrics/controller.go`
- [Metrics exporter](https://github.com/agones-dev/agones/blob/main/pkg/metrics/exporter.go): `pkg/metrics/exporter.go`

### Other components

- **Matchmaker**
- **Game process**
- **Kubernetes**

## Connections

- Matchmaker → Allocator service: requests server (evidence: `README.md`)
- Allocator service → Allocation endpoint: serves allocation
- Allocation endpoint → Server selection: selects server
- Allocation endpoint → Allocation processor: delegates allocation
- Server selection → Kubernetes: reads and allocates
- Allocation endpoint → Allocation resource: returns allocation (evidence: `pkg/gameserverallocations/controller.go`)
- Controller service → GameServer reconciliation: starts controllers
- Controller service → Fleet reconciliation: starts controllers
- Controller service → GameServerSet reconciliation: starts controllers
- GameServer reconciliation → Kubernetes clients: updates resources (evidence: `pkg/gameservers/controller.go`)
- Fleet reconciliation → Kubernetes clients: updates resources (evidence: `pkg/fleets/controller.go`)
- GameServerSet reconciliation → Kubernetes clients: updates resources
- GameServer reconciliation → Agones resources: updates status (evidence: `pkg/gameservers/controller.go`)
- Fleet reconciliation → GameServerSet reconciliation: manages sets (evidence: `pkg/fleets/controller.go`)
- Admission extensions → Agones resources: validates resources
- SDK service entry → SDK sidecar server: registers service (evidence: `cmd/sdk-server/main.go`)
- Game process → SDK sidecar server: uses SDK (evidence: `README.md`)
- SDK sidecar server → Kubernetes clients: updates server state
- Fleet autoscaling → Agones resources: reads fleet state (evidence: `pkg/fleetautoscalers/controller.go`)
- Fleet autoscaling → Kubernetes clients: scales fleet
- Metrics controller → Agones resources: observes resources (evidence: `pkg/metrics/controller.go`)
- Metrics controller → Metrics exporter: exports metrics
- Kubernetes → Controller service: hosts services (evidence: `README.md`)
