Skip to content

Commit 43b27b5

Browse files
authored
Init bedrock chart (#4)
1 parent 70422c4 commit 43b27b5

File tree

11 files changed

+496
-0
lines changed

11 files changed

+496
-0
lines changed

charts/minecraft-bedrock/.helmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*~
18+
# Various IDEs
19+
.project
20+
.idea/
21+
*.tmproj
22+
# OWNERS file for Kubernetes
23+
OWNERS

charts/minecraft-bedrock/Chart.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
apiVersion: v1
2+
name: minecraft-bedrock
3+
version: 1.0.0
4+
appVersion: 1.14.4
5+
home: https://minecraft.net/
6+
description: Minecraft server
7+
keywords:
8+
- game
9+
- server
10+
sources:
11+
- https://github.com/itzg/minecraft-server-charts
12+
- https://hub.docker.com/r/itzg/minecraft-bedrock-server/~/dockerfile/
13+
- https://github.com/itzg/dockerfiles
14+
maintainers:
15+
- name: gtaylor
16+
email: gtaylor@gc-taylor.com
17+
- name: billimek
18+
email: jeff@billimek.com
19+
- name: itzg
20+
email: itzgeoff@gmail.com

charts/minecraft-bedrock/OWNERS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
approvers:
2+
- gtaylor
3+
- itzg
4+
- billimek
5+
reviewers:
6+
- gtaylor
7+
- itzg
8+
- billimek

charts/minecraft-bedrock/README.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Minecraft
2+
3+
[Minecraft](https://minecraft.net/en/) is a game about placing blocks and going on adventures.
4+
5+
## Introduction
6+
7+
This chart creates a single [Minecraft Bedrock Server](https://www.minecraft.net/en-us/download/server/bedrock/) Pod, plus Services for the Minecraft server.
8+
9+
## Prerequisites
10+
11+
- 512 MB of RAM
12+
- Kubernetes 1.4+ with Beta APIs enabled
13+
- PV provisioner support in the underlying infrastructure
14+
15+
## Installing the Chart
16+
17+
To install the chart with the release name `minecraft`, read the [Minecraft EULA](https://account.mojang.com/documents/minecraft_eula) run:
18+
19+
```shell
20+
helm install minecraft-bedrock \
21+
--set minecraftServer.eula=true itzg/minecraft
22+
```
23+
24+
This command deploys a Minecraft dedicated server with sensible defaults.
25+
26+
> **Tip**: List all releases using `helm list`
27+
28+
## Uninstalling the Chart
29+
30+
To uninstall/delete the `minecraft-bedrock` deployment:
31+
32+
```shell
33+
helm delete minecraft-bedrock
34+
```
35+
36+
The command removes all the Kubernetes components associated with the chart and deletes the release.
37+
38+
## Configuration
39+
40+
Refer to [values.yaml](values.yaml) for the full run-down on defaults. These are a mixture of Kubernetes and Minecraft-related directives that map to environment variables in the [itzg/minecraft-bedrock-server](https://hub.docker.com/r/itzg/minecraft-bedrock-server/) Docker image.
41+
42+
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,
43+
44+
```shell
45+
helm install --name minecraft-bedrock \
46+
--set minecraftServer.eula=true,minecraftServer.Difficulty=hard \
47+
itzg/minecraft
48+
```
49+
50+
Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example,
51+
52+
```shell
53+
helm install --name minecraft -f values.yaml itzg/minecraft
54+
```
55+
56+
> **Tip**: You can use the default [values.yaml](values.yaml)
57+
58+
## Persistence
59+
60+
The [itzg/minecraft-bedrock-server](https://hub.docker.com/r/itzg/minecraft-bedrock-server/) image stores the saved games and mods under /data.
61+
62+
By default a PersistentVolumeClaim is created and mounted for saves but not mods. In order to disable this functionality
63+
you can change the values.yaml to disable persistence under the sub-sections under `persistence`.
64+
65+
> *"An emptyDir volume is first created when a Pod is assigned to a Node, and exists as long as that Pod is running on that node. When a Pod is removed from a node for any reason, the data in the emptyDir is deleted forever."*
66+
67+
## Backups
68+
69+
You can backup the state of your minecraft server to your local machine via the `kubectl cp` command.
70+
71+
```shell
72+
NAMESPACE=default
73+
POD_ID=lionhope-387ff8d-sdis9
74+
kubectl attach --namespace ${NAMESPACE} ${POD_ID} -it
75+
save hold
76+
save query
77+
^P + ^Q (CtrlP and CtrlQ)
78+
kubectl cp ${NAMESPACE}/${POD_ID}:/data .
79+
kubectl attach --namespace ${NAMESPACE} ${POD_ID} -it
80+
save resume
81+
^P + ^Q (CtrlP and CtrlQ)
82+
```
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# This must be overridden, since we can't accept this for the user.
2+
minecraftServer:
3+
eula: "TRUE"
4+
# fix in place and rebased
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{{- if eq (printf "%s" .Values.minecraftServer.eula) "FALSE" }}
2+
##############################################################################
3+
#### ERROR: You did not agree to the EULA in your 'helm install' call. ####
4+
##############################################################################
5+
6+
This deployment will be incomplete until you read the Minecraft EULA linked
7+
in the README.md, then:
8+
9+
helm upgrade {{ .Release.Name }} \
10+
--set minecraftServer.eula=true stable/minecraft
11+
{{- else -}}
12+
13+
Get the IP address of your Minecraft server by running these commands in the
14+
same shell:
15+
16+
{{- if contains "NodePort" .Values.minecraftServer.serviceType }}
17+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} \
18+
-o jsonpath="{.spec.ports[0].nodePort}" services {{ template "minecraft.fullname" . }})
19+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} \
20+
-o jsonpath="{.items[0].status.addresses[0].address}")
21+
echo "You'll need to expose this node through your security groups/firewall"
22+
echo "for it to be world-accessible."
23+
echo $NODE_IP:$NODE_PORT
24+
25+
{{- else if contains "LoadBalancer" .Values.minecraftServer.serviceType }}
26+
27+
!! NOTE: It may take a few minutes for the LoadBalancer IP to be available. !!
28+
29+
You can watch for EXTERNAL-IP to populate by running:
30+
kubectl get svc --namespace {{ .Release.Namespace }} -w {{ template "minecraft.fullname" . }}
31+
32+
{{- else if contains "ClusterIP" .Values.minecraftServer.serviceType }}
33+
export POD_NAME=$(kubectl get pods \
34+
--namespace {{ .Release.Namespace }} \
35+
-l "component={{ template "minecraft.fullname" . }}" \
36+
-o jsonpath="{.items[0].metadata.name}")
37+
kubectl port-forward $POD_NAME 25565:25565
38+
echo "Point your Minecraft client at 127.0.0.1:22565"
39+
40+
{{- end }}
41+
42+
{{- if .Values.persistence.dataDir.enabled }}
43+
{{- else }}
44+
45+
############################################################################
46+
### WARNING: Persistence is disabled!!! You will lose your game state ###
47+
### when the Minecraft pod is terminated. ###
48+
### See values.yaml's persistence.dataDir.enabled directive. ###
49+
############################################################################
50+
{{- end }}
51+
{{- end }}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "minecraft.name" -}}
6+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7+
{{- end -}}
8+
9+
{{/*
10+
Create a default fully qualified app name.
11+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
12+
*/}}
13+
{{- define "minecraft.fullname" -}}
14+
{{- $name := default .Chart.Name .Values.nameOverride -}}
15+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
16+
{{- end -}}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{{- if and .Values.persistence.dataDir.enabled (not .Values.persistence.dataDir.existingClaim ) -}}
2+
kind: PersistentVolumeClaim
3+
apiVersion: v1
4+
metadata:
5+
name: {{ template "minecraft.fullname" . }}-datadir
6+
labels:
7+
app: {{ template "minecraft.fullname" . }}
8+
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
9+
release: "{{ .Release.Name }}"
10+
heritage: "{{ .Release.Service }}"
11+
annotations:
12+
{{- if .Values.persistence.storageClass }}
13+
volume.beta.kubernetes.io/storage-class: {{ .Values.persistence.storageClass | quote }}
14+
{{- else }}
15+
volume.alpha.kubernetes.io/storage-class: default
16+
{{- end }}
17+
spec:
18+
accessModes:
19+
- ReadWriteOnce
20+
resources:
21+
requests:
22+
storage: {{ .Values.persistence.dataDir.Size | quote }}
23+
{{- if .Values.persistence.storageClass }}
24+
{{- if (eq "-" .Values.persistence.storageClass) }}
25+
storageClassName: ""
26+
{{- else }}
27+
storageClassName: "{{ .Values.persistence.storageClass }}"
28+
{{- end }}
29+
{{- end }}
30+
{{- end -}}
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
{{- if ne (printf "%s" .Values.minecraftServer.eula) "FALSE" }}
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: {{ template "minecraft.fullname" . }}
6+
{{- if .Values.deploymentAnnotations }}
7+
annotations:
8+
{{- range $key, $value := .Values.deploymentAnnotations }}
9+
{{ $key }}: {{ $value | quote }}
10+
{{- end }}
11+
{{- end }}
12+
labels:
13+
app: {{ template "minecraft.fullname" . }}
14+
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
15+
release: "{{ .Release.Name }}"
16+
heritage: "{{ .Release.Service }}"
17+
spec:
18+
strategy:
19+
type: {{ .Values.strategyType }}
20+
selector:
21+
matchLabels:
22+
app: {{ template "minecraft.fullname" . }}
23+
template:
24+
metadata:
25+
labels:
26+
app: {{ template "minecraft.fullname" . }}
27+
{{- if .Values.podAnnotations }}
28+
annotations:
29+
{{- range $key, $value := .Values.podAnnotations }}
30+
{{ $key }}: {{ $value | quote }}
31+
{{- end }}
32+
{{- end }}
33+
spec:
34+
containers:
35+
- name: {{ template "minecraft.fullname" . }}
36+
image: "{{ .Values.image }}:{{ .Values.imageTag }}"
37+
imagePullPolicy: Always
38+
stdin: true
39+
tty: true
40+
resources:
41+
{{ toYaml .Values.resources | indent 10 }}
42+
readinessProbe:
43+
exec:
44+
command:
45+
- mc-monitor
46+
- status-bedrock
47+
- --host
48+
# force health check against IPv4 port
49+
- 127.0.0.1
50+
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
51+
livenessProbe:
52+
exec:
53+
command:
54+
- mc-monitor
55+
- status-bedrock
56+
- --host
57+
# force health check against IPv4 port
58+
- 127.0.0.1
59+
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
60+
env:
61+
- name: EULA
62+
value: {{ .Values.minecraftServer.eula | quote }}
63+
- name: VERSION
64+
value: {{ .Values.minecraftServer.version | quote }}
65+
- name: DIFFICULTY
66+
value: {{ .Values.minecraftServer.difficulty | quote }}
67+
- name: SERVER_NAME
68+
value: {{ .Values.minecraftServer.serverName | quote }}
69+
- name: WHITE_LIST
70+
value: {{ default "" .Values.minecraftServer.whitelist | quote }}
71+
- name: ALLOW_CHEATS
72+
value: {{ .Values.minecraftServer.cheats | quote }}
73+
- name: MAX_PLAYERS
74+
value: {{ .Values.minecraftServer.maxPlayers | quote }}
75+
- name: VIEW_DISTANCE
76+
value: {{ .Values.minecraftServer.viewDistance | quote }}
77+
- name: TICK_DISTANCE
78+
value: {{ .Values.minecraftServer.tickDistance | quote }}
79+
- name: PLAYER_IDLE_TIMEOUT
80+
value: {{ .Values.minecraftServer.playerIdleTimeout | quote }}
81+
- name: MAX_THREADS
82+
value: {{ .Values.minecraftServer.maxThreads | quote }}
83+
- name: GAMEMODE
84+
value: {{ .Values.minecraftServer.gameMode | quote }}
85+
- name: LEVEL_TYPE
86+
value: {{ .Values.minecraftServer.levelType | quote }}
87+
- name: LEVEL_NAME
88+
value: {{ .Values.minecraftServer.levelName | quote }}
89+
- name: LEVEL_SEED
90+
value: {{ default "" .Values.minecraftServer.levelSeed | quote }}
91+
- name: DEFAULT_PLAYER_PERMISSION_LEVEL
92+
value: {{ .Values.minecraftServer.defaultPermission | quote }}
93+
- name: TEXTUREPACK_REQUIRED
94+
value: {{ .Values.minecraftServer.texturepackRequired | quote }}
95+
- name: ONLINE_MODE
96+
value: {{ .Values.minecraftServer.onlineMode | quote }}
97+
98+
99+
100+
101+
{{- range $key, $value := .Values.extraEnv }}
102+
- name: {{ $key }}
103+
value: {{ $value }}
104+
{{- end }}
105+
106+
ports:
107+
- name: minecraft
108+
containerPort: 19132
109+
protocol: UDP
110+
111+
volumeMounts:
112+
- name: datadir
113+
mountPath: /data
114+
volumes:
115+
- name: datadir
116+
{{- if .Values.persistence.dataDir.enabled }}
117+
persistentVolumeClaim:
118+
{{- if .Values.persistence.dataDir.existingClaim }}
119+
claimName: {{ .Values.persistence.dataDir.existingClaim }}
120+
{{- else }}
121+
claimName: {{ template "minecraft.fullname" . }}-datadir
122+
{{- end }}
123+
{{- else }}
124+
emptyDir: {}
125+
{{- end }}
126+
{{- if .Values.nodeSelector }}
127+
nodeSelector:
128+
{{ toYaml .Values.nodeSelector | indent 8 }}
129+
{{- end }}
130+
{{- if .Values.affinity }}
131+
affinity:
132+
{{ toYaml .Values.affinity | indent 8 }}
133+
{{- end }}
134+
{{- if .Values.tolerations }}
135+
tolerations:
136+
{{ toYaml .Values.tolerations | indent 8 }}
137+
{{- end }}
138+
{{ end }}

0 commit comments

Comments
 (0)