Files
helm-charts/minecraft-router/templates/minecraft-router.deployment.yaml
T
jklein e4b3c06674 Restart the router when its routing config changes (2.0.0+up1.46.4)
The deployment now carries a checksum/config annotation over the rendered
ConfigMap, so a changed routing table produces a new pod template and a
controlled rollout.

Without it a mapping change was inert but looked successful: the file is
mounted with subPath (kubelet never refreshes those in a running container)
and mc-router reads ROUTES_CONFIG only at startup. That combination caused the
minecraft-server stage-3 outage - the ConfigMap pointed at the renamed
services, the running router kept proxying to the old ones, and the pod stayed
Ready throughout.

Major bump: runtime behaviour changes. A mapping change now costs a router
restart (~4.5 s in k3d, so roughly 17-19 s in the real cluster) during which
clients cannot connect. That restart is what makes the change take effect at
all.

Refs #82.
2026-08-23 18:52:19 +02:00

87 lines
3.5 KiB
YAML

apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}-{{ .Chart.Name }}-deployment
labels:
app: {{ .Release.Name }}-{{ .Chart.Name }}-deployment
spec:
replicas: {{ include "minecraft-router.replicas" (dict "scaleDown" .Values.scaleDown "replicas" .Values.server.replicas) }}
selector:
matchLabels:
app: {{ .Release.Name }}-{{ .Chart.Name }}-deployment
template:
metadata:
name: {{ .Release.Name }}-{{ .Chart.Name }}-deployment
labels:
app: {{ .Release.Name }}-{{ .Chart.Name }}-deployment
annotations:
# Rolls the pod whenever the rendered routing ConfigMap changes.
# Without it a changed routing table stays inert: the file is mounted
# with subPath (kubelet never refreshes those in a running container)
# and mc-router reads ROUTES_CONFIG only at startup, so the router
# would keep serving the old routes while everything looks healthy.
checksum/config: {{ include (print $.Template.BasePath "/minecraft-router.configmap.yaml") . | sha256sum }}
spec:
automountServiceAccountToken: false
securityContext:
{{- toYaml .Values.server.securityContext.pod | nindent 8 }}
containers:
- name: {{ .Release.Name }}-{{ .Chart.Name }}-deployment
image: "itzg/mc-router:{{ .Chart.AppVersion }}"
imagePullPolicy: IfNotPresent
args:
- "--port"
- "{{ .Values.server.port }}"
- "--api-binding"
- ":{{ .Values.server.apiPort }}"
env:
- name: ROUTES_CONFIG
value: /data/custom-routing-config.json
{{- range $value := .Values.server.env }}
{{- if $value.value }}
- name: {{ $value.name }}
value: {{ tpl $value.value $ }}
{{- else if $value.valueFrom }}
{{- if $value.valueFrom.secretKeyRef }}
- name: {{ $value.name }}
valueFrom:
secretKeyRef:
name: {{ tpl $value.valueFrom.secretKeyRef.name $ }}
key: {{ tpl $value.valueFrom.secretKeyRef.key $ }}
{{- else if $value.valueFrom.configMapKeyRef }}
- name: {{ $value.name }}
valueFrom:
configMapKeyRef:
name: {{ tpl $value.valueFrom.configMapKeyRef.name $ }}
key: {{ tpl $value.valueFrom.configMapKeyRef.key $ }}
{{- end }}
{{- end }}
{{- end }}
ports:
- name: proxy-port
protocol: TCP
containerPort: {{ .Values.server.port }}
- name: api-port
protocol: TCP
containerPort: {{ .Values.server.apiPort }}
livenessProbe:
{{- toYaml .Values.server.livenessProbe | nindent 12 }}
readinessProbe:
{{- toYaml .Values.server.readinessProbe | nindent 12 }}
startupProbe:
{{- toYaml .Values.server.startupProbe | nindent 12 }}
resources:
{{- include "minecraft-router.resources" .Values.server.resources | nindent 12 }}
securityContext:
{{- toYaml .Values.server.securityContext.container | nindent 12 }}
volumeMounts:
- name: config-mount
mountPath: /data/custom-routing-config.json
subPath: custom-routing-config.json
readOnly: true
volumes:
- name: config-mount
configMap:
name: {{ .Release.Name }}-{{ .Chart.Name }}-configmap
restartPolicy: Always