From 5797eb8b5db9fe8a2a5e468870096e40d8a9ec30 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sun, 25 Aug 2019 12:27:10 -0500 Subject: [PATCH] docs: added a kubernetes example --- README.md | 31 +++++++++++++++++++++- examples/kubernetes.yml | 58 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 examples/kubernetes.yml diff --git a/README.md b/README.md index a4bbc4c..e39ae3f 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,6 @@ docker run -d --name bds-flat-creative \ -p 19132:19132/udp itzg/minecraft-bedrock-server ``` - ## Exposed Ports - **UDP** 19132 : the Bedrock server port. @@ -77,3 +76,33 @@ When running the container on your LAN, you can find and connect to the dedicate in the "LAN Games" part of the "Friends" tab, such as: ![](docs/example-client.jpg) + +## Deploying with Kubernetes + +The [examples](examples) directory contains [an example Kubernetes manifest file](examples/kubernetes.yml) that declares: +- a peristent volume claim (using default storage class) +- a pod deployment that uses the declared PVC +- a service of type LoadBalancer + +The pod deployment includes some examples of configuring the server properties via environment variables: +```yaml +env: +- name: EULA + value: "TRUE" +- name: GAMEMODE + value: survival +- name: DIFFICULTY + value: normal +``` + +The file is deploy-able as-is on most clusters, but has been confirmed on [Docker for Desktop](https://docs.docker.com/docker-for-windows/kubernetes/) and [Google Kubernetes Engine](https://cloud.google.com/kubernetes-engine/docs/): + +```bash +kubectl apply -f examples/kubernetes.yml +``` + +You can follow the logs of the deployment using: + +```bash +kubectl logs -f deployment/bds +``` \ No newline at end of file diff --git a/examples/kubernetes.yml b/examples/kubernetes.yml new file mode 100644 index 0000000..b38943f --- /dev/null +++ b/examples/kubernetes.yml @@ -0,0 +1,58 @@ +--- +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: bds +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: bds + labels: + app: bds +spec: + replicas: 1 + template: + metadata: + name: bds + labels: + app: bds + spec: + containers: + - name: bds + image: itzg/minecraft-bedrock-server + env: + - name: EULA + value: "TRUE" + - name: GAMEMODE + value: survival + - name: DIFFICULTY + value: normal + volumeMounts: + - mountPath: /data + name: data + volumes: + - name: data + persistentVolumeClaim: + claimName: bds + selector: + matchLabels: + app: bds +--- +apiVersion: v1 +kind: Service +metadata: + name: bds +spec: + selector: + app: bds + ports: + - port: 19132 + protocol: UDP + type: LoadBalancer \ No newline at end of file