Skip to content

Commit

Permalink
feature/add-server-port-bedrock: Added minecraftServer.serverPort val…
Browse files Browse the repository at this point in the history
…ue to allow the pod to run on a different port for Bedrock.

The ping function doesn't work if the server is accessed on an external port (eg nodePort) that isn't 19132.
This change allows the port of the pod to match the external port.
  • Loading branch information
c-gunther committed Sep 26, 2023
1 parent be89ab8 commit 86d677e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
8 changes: 7 additions & 1 deletion charts/minecraft-bedrock/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ spec:
- --host
# force health check against IPv4 port
- 127.0.0.1
- --port
- {{ .Values.minecraftServer.serverPort | quote }}
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
livenessProbe:
exec:
Expand All @@ -72,6 +74,8 @@ spec:
- --host
# force health check against IPv4 port
- 127.0.0.1
- --port
- {{ .Values.minecraftServer.serverPort | quote }}
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}

{{- with .Values.envFrom }}
Expand Down Expand Up @@ -127,6 +131,8 @@ spec:
value: {{ .Values.minecraftServer.emitServerTelemetry | quote }}
- name: ENABLE_LAN_VISIBILITY
value: {{ .Values.minecraftServer.enableLanVisibility | quote }}
- name: SERVER_PORT
value: {{ .Values.minecraftServer.serverPort | quote }}

{{- range $key, $value := .Values.extraEnv }}
{{- if kindIs "map" $value }}
Expand All @@ -143,7 +149,7 @@ spec:

ports:
- name: minecraft
containerPort: 19132
containerPort: {{ .Values.minecraftServer.serverPort }}
protocol: UDP

volumeMounts:
Expand Down
2 changes: 1 addition & 1 deletion charts/minecraft-bedrock/templates/minecraft-svc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ spec:
{{- end }}
ports:
- name: minecraft
port: 19132
port: {{ .Values.minecraftServer.serverPort }}
targetPort: minecraft
{{- if .Values.minecraftServer.nodePort }}
nodePort: {{ .Values.minecraftServer.nodePort }}
Expand Down
2 changes: 2 additions & 0 deletions charts/minecraft-bedrock/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ minecraftServer:
emitServerTelemetry: false
# Enable lan visibility.
enableLanVisibility: false
# IPv4 UDP port of server. If using a nodePort, set serverPort and nodePort to the same value (e.g. 30000) so ping time displays.
serverPort: 19132
# type of kubernetes service to use
serviceType: ClusterIP
## Set the port used if the serviceType is NodePort
Expand Down

0 comments on commit 86d677e

Please sign in to comment.