GithubHelp home page GithubHelp logo

adilusprimus / kubecraft Goto Github PK

View Code? Open in Web Editor NEW

This project forked from stevesloka/kubecraft

1.0 3.0 0.0 27.4 MB

Kubernetes + Minecraft = Kubecraft

License: Apache License 2.0

Go 13.34% Makefile 0.01% Shell 0.06% Lua 80.54% HTML 4.99% CSS 1.01% Batchfile 0.05%

kubecraft's Introduction

Kubecraft

A simple Minecraft Docker client, to visualize and manage Kubernetes pods.

YouTube video

How to run Kubecraft

  1. Install Minecraft: minecraft.net

    The Minecraft client hasn't been modified, just get the official release.

  2. Pull or build Kubecraft image:

    docker pull stevesloka/kubecraft
    

    or

    git clone [email protected]:stevesloka/kubecraft.git
    cd kubecraft && go/src/kubeproxy/make
    docker build -t stevesloka/kubecraft .
    
  3. Run Kubecraft container:

    docker run -t -d -i -p 25565:25565 \
    --name kubecraft \
    -e KUBE_CFG_FILE=/etc/kubeconfig \
    -v ~/.kube/config:/etc/kubeconfig \
    stevesloka/kubecraft
    

    Copying kubeconfig file to enable k8s api server

    The default port for a Minecraft server is 25565, if you prefer a different one: -p <port>:25565

  4. Open Minecraft > Multiplayer > Add Server

    The server address is the IP of Docker host. No need to specify a port if you used the default one.

    If you're using Docker Machine: docker-machine ip <machine_name> or if using the Docker beta just use localhost

  5. Join Server!

    You should see at least one container in your world, which is the one hosting your Kubecraft server.

    You can start, stop and remove containers interacting with levers and buttons. Kubectl commands are also supported directly via Minecraft's chat window, which is displayed by pressing the T key (default) or / key.

A command always starts with a /.

If you open the prompt using the / key, it will be prefilled with a / character, but if you open it with the T key, it will not be prefilled and you will have to type a / yourself before typing your kubectl command.

example: /kubectl scale deployments my-nginx --replicas=2.

How it works

The Minecraft client itself remains unmodified. All operations are done server side.

The Minecraft server we use is http://cuberite.org. A custom Minecraft compatible game server written in C++. github repo

This server accepts plugins, scripts written in Lua. So we did one for Docker. (world/Plugins/Docker)

Unfortunately, there's no nice API to communicate with these plugins. But there's a webadmin, and plugins can be responsible for "webtabs".

Plugin:AddWebTab("Docker",HandleRequest_Docker)

Basically it means the plugin can catch POST requests sent to http://127.0.0.1:8080/webadmin/Docker/Docker.

Kubeproxy

Events from the Kubernetes API are transmitted to the Lua plugin by a small daemon (written in Go). (go/src/kubeproxy)

func MCServerRequest(data url.Values, client *http.Client) {
	req, _ := http.NewRequest("POST", "http://127.0.0.1:8080/webadmin/Docker/Docker", strings.NewReader(data.Encode()))
	req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
	req.SetBasicAuth("admin", "admin")
	client.Do(req)
}

The kubeproxy binary can also be executed with parameters from the Lua plugin, to send requests to the daemon:

function PlayerJoined(Player)
	-- refresh containers
	r = os.execute("goproxy containers")
end

Thanks!

Thanks to the awesome folks who built Dockercraft! Please go check it out as well: https://github.com/docker/dockercraft

If you're interested about Dockercraft's design, discussions happen in that issue. Also, we're using Magicavoxel to do these nice prototypes:

You can find our Magicavoxel patterns in that folder.

To get fresh news, follow their Twitter account: @dockercraft.

kubecraft's People

Contributors

adilusprimus avatar gdevillele avatar jessfraz avatar leonhartx avatar stevesloka avatar thibaultcha avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

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.