Skip to content

Octops/agones-broadcaster-http

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

Agones Broadcaster HTTP

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
         }        
      }
   ]
}

Install

The command below will push the install.yaml manifest and deploy the required resources.

# Everything will be deployed in the `default` namespace.
$ make install

Alternatively, you can deploy the service in a difference namespace

$ kubectl create ns NAMESPACE_NAME
$ kubectl -n [NAMESPACE_NAME] apply -f install/install.yaml

Fetch Data

Port-Forward

Use 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/gameservers

In-Cluster

The 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.

External World

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.

Clean up

$ kubectl [-n NAMESPACE_NAME] delete -f install/install.yaml