In addition to having some fun playing with K8s, this solution was also quite interesting from the techniques that were used, here is a description from Paolo's own words:
One of the goal of this project was to use just Kubernetes API without any external dependency (neither the storage), in fact is noteworthy that ConfigMaps are (ab)used as a persistent storage layer, using a simple technique of split/merge parts of files to save the games.
After poking around the repository, I found that it was not very intuitive to get started. In fact, it took me some time to figure out everything and lots of trial/error. I eventually got everything working and successfully deployed several DOS games to my Tanzu Kubernetes Grid (TKG) Cluster which I had running in my homelab. Below are the detailed instructions on how to quickly get this solution stood up which just requires a vanilla K8s deployment.
Step 1 - Clone the additronk8s repository:
git clone https://github.com/paolomainardi/additronk8s-retrogames-kubernetes-controller.git
Step 2 - Deploy the retro game controller engine to your K8s cluster by running the following command:
kubectl apply -f k8s/manifests/namespace.yml
kubectl -n games apply -f k8s/manifests/crd-game-controller.yml
kubectl -n games apply -f k8s/manifests/game-controller-sa.yml
kubectl -n games apply -f k8s/manifests/game-controller-cluster-role.yml
kubectl -n games apply -f k8s/manifests/game-controller-cluster-role-binding.yml
kubectl -n games apply -f k8s/manifests/game-controller.yaml
Step 4 - Next, we need to create a game deployment manifest that contains details about the game we plan to deploy. Use a descriptive filename along with updating the name attributes within the file which will show up in your K8s deployment. You will need to specify the zipURL property which should be an HTTP endpoint where your game zip file is hosted along with the dir property which is the name of the directory upon unzipping the file (use "." for no subdirectory) and lastly the exe property which is the name of the DOS executable.
cat > tetris.yaml <<EOF apiVersion: retro.sparkfabrik.com/v1 kind: Game metadata: name: tetris namespace: games spec: name: "Tetris" zipUrl: "http://192.168.30.6/f-tetris.zip" dir: "." exe: "F-TETRIS.EXE" EOF
Step 5 - Now we are ready to deploy our game by running the following command:
kubectl apply -f tetris.yaml
We can verify that the deployment was successful by running the following command and ensuring we see Status=Runningn for our game pod which will be named based on the spec name as shown in the screenshot below:
kubectl -n games get all
kubectl -n games logs deployment/game-controller -f
Step 6 - Before we can start playing our game, we need to setup a port forward by specifying the name of our service. In this case, it is svc/tetris or whatever name you had used in your deployment spec and we will need to forward both port 8080/8081.
kubectl -n games port-forward svc/tetris 8080:8080 8081:8081
Step 7 - Finally, open a web browser to localhost:8080 and you should see the DOSBox console and simply type the name of the DOS executable name to load the game: