Minecraft Bedrock on Kubernetes

That curious company on desk on the side and in sight.

A while ago I setup a Minecraft server for myself and my kids to play together on. We don't play that often so I often seem to run into an issue of the server running an older version of the client. Updating minecraft manually typically takes me fifteen to twenty minutes and by the time I get it done the kids are on to something else.

So I have been wanting to either make or find an automated way to update the Minecraft server and I have been working with Kubernetes quite a bit lately so I wondered if there was a way to get it working on Kubernetes.

Helm is a package manager for Kubernetes but unfortunately I could only find a Helm chart for Minecraft Java edition which you can check out here.


I did happen to find a docker container for bedrock from here  and he even has a few example configs:

itzg/docker-minecraft-bedrock-server
Containerized Minecraft Bedrock Dedicated Server with selectable version - itzg/docker-minecraft-bedrock-server

There are only three resources you need to setup to get Minecraft Bedrock up and running in Kubernetes.

A Persistent Volume Claim so that you can save your data:

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: bedrock
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
bedrock-pvc.yaml

The next item is a Deployment to handle the creation of the pod/container instance:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: bedrock
  labels:
    app: bedrock
spec:
  replicas: 1
  template:
    metadata:
      name: bedrock
      labels:
        app: bedrock
    spec:
      containers:
        - name: bedrock
          image: itzg/minecraft-bedrock-server
          imagePullPolicy: Always
          env:
            - name: EULA
              value: "TRUE"
            - name: GAMEMODE
              value: survival
            - name: DIFFICULTY
              value: normal
          volumeMounts:
            - mountPath: /data
              name: data
      volumes:
        - name: data
          persistentVolumeClaim:
            claimName: bedrock
  selector:
    matchLabels:
      app: bedrock
bedrock-deployment.yaml

The container supports a number of configuration settings that you can find here.


The last item you need is a Service to expose the UDP port. Since Minecraft bedrock uses UDP protocol we do need a load balancer in our config. As far as I know it inst possible to use an HTTP endpoint.

apiVersion: v1
kind: Service
metadata:
  name: bedrock
spec:
  selector:
    app: bedrock
  ports:
    - port: 19132
      protocol: UDP
  type: LoadBalancer
bedrock-service.yaml

You can upload the configs with the typical kubectl apply

kubectl apply -f bedrock-pvc.yaml
kubectl apply -f bedrock-deployment.yaml
kubectl apply -f bedrock-service.yaml

One thing to keep in mind with this setup is the server is completely open so you will either want to configure access at a firewall or shell into the docker container and configure a whitelist of users that can login.

I haven't been able to test updating yet but hopefully its as simple as killing the pod and letting the deployment bring up the new instance.🤞