Expose Agones GameServers information via HTTP
This project leverages the https://github.com/Octops/agones-event-broadcaster and exposes details about GameServers running within the cluster via an HTTP endpoint.
All the information from the GameServers returned from the Agones Event Broadcaster is kept in memory only. There is no persistent storage available.
Considerations:
- It is not possible to recover information from the GameServers if the service is not up and running
- Every time the service starts it will re-sync the in-memory cache from scratch
- If the state of a GameServer changes due to any circumstances, the broadcaster will update the cached info in nearly realtime
- The service can't be used for updating data
Important
Only information from GameServers in a Scheduled, Ready or Allocated state will be returned.
The service returns json data in a non specific order. An example is shown below.
{
"gameservers":[
{
"name":"simple-udp-agones-1",
"namespace":"default",
"labels":{
"version":"v1"
},
"addr":"172.17.0.2",
"port":7412,
"state":"Ready",
"node_name":"node-us-central1-pool-172-17-0-2",
"players": {
"capacity": 10,
"count": 2
}
},
{
"name":"simple-udp-agones-2",
"namespace":"default",
"labels":{
"version":"v1"
},
"addr":"172.17.0.2",
"port":7080,
"state":"Ready",
"node_name":"node-us-central1-pool-172-17-0-2",
"players": {
"capacity": 10,
"count": 0
}
},
{
"name":"simple-udp-agones-3",
"namespace":"default",
"labels":{
"version":"v1"
},
"addr":"172.17.0.2",
"port":7611,
"state":"Ready",
"node_name":"node-us-central1-pool-172-17-0-2",
"players": {
"capacity": 10,
"count": 9
}
}
]
}The command below will push the install.yaml manifest and deploy the required resources.
# Everything will be deployed in the `default` namespace.
$ make installAlternatively, you can deploy the service in a difference namespace
$ kubectl create ns NAMESPACE_NAME
$ kubectl -n [NAMESPACE_NAME] apply -f install/install.yamlUse Kubernetes port-forward mechanism to access the service's endpoint running withing the cluster from your local environment.
# Terminal session #1
$ kubectl [-n NAMESPACE_NAME] port-forward svc/octops-broadcaster-http 8000
# Terminal session #2
$ curl localhost:8000/api/gameserversThe service's endpoint will be available to other services running within the cluster using the internal DNS name octops-broadcaster-http.default.svc.cluster.local.
The current install manifest does not expose the service to the external world using Load Balancers or the Ingress Controller.
Check the Kubernetes documentation for more details about Connecting Applications with Services.
$ kubectl [-n NAMESPACE_NAME] delete -f install/install.yaml