Getting started

Your first server

Create a Minecraft server, connect to it and run a command, in a few minutes.

This guide assumes Kobblestone is installed. All commands use a namespace called minecraft:

Terminal window
kubectl create namespace minecraft

Create the server

Save this as server.yaml:

apiVersion: kobblestone.io/v1alpha1
kind: Server
metadata:
name: my-server
namespace: minecraft
spec:
eula: true
type: Paper
version: "26.2"
storage:
size: 2Gi
resources:
limits:
memory: 2Gi
  • eula: true accepts the Minecraft EULA. The server does not start without it.
  • type and version pick the server software and game version. version: LATEST always uses the latest release.
  • storage gives the server a volume for its world and configuration.
  • The memory limit also sizes the Java heap: by default, 75% of it.

Apply it and wait until the server is up:

Terminal window
kubectl apply -f server.yaml
kubectl -n minecraft wait --for=condition=Running=True server/my-server --timeout=5m

The first start downloads the server software and generates the world, so it can take a few minutes. Follow along with:

Terminal window
kubectl -n minecraft get server my-server
kubectl -n minecraft logs my-server-0 -c server -f

Connect to it

The server is only reachable inside the cluster for now. For a quick test, forward its port to your machine:

Terminal window
kubectl -n minecraft port-forward svc/my-server 25565:25565

Then add localhost as a server in Minecraft and join. To make the server reachable for other players, see exposing servers.

Run a command

Commands are resources too. Save this as command.yaml and apply it:

apiVersion: kobblestone.io/v1alpha1
kind: Command
metadata:
name: hello
namespace: minecraft
spec:
targetRef:
name: my-server
command: say Hello from Kubernetes!

The server’s answer ends up in the resource’s status:

Terminal window
kubectl -n minecraft get command hello -o jsonpath='{.status.response}'

Stop, start and clean up

Set spec.state to Stopped to shut the server down while keeping its data, and back to Running to start it again:

Terminal window
kubectl -n minecraft patch server my-server --type merge -p '{"spec":{"state":"Stopped"}}'

When you are done, delete the server. This deletes its volume and the world with it.

Terminal window
kubectl -n minecraft delete server my-server