Giter Club home page Giter Club logo

quake-kube's Introduction

Due to changes in the priorities, this project is currently not being supported. The project is archived as of 11/17/21 and will be available in a read-only state. Please note, since archival, the project is not maintained or reviewed.

Build Status

QuakeKube

QuakeKube is a Kubernetes-ified version of QuakeJS that runs a dedicated Quake 3 server in a Kubernetes Deployment, and then allow clients to connect via QuakeJS in the browser.

Quick start

With an existing K8s cluster

Deploy the example manifest:

$ kubectl apply -f https://raw.githubusercontent.com/criticalstack/quake-kube/master/example.yaml

Without an existing K8s cluster

Start an instance of Kubernetes locally using cinder (or kind):

$ cinder create cluster

Deploy the example manifest:

$ kubectl apply -f example.yaml

Finally, navigate to http://$(cinder get ip):30001 in the browser.

How it works

QuakeKube makes use of ioquake for the Quake 3 dedicated server, and QuakeJS, a port of ioquake to javascript using Emscripten, to provide an in-browser game client.

Networking

The client/server protocol of Quake 3 uses UDP to synchronize game state. Browsers do not natively support sending UDP packets so QuakeJS wraps the client and dedicated server net code in websockets, allowing the browser-based clients to send messages and enable multiplayer for other clients. This ends up preventing the browser client from using any other Quake 3 dedicated server. In order to use other Quake 3 dedicated servers, a proxy handles websocket traffic coming from browser clients and translates that into UDP to the backend. This gives the flexibility of being able to talk to other existing Quake 3 servers, but also allows using ioquake (instead of the javascript translation of it), which uses considerably less CPU and memory.

QuakeKube also uses a cool trick with cmux to multiplex the client and websocket traffic into the same connection. Having all the traffic go through the same address makes routing a client to its backend much easier (since it can just use its document.location.host).

Quake 3 demo EULA

The Quake 3 dedicated server requires an End-User License Agreement be agreed to by the user before distributing the Quake 3 demo files that are used (maps, textures, etc). To ensure that the installer is aware of, and agrees to, this EULA, the flag --agree-eula must be passed to q3 server at runtime. This flag is not set by default in the container image and is therefore required for the dedicated server to pass the prompt for EULA. The example.yaml manifest demonstrates usage of this flag to agree to the EULA.

Configuration

The server and maps are configured via ConfigMap that is mounted to the container:

apiVersion: v1
kind: ConfigMap
metadata:
  name: quake3-server-config
data:
  config.yaml: |
    fragLimit: 25
    timeLimit: 15m
    game:
      motd: "Welcome to Critical Stack"
      type: FreeForAll
      forceRespawn: false
      inactivity: 10m
      quadFactor: 3
      weaponRespawn: 3
    server:
      hostname: "quakekube"
      maxClients: 12
      password: "changeme"
    maps:
    - name: q3dm7
      type: FreeForAll
    - name: q3dm17
      type: FreeForAll
    - name: q3wctf1
      type: CaptureTheFlag
      captureLimit: 8
    - name: q3tourney2
      type: Tournament
    - name: q3wctf3
      type: CaptureTheFlag
      captureLimit: 8
    - name: ztn3tourney1
      type: Tournament

The time limit and frag limit can be specified with each map (it will change it for subsequent maps in the list):

- name: q3dm17
  type: FreeForAll
  fragLimit: 30
  timeLimit: 30

Capture limit for CTF maps can also be configured:

- name: q3wctf3
  type: CaptureTheFlag
  captureLimit: 8

Any commands not captured by the config yaml can be specified in the commands section:

commands:
- seta g_inactivity 600
- seta sv_timeout 120

Add bots

Bots can be added individually to map rotations using the commands section of the config:

commands:
  - addbot crash 1
  - addbot sarge 2

The addbot server command requires the name of the bot and skill level (crash and sarge are a couple of the built-in bots).

Another way to add bots is by setting a minimum number of players to allow the server to add bots up to a certain value (removed when human players join):

bot:
  minPlayers: 8
game:
  singlePlayerSkill: 2

singlePlayerSkill can be used to set the skill level of the automatically added bots (2 is the default skill level).

Setting a password

A password should be set for the server to allow remote administration and is found in the server configuration settings:

server:
  password: "changeme"

This will allow clients to use \rcon changeme <cmd> to remotely administrate the server. To create a password that must be provided by clients to connect:

game:
  password: "letmein"

This will add an additional dialog to the in-browser client to accept the password. It will only appear if the server indicates it needs a password.

Add custom maps

The content server hosts a small upload app to allow uploading pk3 or zip files containing maps. The content server in the example.yaml shares a volume with the game server, effectively "side-loading" the map content, however, in the future the game server will introspect into the maps and make sure that it can fulfill the users map configuration before starting.

Development

The easiest way to develop quake-kube is building the binary locally with make and running it directly. This only requires that you have the ioq3ded binary in your path:

$ bin/q3 server -c config.yaml --assets-dir $HOME/.q3a --agree-eula

Multi-platform images

Container images are being cross-compiled with Docker Buildx so it can run on hardware with different architectures and operating systems. Currently, it is building for linux/amd64 and linux/arm64. While not specifically compiling to the macOS platform (darwin/amd64) QuakeKube should also work on macOS and maybe even Windows. This is due to the fact that they both use a linux VM to provide container support.

Docker Buildx uses QEMU to virtualize non-native platforms, which has unfortunately had long-running issues running the Go compiler:

This issue is circumvented by ensuring that the Go compiler does not run across multiple hardware threads, which is why the affinity is being limited in the Dockerfile.

Credits

  • inolen/quakejs - The really awesome QuakeJS project that makes this possible.
  • ioquake/ioq3 - The community supported version of Quake 3 used by QuakeJS. It is licensed under the GPLv2.
  • begleysm/quakejs - Information in the README.md (very helpful) was used as a guide, as well as, some forked assets of this project (which came from quakejs-web originally) were used.
  • joz3d.net - Useful information about configuration values.

quake-kube's People

Contributors

andrewalexander avatar campbel avatar chrisrx avatar int13h avatar just1689 avatar ktravis avatar ospo-capitalone avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

quake-kube's Issues

Compiling issue - modifying any files in the public folder has no effect when compiling the docker image

Hi,
i have clone your git hub repo
https://github.com/criticalstack/quake-kube.git

and edit the file
quake-kube/public/index.html

adding this lines
args.push.apply(args, ['+set', 'cg_drawfps', '"1"'])
args.push.apply(args, ['+set', 'cg_fov', '"115"'])
after line 142.

but after compiling the docker image, the changes have no effect. Compilation is successful.

In directory
quake-kube/public/
it's file called zz_generated.static.go and inside is (line 217):
"/index.html": &vfsgen۰CompressedFileInfo{ name: "index.html", modTime: time.Time{}, uncompressedSize: 6166, compressedContent: []byte("\x1f\x8b\x08\... ...\x00\x00"),

perhaps the index.html file is not recompressed and converted. How can I solve?

Some game data files may have been corrupted

After deploying example.yaml on my cluster I can see in the pod server logs:

**************************************************
WARNING: baseq3/pak0.pk3 is present but its checksum (2985612116)
is not correct. Please re-copy pak0.pk3 from your
legitimate Q3 CDROM.
**************************************************

Not sure if this a known non-issue or something that needs to be re-copied into the container image.

tls through reverse proxy support ?

Hi All,

Nice work, well done! I got a question on running this through a tls reverse proxy.

So, when I run it through tls, I get this:

Form submission canceled because the form is not connected (index)
ioquake3.js:116 initial sync completed in 0.01 seconds
ioquake3.js:15511 Mixed Content: The page at 'https://quake.domain.com/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://quake.domain.com/info'. This request has been blocked; the content must be served over HTTPS.

did you think about any way of addressing this ? Or maybe there's a flag somewhere... ? :)

Add quakecon

Use kubebuilder to make a quake-kube server controller to create ContentServer and GameServer types.

Access Server Console

When using this with custom maps it seems about 1/3rd of maps the client can't find the map but the server can, which puts the server in an unrecoverable bad state since nobody can join to issue rcon commands. Restarting the deployment causes you to lose the volume, and repeatedly killing just the server container in the pod puts me in an increasingly long CrashLoopBackoff.

It'd be great if I could exec into the server container and just issue the command to change the map that way. Is that possible?

I suppose I could make a persistent volume for the maps as well, but I still think it would be valuable to be able to control the server directly.

Error on Game startup : Method not allowed

This is an amazing project and I was super keen to give it a go.

I was hoping I could get some help here, since I am very new to kubernetes.

Systes:
Windows 10 64-bit machine
Latest updates applied
WSL2 and Docker.

I managed to setup the example stack and it is up and running and the websites are available.

However after the name selection and acceptance for the game startup I get an error message : Method not allowed.

I tried in Windows Firefox & Chrome and Mobile Firefox, getting the following :
image

Did I miss something in the setup ?

I will give a bit more of a hack at this week and potentially answer my own issue, but if you know what it is, it would be really appreciated if you could share.

Thanks again for even doing this to start with, I'm finally starting on my journey to learning kubernetes, thanks to you 😄

running quake-kube on RPI4

Hi, thank you for this project.

I would like to try and build this on a rpi4 cluster using k3s. I am not 100% sure what I need to do to get it running using ARM images.
If possible, can you give me some pointers please on what I would need to do? I am still new to kubernetes. Happy to contribute back if I can get it going.

content-server error invalid character

Hi,

any idea where this error is coming from when the content-server starts ?

Error: invalid character '<' looking for beginning of value
2020/08/05 10:27:44 invalid character '<' looking for beginning of value

Update QuakeJS or replace with other browser client

QuakeJS is used for the browser client of Quake 3, and has not been updated in some time. As detailed in inolen/quakejs#44 the Emscripten tooling would need to be updated to recompile with a modern version of Emscripten. The other alternative would be to integrate a new client into QuakeKube like the client used in planet_quake, however, this is probably also non-trivial and would need a lot of work to adapt to work with QuakeKube (most notably because it relies on SOCKS vs. the websocket proxy used in QuakeKube).

The goal of this would be improve compatibility/performance with browsers (e.g. Firefox doesn't work too well with the older client), and to potentially introduce the ability to use custom games.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.