Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A retrogames kubernetes controller built in Javascript

License

NotificationsYou must be signed in to change notification settings

paolomainardi/additronk8s-retrogames-kubernetes-controller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

build-controllerbuild-engine

Description

AdditronK8S is a retro game machine build as a Kubernetes custom controller andimplemented in Javascript.

The nameAdditron 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):

AdditronK8S Scheme

See it in action:

asciicast

Here you can find the slides of my talk:https://www2.slideshare.net/sparkfabrik/retro-gaming-machine-made-with-javascript-and-kubernetes

Technology

This project consists of 3 main components:

  1. A Docker image to run games based on Dosbox +noVNC + Pulseaudio/gStreamer
  2. A Javascript Kubernetes custom controller who implements the CRD and the needed logic to run the games.
  3. 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.

Quick start

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 pressALT + s this will start once the needed websocket,to transport the audio from the pulseaudio server to your browser.

Games

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

Development

The development environment is based onk3d andskaffold,by runningmake dev you will have end up with:

  1. A k3d kubernetes cluster
  2. Docker images loaded into the k3d cluster
  3. Game controller up and running with live-reload in case of code changes

References

About

A retrogames kubernetes controller built in Javascript

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors3

  •  
  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp