Platform and reliability
On-demand game servers on Kubernetes at Stratus Network
At Stratus I led part-time developers, planned an infrastructure rewrite, and built a worker that starts private game servers on Kubernetes on request.
The problem
Stratus ran on a big legacy codebase with little to no documentation, maintained by part-time developers spread across time zones. Players also wanted private servers they could request for their own matches, and there was no way to give them one without staff starting it by hand.
What I did
- Led a group of part-time developers across several time zones
- Led the planning and first steps of a complete infrastructure rewrite
- Built server requests: a worker in the Rails backend that hands a player a private server, claiming a spare one or creating a new one, and starts its pod and service through the Kubernetes API
- Kept the fleet tidy: idle private servers restart after ten minutes empty, offline ones are torn down, and one spare is always kept ready
- On the website, a UHC event calendar, the play page, flag captures on profiles, tournament map classifications and a legacy ban check
- On the cluster side, a custom default backend, a public API, event and tournament manifests, and letting an environment force tournament mode
- A UHC leaderboard API in the network’s Java game plugin, PGM
- Playerasks for a server
- Workerfinds or claims a spare
- KubernetesService and Pod created
- Replyproxy name and status
- Every minuterestart idle, keep a spare
How a request is handled
on UseServerRequest(user, name):
server = Server.find_by(name)
?? (Server.free_for_requests.first ?? create_server()).claim(user, name)
if not pod_running_or_pending(server):
k8s.create(headless_service(server))
k8s.create(pod(server, image = "minecraft:bukkit-master",
readiness = "run.rb ready?", liveness = "run.rb alive?"))
reply(UseServerResponse(server.bungee_name, now = server.online?))
every 1 minute:
for s in owned_servers:
if s.online? and s.empty_for > 10 minutes: queue_restart(s)
if Server.free_for_requests.empty?: create_server()
on ModelUpdate(server) where server.owned? and not server.online?:
k8s.delete(pod(server)); k8s.delete(service(server))