Skip to content

Commit 4c9a8da

Browse files
authored
Update mc-router chart for new auto scale options (#270)
1 parent f863931 commit 4c9a8da

7 files changed

+136
-20
lines changed

charts/mc-router/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
apiVersion: v1
22
name: mc-router
3-
version: 1.3.0
3+
version: 1.4.0
44
# not used
55
appVersion: 1.0.0
66
home: https://github.com/itzg/mc-router
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{{- if eq .Values.minecraftRouter.autoScale.configObject "ConfigMap" | and .Values.minecraftRouter.autoScale.allowDeny }}
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: {{ include "mc-router.fullname" . }}-autoscale-allow-deny
6+
namespace: {{ .Release.Namespace }}
7+
labels:
8+
{{- include "mc-router.labels" . | nindent 4 }}
9+
data:
10+
auto-scale-allow-deny-list.json: {{ .Values.minecraftRouter.autoScale.allowDeny | toJson | squote }}
11+
{{- end }}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{{- if eq .Values.minecraftRouter.autoScale.configObject "Secret" | and .Values.minecraftRouter.autoScale.allowDeny }}
2+
apiVersion: v1
3+
kind: Secret
4+
metadata:
5+
name: {{ include "mc-router.fullname" . }}-autoscale-allow-deny
6+
namespace: {{ .Release.Namespace }}
7+
labels:
8+
{{- include "mc-router.labels" . | nindent 4 }}
9+
data:
10+
auto-scale-allow-deny-list.json: {{ .Values.minecraftRouter.autoScale.allowDeny | toJson | b64enc }}
11+
{{- end }}

charts/mc-router/templates/clusterrole.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ rules:
88
- apiGroups: [""]
99
resources: ["services"]
1010
verbs: ["watch","list"]
11-
{{- if .Values.minecraftRouter.autoScaleUp.enabled }}
11+
{{- if .Values.minecraftRouter.autoScale.up.enabled }}
1212
- apiGroups: ["apps"]
1313
resources: ["statefulsets", "statefulsets/scale"]
1414
verbs: ["watch","list","get","update"]

charts/mc-router/templates/deployment.yaml

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,18 @@ spec:
2525
{{- .Values.deploymentStrategy | toYaml | nindent 4}}
2626
template:
2727
metadata:
28-
{{- with .Values.podAnnotations }}
28+
{{- if or .Values.minecraftRouter.autoScale.allowDeny .Values.podAnnotations }}
2929
annotations:
30+
{{- if .Values.minecraftRouter.autoScale.allowDeny }}
31+
{{- if eq .Values.minecraftRouter.autoScale.configObject "Secret" }}
32+
checksum/autoscale-allow-deny-config: {{ include (print .Template.BasePath "/autoscale-allow-deny-secret.yaml") . | sha256sum }}
33+
{{- else if eq .Values.minecraftRouter.autoScale.configObject "ConfigMap" }}
34+
checksum/autoscale-allow-deny-config: {{ include (print .Template.BasePath "/autoscale-allow-deny-configmap.yaml") . | sha256sum }}
35+
{{- end }}
36+
{{- end }}
37+
{{- with .Values.podAnnotations }}
3038
{{- toYaml . | nindent 8 }}
39+
{{- end }}
3140
{{- end }}
3241
labels:
3342
{{- include "mc-router.labels" . | nindent 8 }}
@@ -54,7 +63,12 @@ spec:
5463
{{- include "mc-router.envMap" (list "PORT" $minecraftPort) }}
5564

5665
{{- with .Values.minecraftRouter }}
57-
{{- include "mc-router.envMap" (list "AUTO_SCALE_UP" .autoScaleUp.enabled) }}
66+
{{- include "mc-router.envMap" (list "AUTO_SCALE_UP" .autoScale.up.enabled) }}
67+
{{- include "mc-router.envMap" (list "AUTO_SCALE_DOWN" .autoScale.down.enabled) }}
68+
{{- include "mc-router.envMap" (list "AUTO_SCALE_DOWN_AFTER" .autoScale.down.after) }}
69+
{{- if .autoScale.allowDeny }}
70+
{{- include "mc-router.envMap" (list "AUTO_SCALE_ALLOW_DENY" "etc/mc-router/auto-scale-allow-deny-list.json") }}
71+
{{- end }}
5872
{{- include "mc-router.envMap" (list "CONNECTION_RATE_LIMIT" .connectionRateLimit) }}
5973
{{- include "mc-router.envMap" (list "CPU_PROFILE" .cpuProfilePath) }}
6074
{{- include "mc-router.envMap" (list "DEBUG" .debug.enabled) }}
@@ -136,13 +150,20 @@ spec:
136150
port: {{ $apiPort }}
137151
resources:
138152
{{- toYaml .Values.resources | nindent 12 }}
139-
{{- with .Values.extraVolumes }}
153+
{{- if or .Values.minecraftRouter.autoScale.allowDeny .Values.extraVolumes }}
140154
volumeMounts:
155+
{{- if .Values.minecraftRouter.autoScale.allowDeny }}
156+
- name: autoscale-allow-deny
157+
mountPath: /etc/mc-router
158+
readOnly: true
159+
{{- end }}
160+
{{- with .Values.extraVolumes }}
141161
{{- range . }}
142162
{{- if .volumeMounts }}
143163
{{- toYaml .volumeMounts | nindent 12 }}
144164
{{- end }}
145165
{{- end }}
166+
{{- end }}
146167
{{- end }}
147168
{{- with .Values.nodeSelector }}
148169
nodeSelector:
@@ -157,13 +178,26 @@ spec:
157178
{{- toYaml . | nindent 8 }}
158179
{{- end }}
159180

160-
{{- with .Values.extraVolumes }}
181+
{{- if or .Values.minecraftRouter.autoScale.allowDeny .Values.extraVolumes }}
161182
volumes:
183+
{{- if .Values.minecraftRouter.autoScale.allowDeny }}
184+
{{- if eq .Values.minecraftRouter.autoScale.configObject "Secret" }}
185+
- name: autoscale-allow-deny
186+
secret:
187+
secretName: {{ include "mc-router.fullname" . }}-autoscale-allow-deny
188+
{{- else if eq .Values.minecraftRouter.autoScale.configObject "ConfigMap" }}
189+
- name: autoscale-allow-deny
190+
configMap:
191+
name: {{ include "mc-router.fullname" . }}-autoscale-allow-deny
192+
{{- end }}
193+
{{- end }}
194+
{{- with .Values.extraVolumes }}
162195
{{- range . }}
163196
{{- if .volumes }}
164197
{{- toYaml .volumes | nindent 8 }}
165198
{{- end }}
166199
{{- end }}
200+
{{- end }}
167201
{{- end }}
168202
{{- range $key, $value := .Values.extraPodSpec }}
169203
{{ $key }}: {{ tpl $value $ }}

charts/mc-router/values.schema.json

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "http://json-schema.org/schema",
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
33
"required": [
44
"minecraftRouter",
55
"services"
@@ -59,17 +59,51 @@
5959

6060
"minecraftRouter": {
6161
"type": "object",
62+
"additionalProperties": false,
6263
"properties": {
63-
"autoScaleUp": {
64+
"autoScale": {
6465
"type": "object",
65-
"title": "\"Wake up\" any stopped Minecraft servers.",
66-
"description": "This requires Minecraft servers to be kind: StatefulSet",
6766
"properties": {
68-
"enabled": {
69-
"anyOf": [
70-
{ "type": "string", "enum": ["default"] },
71-
{ "type": "boolean" }
72-
]
67+
"up": {
68+
"type": "object",
69+
"properties": {
70+
"enabled": {
71+
"title": "\"Wake up\" any stopped Minecraft servers.",
72+
"description": "This requires Minecraft servers to be kind: StatefulSet",
73+
"anyOf": [
74+
{ "type": "string", "enum": ["default"] },
75+
{ "type": "boolean" }
76+
]
77+
}
78+
}
79+
},
80+
"down": {
81+
"type": "object",
82+
"properties": {
83+
"enabled": {
84+
"title": "Shut down any running Minecraft servers after there are no more connections.",
85+
"description": "This requires Minecraft servers to be kind: StatefulSet",
86+
"anyOf": [
87+
{ "type": "string", "enum": ["default"] },
88+
{ "type": "boolean" }
89+
]
90+
},
91+
"after": {
92+
"type": "string",
93+
"title": "Shut down waiting period after there are no more connections.",
94+
"description": "It is recommended that this value is high enough so momentary disconnections do not result in a server shutdown"
95+
}
96+
}
97+
},
98+
"configObject": {
99+
"type": "string",
100+
"enum": ["Secret", "ConfigMap"],
101+
"title": "Type of Kubernetes object to store autoscale allow/deny list config in."
102+
},
103+
"allowDeny": {
104+
"title": "Specify a server allow/deny list to restrict which players may trigger the scalers.",
105+
"$comment": "Update tag below and in values.yaml comment when this file changes",
106+
"$ref": "https://raw.githubusercontent.com/itzg/mc-router/refs/tags/1.29.0/docs/allow-deny-list.schema.json"
73107
}
74108
}
75109
},

charts/mc-router/values.yaml

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,36 @@ extraDeploy: []
143143
# }
144144

145145
minecraftRouter:
146-
# "Wake up" any stopped Minecraft servers.
147-
# This requires Minecraft servers to be kind: StatefulSet
148-
autoScaleUp:
149-
enabled: false
146+
autoScale:
147+
up:
148+
# "Wake up" any stopped Minecraft servers.
149+
# This requires Minecraft servers to be kind: StatefulSet
150+
enabled: false
151+
down:
152+
# Shut down any running Minecraft servers after there are no more connections.
153+
# This requires Minecraft servers to be kind: StatefulSet
154+
enabled: false
155+
# Shut down waiting period after there are no more connections.
156+
# It is recommended that this value is high enough so momentary disconnections do not result in a server shutdown
157+
after: ""
158+
# Type of Kubernetes object to store autoscale allow/deny list config in.
159+
# Valid options: Secret,ConfigMap
160+
configObject: Secret
161+
# Specify a server allow/deny list to restrict which players may trigger the scalers.
162+
# For more info on the schema, check out the file in `mc-router`
163+
# https://github.com/itzg/mc-router/blob/1.29.0/docs/allow-deny-list.schema.json
164+
allowDeny: {}
165+
# global:
166+
# denylist:
167+
# - uuid: some-player-uuid
168+
# name: somePlayerName
169+
# servers:
170+
# my.server.domain:
171+
# allowlist:
172+
# - uuid: some-player-uuid
173+
# my.other-server.domain:
174+
# denylist:
175+
# - uuid: some-player-uuid
150176

151177
# Max number of connections to allow per second
152178
connectionRateLimit: 1
@@ -170,7 +196,7 @@ minecraftRouter:
170196
# port: 25565
171197

172198
metrics:
173-
# Backend to use for metrics exposure/publishing: discard,expvar,influxdb
199+
# Backend to use for metrics exposure/publishing: discard,expvar,influxdb,prometheus
174200
backend: discard
175201

176202
# InfluxDB settings. Required if backend is set to influxdb

0 commit comments

Comments
 (0)