- Notifications
You must be signed in to change notification settings - Fork24
A retrogames kubernetes controller built in Javascript
License
paolomainardi/additronk8s-retrogames-kubernetes-controller
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
AdditronK8S is a retro game machine build as a Kubernetes custom controller andimplemented in Javascript.
The name
Additron
is a tribute to the great inventor and scientistJosef Kates who invented thefirst digital playing machine to showcase his Additron tube invention.
I did this as a PoCfor a company talk(Video), to demonstrate howpowerful can be theKubernetes APIs when used also to build custom applications.
I chose to useJavascript as it is anofficially supported clientand also because I didn't find any project a bit more complex than a simple hello world, to implement a custom controller.
Personal note: When developing for Kubernetes, you have to deal with tons of REST APIs and complex relationship between them, this is where the GOecosystem shines, you have framework and abstractions used to build Kubernetesitself and you are sure to use top-notch quality code; so if you planto implement something serious with Kubernetes, my advice is to use GO asa first class citizen language of your system.
One of the goal of this project was to use justKubernetes API without any external dependency (neither the storage),infact is noteworthy thatConfigmaps
are (ab)used as a persistent storage layer, using a simple techniqueof split/merge parts of files to save the games.
How it works (hand written schematic):
See it in action:
Here you can find the slides of my talk:https://www2.slideshare.net/sparkfabrik/retro-gaming-machine-made-with-javascript-and-kubernetes
This project consists of 3 main components:
- A Docker image to run games based on Dosbox +noVNC + Pulseaudio/gStreamer
- A Javascript Kubernetes custom controller who implements the CRD and the needed logic to run the games.
- A K3d Kubernetes cluster and Skaffold to manage it.
WARNING: The code is not even close to be production ready, it is just a quick PoC to build a custom controller in Javascript.
You just need a working k8s cluster, with a working external connection.
To install it from the root, run the following commands:
kubectl apply -f k8s/manifests/namespace.ymlkubectl -n games apply -f k8s/manifests/crd-game-controller.ymlkubectl -n games apply -f k8s/manifests/game-controller-sa.ymlkubectl -n games apply -f k8s/manifests/game-controller-cluster-role.ymlkubectl -n games apply -f k8s/manifests/game-controller-cluster-role-binding.ymlkubectl -n games apply -f k8s/manifests/game-controller.yaml
Now you can run a demo game to test if everything is working as expected:
kubectl -n games apply -f k8s/games/quake.yml
You can also tail the logs of the game-controller to ensure that it was successfulin processing the location of your game zip file.
kubectl -n games logs deployment/game-controller -f
Once you have the game up and running, you can access via the web browser by proxyingthe game service, like this:
kubectl -n games port-forward svc/quake 8080:8080 8081:8081
Finally you can access the game console on:https://localhost:8080
At this stage you will be presented with the dosbox command line andthe command to run to execute the game.
IMPORTANT: To start the audio websocket, before to start the game and inside thedosbox cli, you have to press
ALT + s
this will start once the needed websocket,to transport the audio from the pulseaudio server to your browser.
Files can be downloaded from any public http endpoint or from any public GCP cloud storage bucket.
The expect manifest to run a game is this:
apiVersion:retro.sparkfabrik.com/v1kind:Gamemetadata:name:game-namespec:name:"Game name human friendly"zipUrl:"gs://my-gs-bucket/game.zip"dir:"GAME"exe:"GAME.EXE"
Wheredir
represent the directory of the unzipped game andexe
the binary to run.
To be clear, this is a structure we expect:
unzip game.zip> GAME - GAME.EXE - SOUND.MOD - VIDEO.MOD
The development environment is based onk3d
andskaffold
,by runningmake dev
you will have end up with:
- A k3d kubernetes cluster
- Docker images loaded into the k3d cluster
- Game controller up and running with live-reload in case of code changes
- Retro DOS Games on Kubernetes: many thanks toWilliam Lam for this great write-up.
About
A retrogames kubernetes controller built in Javascript
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Contributors3
Uh oh!
There was an error while loading.Please reload this page.