Kubecraftadmin Save

Project README


KubeCraftAdmin : The Adventurer's Admin Tool

Would you kill this innocent looking service?

This project allows you to do basic Kubernetes administration through Minecraft.


Read this if you're just interested in trying out KubeCraftAdmin yourself. You will need the following to get started:

  • A k8s cluster that you own and are allowed to break
  • A place to run the kubecraftcontainer, this can be anywhere inside or outside of the cluster. As long as it has network connectivity to the cluster and to your Minecraft client.
  • Minecraft Bedrock Edition

How to run KubeCraftAdmin:

  1. Run the container erjadi/kubecraftadmin passing the external port and the location of your .kube directory. The container internally listens to port 8000 and in my case my .kube directory resides in /home/erjadi/.kube. You can optionally specify one to four namespaces from your cluster using the environment variable namespaces
 docker run -p 8000:8000 -v /home/erjadi/.kube:/.kube [-e namespaces=mynamespace1,mynamespace2] erjadi/kubecraftadmin
  1. Start up Minecraft Bedrock Edition
  2. Create a new world with the Activate Cheats option turned on Activate Cheats
  3. Once you've spawned log into the server with the following command after which you should be greeted by the KubeCraftAdmin splash screen. You should also be given some items to start with (a sword, TNT and some flint).
  1. Next find a nice area to spawn your kubecraft pen. Type init to generate the structure.
  2. Lastly step on the beacon to activate the link with your cluster.
  3. At this point your pens should be populated with animals!

Running KUbecraftadmin on OpenShift

  • oc new-project kubecraft
  • oc adm policy add-cluster-role-to-user cluster-admin system:serviceaccount:kubecraft:default
  • oc create -f deploy.yaml
  • Get the route
  • Load minecraft and use /connect <route-url>/ws

Technical Details


KubeCraftAdmin is written in Golang. It builds upon the great MCWSS project by Sandertv.

This project makes use of the Websocket Server functionality present in Minecraft Bedrock and Education Edition. The WS connection is a Minecraft client connection, which means that all actions are performed through the client. The server / local world is unaffected and not controlled by this project. This also implies we need to activate cheats in the world to be able to summon or kill entities.

The below description explains the main process which you can find in kubecraftadmin.go.
Highly simplified, KubeCraftAdmin connects to the Kubernetes cluster, spawns the required entities and starts an endless loop function LoopReconcile. Every second it starts a sync function called ReconcileKubetoMC which basically:

  • Enumerates entities in Minecraft
  • Enumerates resources in Kubernetes
  • Kills / Spawns the differences in Minecraft

For the reverse sync we rely on a mobEvent which triggers execution of ReconcileMCtoKubeMob. We basically perform the same check, but this time we take the Minecraft entities as the truth and delete the corresponding Kubernetes resources.

Known Issues / TODO

  • There are some hacks to make the sync stable. Some operations take time on the kubernetes cluster (e.g. you kill a service in Minecraft). For the duration of the deletion process, Minecraft and Kubernetes will be out of sync (chicken is dead, service is still there). This could lead to syncing issues where KubeCraftAdmin tries to spawn chickens. Right now this is 'fixed' by keeping a list of uniqueIDs and never spawning the same entity twice. This has its own issues. A slight improvement would be to have a TTL on the uniqueIDs, but the best solution would be to keep track of the state as "being synced to MC" or "being synced to K8s".
  • Hardcoded to 4 namespaces (more than 4 will crash)
  • Logging is bad / non-configurable
  • No error handling

How to compile

The easiest way to compile your own version is to use the provided Dockerfile. This way you can build it without requiring a local golang build environment.

docker build -t kubecraftadmin .
Open Source Agenda is not affiliated with "Kubecraftadmin" Project. README Source: erjadi/kubecraftadmin
Open Issues
Last Commit
8 months ago

Open Source Agenda Badge

Open Source Agenda Rating