From 23a8a893b9c28f5ff05887320d3cabb4fbb3a006 Mon Sep 17 00:00:00 2001 From: RemcoSpigot <106870142+RemcoSpigot@users.noreply.github.com> Date: Mon, 13 Jun 2022 23:16:37 +0200 Subject: [PATCH 1/6] Add velocity support without configuration Add velocity support without configuration Currently supports disabling the proxy and using Velocity instead --- templates/_helpers.tpl | 19 +++++++ templates/master-proxy-service.yaml | 4 +- templates/master-statefulset.yaml | 6 ++ templates/velocity-configmap.yaml | 11 ++++ templates/velocity-deployment.yaml | 59 +++++++++++++++++++ templates/velocity-service.yaml | 17 ++++++ values.yaml | 88 ++++++++++++++++++++++++++++- 7 files changed, 201 insertions(+), 3 deletions(-) create mode 100644 templates/velocity-configmap.yaml create mode 100644 templates/velocity-deployment.yaml create mode 100644 templates/velocity-service.yaml diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl index 01b0f2d..6059f41 100644 --- a/templates/_helpers.tpl +++ b/templates/_helpers.tpl @@ -77,4 +77,23 @@ Selector labels server {{- define "multipaper-helm.server.selectorLabels" -}} app.kubernetes.io/name: {{ include "multipaper-helm.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Common labels server +*/}} +{{- define "multipaper-helm.velocity.labels" -}} +helm.sh/chart: {{ include "multipaper-helm.chart" . }} +{{ include "multipaper-helm.velocity.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +{{- end }} + +{{/* +Selector labels server +*/}} +{{- define "multipaper-helm.velocity.selectorLabels" -}} +app.kubernetes.io/name: {{ include "multipaper-helm.name" . }}-velocity +app.kubernetes.io/instance: {{ .Release.Name }} {{- end }} \ No newline at end of file diff --git a/templates/master-proxy-service.yaml b/templates/master-proxy-service.yaml index 376c7de..653fcc3 100644 --- a/templates/master-proxy-service.yaml +++ b/templates/master-proxy-service.yaml @@ -1,4 +1,4 @@ -{{- if .Values.master.proxy.enabled -}} +{{- if .Values.master.proxy.enabled }} apiVersion: v1 kind: Service metadata: @@ -14,4 +14,4 @@ spec: name: proxy selector: {{- include "multipaper-helm.master.selectorLabels" . | nindent 4 }} -{{- end -}} \ No newline at end of file +{{- end }} \ No newline at end of file diff --git a/templates/master-statefulset.yaml b/templates/master-statefulset.yaml index 2120b32..baa70a7 100644 --- a/templates/master-statefulset.yaml +++ b/templates/master-statefulset.yaml @@ -28,14 +28,20 @@ spec: image: "{{ .Values.master.image.repository }}:{{ .Values.master.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.master.image.pullPolicy }} command: [ "java", "-jar", "/multipaper/multipaper-master.jar" ] + {{- if .Values.master.proxy.enabled }} args: [ "{{ .Values.master.service.port }}", "{{ .Values.master.proxy.service.port }}" ] + {{- else }} + args: [ "{{ .Values.master.service.port }}" ] + {{- end }} ports: - name: server containerPort: {{ .Values.master.service.port }} protocol: TCP + {{- if .Values.master.proxy.enabled }} - name: proxy containerPort: {{ .Values.master.proxy.service.port }} protocol: TCP + {{- end }} volumeMounts: {{ .Values.master.persistent.volumeMounts | toYaml | nindent 16 }} {{- if .Values.master.probes.readinessProbe.startupProbe }} startupProbe: diff --git a/templates/velocity-configmap.yaml b/templates/velocity-configmap.yaml new file mode 100644 index 0000000..5ecd0cf --- /dev/null +++ b/templates/velocity-configmap.yaml @@ -0,0 +1,11 @@ +{{- if .Values.velocity.enabled }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ template "multipaper-helm.fullname" . }}-velocity + labels: + {{- include "multipaper-helm.velocity.labels" . | nindent 4 }} +data: + velocity.toml: | + +{{- end }} \ No newline at end of file diff --git a/templates/velocity-deployment.yaml b/templates/velocity-deployment.yaml new file mode 100644 index 0000000..32c29c2 --- /dev/null +++ b/templates/velocity-deployment.yaml @@ -0,0 +1,59 @@ +{{- if .Values.velocity.enabled }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ template "multipaper-helm.fullname" . }}-velocity + labels: + {{- include "multipaper-helm.velocity.labels" . | nindent 4 }} +spec: + replicas: 1 + selector: + matchLabels: + {{- include "multipaper-helm.velocity.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "multipaper-helm.velocity.selectorLabels" . | nindent 8 }} + spec: + serviceAccountName: {{ template "multipaper-helm.serviceAccount.name" . }} + securityContext: + runAsNonRoot: true + runAsUser: {{ .Values.velocity.uid }} + runAsGroup: {{ .Values.velocity.gid }} + fsGroup: {{ .Values.velocity.gid }} + containers: + - name: {{ .Chart.Name }}-velocity + image: "{{ .Values.velocity.image.repository }}:{{ .Values.velocity.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.velocity.image.pullPolicy }} + ports: + - name: proxy + containerPort: {{ .Values.velocity.service.port }} + protocol: TCP + {{- if .Values.velocity.probes.readinessProbe.startupProbe }} + startupProbe: + tcpSocket: + port: proxy + failureThreshold: {{ .Values.velocity.probes.startupProbe.failureThreshold }} + periodSeconds: {{ .Values.velocity.probes.startupProbe.periodSeconds }} + {{- end }} + {{- if .Values.velocity.probes.readinessProbe.timeoutSecond }} + readinessProbe: + tcpSocket: + port: proxy + initialDelaySeconds: {{ .Values.velocity.probes.readinessProbe.initialDelaySeconds }} + periodSeconds: {{ .Values.velocity.probes.readinessProbe.periodSeconds }} + failureThreshold: {{ .Values.velocity.probes.readinessProbe.failureThreshold }} + successThreshold: {{ .Values.velocity.probes.readinessProbe.successThreshold }} + timeoutSeconds: {{ .Values.velocity.probes.readinessProbe.timeoutSeconds }} + {{- end }} + {{- if .Values.velocity.probes.livenessProbe.timeoutSecond }} + livenessProbe: + tcpSocket: + port: proxy + initialDelaySeconds: {{ .Values.velocity.probes.livenessProbe.initialDelaySeconds }} + periodSeconds: {{ .Values.velocity.probes.livenessProbe.periodSeconds }} + failureThreshold: {{ .Values.velocity.probes.livenessProbe.failureThreshold }} + successThreshold: {{ .Values.velocity.probes.livenessProbe.successThreshold }} + timeoutSeconds: {{ .Values.velocity.probes.livenessProbe.timeoutSeconds }} + {{- end }} +{{- end }} \ No newline at end of file diff --git a/templates/velocity-service.yaml b/templates/velocity-service.yaml new file mode 100644 index 0000000..a7b3ec9 --- /dev/null +++ b/templates/velocity-service.yaml @@ -0,0 +1,17 @@ +{{- if .Values.velocity.enabled }} +apiVersion: v1 +kind: Service +metadata: + name: {{ template "multipaper-helm.fullname" . }}-velocity + labels: + {{- include "multipaper-helm.velocity.labels" . | nindent 4 }} +spec: + type: {{ .Values.velocity.service.type }} + ports: + - port: {{ .Values.velocity.service.port }} + targetPort: {{ .Values.velocity.service.targetPort }} + protocol: TCP + name: proxy + selector: + {{- include "multipaper-helm.velocity.selectorLabels" . | nindent 4 }} +{{- end }} \ No newline at end of file diff --git a/values.yaml b/values.yaml index 7808a6a..0271996 100644 --- a/values.yaml +++ b/values.yaml @@ -8,6 +8,88 @@ global: # When empty the full name of the Helm deployment would be used. name: "" +# Velocity +velocity: + # Whether or not Velocity is enabled + enabled: true + # The id of the group that will be running the Velocity server process. + # By default this is 1001, multipaper user. + # Image dependant. + gid: 1001 + # The id of the user that will be running the Velocity server process. + # By default this is 1001, multipaper user. + # Image dependant. + uid: 1001 + + image: + repository: "velocity" + # Tag of the Docker image to be used. + # Defaults to the Chart's app version if left blank. + tag: "3.1.1-98" + pullPolicy: IfNotPresent + + resources: {} + # resources: + # requests: + # memory: 256Mi + # cpu: 250m + # limits: + # memory: 256Mi + # cpu: 250m + + service: + # Type can be ClusterIP or NodePort + type: NodePort + + # Port on which the Velocity server is listening. + port: 25577 + # Target port to which the service should be mapped to. + targetPort: 25577 + + # Section for startup, readiness and liveness probes + probes: + + # Probe used to weed out slow pods + startupProbe: + enabled: true + # When a probe fails, Kubernetes will try failureThreshold times before giving up. + # After this it will restart the container. + failureThreshold: 3 + # How often (in seconds) to perform the probe. + periodSeconds: 20 + + # Probe used to define whether a pod is ready or not + readinessProbe: + enabled: true + # Number of seconds after the container has started before liveness or readiness probes are initiated. + initialDelaySeconds: 40 + # How often (in seconds) to perform the probe. + periodSeconds: 5 + # When a probe fails, Kubernetes will try failureThreshold times before giving up. + # After this it will mark the Pod as Unready + failureThreshold: 5 + # Minimum consecutive successes for the probe to be considered successful after having failed. + successThreshold: 2 + # Number of seconds after which the probe times out and ultimately fails. + timeoutSeconds: 1 + + # Probe used to verify whether a pod is still running succesfully + livenessProbe: + enabled: true + # Number of seconds after the container has started before liveness or readiness probes are initiated. + initialDelaySeconds: 40 + # How often (in seconds) to perform the probe. + periodSeconds: 5 + # When a probe fails, Kubernetes will try failureThreshold times before giving up. + # After this it will restart the container. + failureThreshold: 5 + # Minimum consecutive successes for the probe to be considered successful after having failed. + successThreshold: 1 + # Number of seconds after which the probe times out and ultimately fails. + timeoutSeconds: 1 + + labels: {} + # MultiPaper master server master: # The id of the group that will be running the master server process. @@ -21,7 +103,7 @@ master: # Built-in Proxy settings proxy: - enabled: true + enabled: false service: # Type can be ClusterIP or NodePort type: NodePort @@ -42,6 +124,10 @@ master: # See https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#update-strategies updateStrategyType: "RollingUpdate" + pdb: + enabled: false + minAvailable: 1 + resources: {} # resources: # requests: From b1329aadb1dc62c33a23a87d9dfb81eae41a9d5f Mon Sep 17 00:00:00 2001 From: RemcoSpigot <106870142+RemcoSpigot@users.noreply.github.com> Date: Mon, 13 Jun 2022 23:19:16 +0200 Subject: [PATCH 2/6] By default let velocity use 1G of memory --- values.yaml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/values.yaml b/values.yaml index 0271996..f83a5bc 100644 --- a/values.yaml +++ b/values.yaml @@ -28,14 +28,11 @@ velocity: tag: "3.1.1-98" pullPolicy: IfNotPresent - resources: {} - # resources: - # requests: - # memory: 256Mi - # cpu: 250m - # limits: - # memory: 256Mi - # cpu: 250m + resources: + requests: + memory: 1Gi + limits: + memory: 1Gi service: # Type can be ClusterIP or NodePort From fdaade0d3c21c45ff19ebe5a90f15c2d85f780d4 Mon Sep 17 00:00:00 2001 From: RemcoSpigot <106870142+RemcoSpigot@users.noreply.github.com> Date: Mon, 13 Jun 2022 23:43:10 +0200 Subject: [PATCH 3/6] Add configuration for Velocity, disable master when velocity used --- templates/master-service.yaml | 2 + templates/master-statefulset.yaml | 6 +- templates/multipaper-config-configmap.yaml | 10 +- templates/velocity-configmap.yaml | 103 +++++++++++++++++- templates/velocity-proxy-service.yaml | 17 +++ templates/velocity-service.yaml | 9 +- ...loyment.yaml => velocity-statefulset.yaml} | 21 +++- values.yaml | 64 ++++++----- 8 files changed, 191 insertions(+), 41 deletions(-) create mode 100644 templates/velocity-proxy-service.yaml rename templates/{velocity-deployment.yaml => velocity-statefulset.yaml} (75%) diff --git a/templates/master-service.yaml b/templates/master-service.yaml index 78e4727..f836faf 100644 --- a/templates/master-service.yaml +++ b/templates/master-service.yaml @@ -1,3 +1,4 @@ +{{- if not .Values.velocity.enabled }} apiVersion: v1 kind: Service metadata: @@ -14,3 +15,4 @@ spec: name: server selector: {{- include "multipaper-helm.master.selectorLabels" . | nindent 4 }} +{{- end }} \ No newline at end of file diff --git a/templates/master-statefulset.yaml b/templates/master-statefulset.yaml index baa70a7..3e0584c 100644 --- a/templates/master-statefulset.yaml +++ b/templates/master-statefulset.yaml @@ -1,3 +1,4 @@ +{{- if not .Values.velocity.enabled }} apiVersion: apps/v1 kind: StatefulSet metadata: @@ -28,11 +29,7 @@ spec: image: "{{ .Values.master.image.repository }}:{{ .Values.master.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.master.image.pullPolicy }} command: [ "java", "-jar", "/multipaper/multipaper-master.jar" ] - {{- if .Values.master.proxy.enabled }} args: [ "{{ .Values.master.service.port }}", "{{ .Values.master.proxy.service.port }}" ] - {{- else }} - args: [ "{{ .Values.master.service.port }}" ] - {{- end }} ports: - name: server containerPort: {{ .Values.master.service.port }} @@ -73,3 +70,4 @@ spec: {{- if .Values.master.persistent }} volumeClaimTemplates: {{ .Values.master.persistent.claimTemplates | toYaml | nindent 4}} {{- end }} +{{- end }} \ No newline at end of file diff --git a/templates/multipaper-config-configmap.yaml b/templates/multipaper-config-configmap.yaml index c2aca9d..d4ddaaf 100644 --- a/templates/multipaper-config-configmap.yaml +++ b/templates/multipaper-config-configmap.yaml @@ -12,8 +12,12 @@ data: # Docs: https://github.com/PureGero/MultiPaper/blob/main/MULTIPAPER_YAML.md useLocalPlayerCountForServerIsFullKick: false + {{- if .Values.velocity.enabled }} multipaperMasterAddress: {{ template "multipaper-helm.fullname" . }}-master:{{ .Values.master.service.targetPort }} - advertiseToBuiltInProxy: {{ .Values.master.proxy.enabled }} + {{- else }} + multipaperMasterAddress: {{ template "multipaper-helm.fullname" . }}-velocity:{{ .Values.velocity.master.service.targetPort }} + {{- end }} + advertiseToBuiltInProxy: {{ .Values.velocity.enabled }} filesToSyncOnStartup: filesToSyncInRealTime: filesToOnlyUploadOnServerStop: @@ -25,4 +29,8 @@ data: syncJsonFiles: false filesToNotSync: - plugins/bStats + {{- if .Values.velocity.enabled }} bungeecordName: $HOSTNAME + {{- else }} + bungeecordName: event + {{- end }} diff --git a/templates/velocity-configmap.yaml b/templates/velocity-configmap.yaml index 5ecd0cf..d0f72c5 100644 --- a/templates/velocity-configmap.yaml +++ b/templates/velocity-configmap.yaml @@ -6,6 +6,107 @@ metadata: labels: {{- include "multipaper-helm.velocity.labels" . | nindent 4 }} data: - velocity.toml: | + config.toml: | + # Config version. Do not change this + config-version = "1.0" + # What port should the proxy be bound to? By default, we'll bind to all addresses on port 25577. + bind = "0.0.0.0:25577" + # What should be the MOTD? This gets displayed when the player adds your server to + # their server list. Legacy color codes and JSON are accepted. + motd = " add3A Velocity Server" + # What should we display for the maximum number of players? (Velocity does not support a cap + # on the number of players online.) + show-max-players = 1000 + # Should we authenticate players with Mojang? By default, this is on. + online-mode = true + # If client's ISP/AS sent from this proxy is different from the one from Mojang's + # authentication server, the player is kicked. This disallows some VPN and proxy + # connections but is a weak form of protection. + prevent-client-proxy-connections = false + # Should we forward IP addresses and other data to backend servers? + # Available options: + # - "none": No forwarding will be done. All players will appear to be connecting + # from the proxy and will have offline-mode UUIDs. + # - "legacy": Forward player IPs and UUIDs in a BungeeCord-compatible format. Use this + # if you run servers using Minecraft 1.12 or lower. + # - "bungeeguard": Forward player IPs and UUIDs in a format supported by the BungeeGuard + # plugin. Use this if you run servers using Minecraft 1.12 or lower, and are + # unable to implement network level firewalling (on a shared host). + # - "modern": Forward player IPs and UUIDs as part of the login process using + # Velocity's native forwarding. Only applicable for Minecraft 1.13 or higher. + player-info-forwarding-mode = "NONE" + # If you are using modern or BungeeGuard IP forwarding, configure a unique secret here. + forwarding-secret = "M7VISLIhNnT5" + # Announce whether or not your server supports Forge. If you run a modded server, we + # suggest turning this on. + # + # If your network runs one modpack consistently, consider using ping-passthrough = "mods" + # instead for a nicer display in the server list. + announce-forge = false + # If enabled (default is false) and the proxy is in online mode, Velocity will kick + # any existing player who is online if a duplicate connection attempt is made. + kick-existing-players = false + # Should Velocity pass server list ping requests to a backend server? + # Available options: + # - "disabled": No pass-through will be done. The velocity.toml and server-icon.png + # will determine the initial server list ping response. + # - "mods": Passes only the mod list from your backend server into the response. + # The first server in your try list (or forced host) with a mod list will be + # used. If no backend servers can be contacted, Velocity won't display any + # mod information. + # - "description": Uses the description and mod list from the backend server. The first + # server in the try (or forced host) list that responds is used for the + # description and mod list. + # - "all": Uses the backend server's response as the proxy response. The Velocity + # configuration is used if no servers could be contacted. + ping-passthrough = "DISABLED" + [servers] + # Configure your servers here. Each key represents the server's name, and the value + # represents the IP address of the server to connect to. + event = "127.0.0.1:35353" + # In what order we should try servers when a player logs in or is kicked from a server. + try = ["event"] + + [advanced] + # How large a Minecraft packet has to be before we compress it. Setting this to zero will + # compress all packets, and setting it to -1 will disable compression entirely. + compression-threshold = 256 + # How much compression should be done (from 0-9). The default is -1, which uses the + # default level of 6. + compression-level = -1 + # How fast (in milliseconds) are clients allowed to connect after the last connection? By + # default, this is three seconds. Disable this by setting this to 0. + login-ratelimit = 3000 + # Specify a custom timeout for connection timeouts here. The default is five seconds. + connection-timeout = 5000 + # Specify a read timeout for connections here. The default is 30 seconds. + read-timeout = 30000 + # Enables compatibility with HAProxy's PROXY protocol. If you don't know what this is for, then + # don't enable it. + haproxy-protocol = false + # Enables TCP fast open support on the proxy. Requires the proxy to run on Linux. + tcp-fast-open = false + # Enables BungeeCord plugin messaging channel support on Velocity. + bungee-plugin-message-channel = true + # Shows ping requests to the proxy from clients. + show-ping-requests = false + # By default, Velocity will attempt to gracefully handle situations where the user unexpectedly + # loses connection to the server without an explicit disconnect message by attempting to fall the + # user back, except in the case of read timeouts. BungeeCord will disconnect the user instead. You + # can disable this setting to use the BungeeCord behavior. + failover-on-unexpected-server-disconnect = true + # Declares the proxy commands to 1.13+ clients. + announce-proxy-commands = true + # Enables the logging of commands + log-command-executions = false + + [query] + # Whether to enable responding to GameSpy 4 query responses or not. + enabled = false + # If query is enabled, on what port should the query protocol listen on? + port = 25577 + # This is the map name that is reported to the query services. + map = "Velocity" + show-plugins = false {{- end }} \ No newline at end of file diff --git a/templates/velocity-proxy-service.yaml b/templates/velocity-proxy-service.yaml new file mode 100644 index 0000000..9dff84b --- /dev/null +++ b/templates/velocity-proxy-service.yaml @@ -0,0 +1,17 @@ +{{- if .Values.velocity.enabled }} +apiVersion: v1 +kind: Service +metadata: + name: {{ template "multipaper-helm.fullname" . }}-velocity-proxy + labels: + {{- include "multipaper-helm.velocity.labels" . | nindent 4 }} +spec: + type: {{ .Values.velocity.proxy.service.type }} + ports: + - port: {{ .Values.velocity.proxy.service.port }} + targetPort: {{ .Values.velocity.proxy.service.targetPort }} + protocol: TCP + name: proxy + selector: + {{- include "multipaper-helm.velocity.selectorLabels" . | nindent 4 }} +{{- end }} \ No newline at end of file diff --git a/templates/velocity-service.yaml b/templates/velocity-service.yaml index a7b3ec9..a0bf3e1 100644 --- a/templates/velocity-service.yaml +++ b/templates/velocity-service.yaml @@ -6,12 +6,13 @@ metadata: labels: {{- include "multipaper-helm.velocity.labels" . | nindent 4 }} spec: - type: {{ .Values.velocity.service.type }} + type: ClusterIP + clusterIP: None ports: - - port: {{ .Values.velocity.service.port }} - targetPort: {{ .Values.velocity.service.targetPort }} + - port: {{ .Values.velocity.master.service.port }} + targetPort: {{ .Values.velocity.master.service.targetPort }} protocol: TCP - name: proxy + name: master selector: {{- include "multipaper-helm.velocity.selectorLabels" . | nindent 4 }} {{- end }} \ No newline at end of file diff --git a/templates/velocity-deployment.yaml b/templates/velocity-statefulset.yaml similarity index 75% rename from templates/velocity-deployment.yaml rename to templates/velocity-statefulset.yaml index 32c29c2..6195f2d 100644 --- a/templates/velocity-deployment.yaml +++ b/templates/velocity-statefulset.yaml @@ -1,12 +1,13 @@ {{- if .Values.velocity.enabled }} apiVersion: apps/v1 -kind: Deployment +kind: StatefulSet metadata: name: {{ template "multipaper-helm.fullname" . }}-velocity labels: {{- include "multipaper-helm.velocity.labels" . | nindent 4 }} spec: replicas: 1 + serviceName: {{ template "multipaper-helm.fullname" . }}-velocity selector: matchLabels: {{- include "multipaper-helm.velocity.selectorLabels" . | nindent 6 }} @@ -26,9 +27,16 @@ spec: image: "{{ .Values.velocity.image.repository }}:{{ .Values.velocity.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.velocity.image.pullPolicy }} ports: + - name: master + containerPort: {{ .Values.velocity.master.service.port }} + protocol: TCP - name: proxy - containerPort: {{ .Values.velocity.service.port }} + containerPort: {{ .Values.velocity.proxy.service.port }} protocol: TCP + volumeMounts: + - name: velocity-config + mountPath: /multipaper/plugins/multipaper-velocity/config.toml + subPath: config.toml {{- if .Values.velocity.probes.readinessProbe.startupProbe }} startupProbe: tcpSocket: @@ -56,4 +64,13 @@ spec: successThreshold: {{ .Values.velocity.probes.livenessProbe.successThreshold }} timeoutSeconds: {{ .Values.velocity.probes.livenessProbe.timeoutSeconds }} {{- end }} + volumes: + - name: velocity-config + configMap: + # Provide the name of the ConfigMap containing the files you want + # to add to the container + name: {{ template "multipaper-helm.fullname" . }}-velocity + {{- if .Values.global.persistent }} + volumeClaimTemplates: {{ .Values.global.persistent.claimTemplates | toYaml | nindent 4}} + {{- end }} {{- end }} \ No newline at end of file diff --git a/values.yaml b/values.yaml index f83a5bc..f930e26 100644 --- a/values.yaml +++ b/values.yaml @@ -8,6 +8,26 @@ global: # When empty the full name of the Helm deployment would be used. name: "" + # Own control over persistent volumes. + # Normally this would hold non arbitrary values that are templated, + # but since Minecraft can have other worlds, we decided not to. + persistent: + # Defines Volumes (https://kubernetes.io/docs/concepts/storage/volume) to be linked to the master. + # Persists all the files synced to the master. + volumeMounts: + - name: "data" + mountPath: "/multipaper/plugins/multipaper-velocity/world" + # Template for Persistent Volume Claims (https://kubernetes.io/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims) + # This setup automatically creates Persistent Volumes for you, if no Persistent Volume is found. + claimTemplates: + - metadata: + name: "data" + spec: + accessModes: [ "ReadWriteOnce" ] + storageClassName: null + resources: + requests: + storage: "30Gi" # Velocity velocity: # Whether or not Velocity is enabled @@ -34,14 +54,22 @@ velocity: limits: memory: 1Gi - service: - # Type can be ClusterIP or NodePort - type: NodePort + master: + service: + # Port on which the Velocity server is listening. + port: 35353 + # Target port to which the service should be mapped to. + targetPort: 35353 - # Port on which the Velocity server is listening. - port: 25577 - # Target port to which the service should be mapped to. - targetPort: 25577 + proxy: + service: + # Type can be ClusterIP or NodePort + type: NodePort + + # Port on which the Velocity server is listening. + port: 25577 + # Target port to which the service should be mapped to. + targetPort: 25577 # Section for startup, readiness and liveness probes probes: @@ -100,7 +128,6 @@ master: # Built-in Proxy settings proxy: - enabled: false service: # Type can be ClusterIP or NodePort type: NodePort @@ -181,27 +208,6 @@ master: successThreshold: 1 # Number of seconds after which the probe times out and ultimately fails. timeoutSeconds: 1 - - # Own control over persistent volumes. - # Normally this would hold non arbitrary values that are templated, - # but since Minecraft can have other worlds, we decided not to. - persistent: - # Defines Volumes (https://kubernetes.io/docs/concepts/storage/volume) to be linked to the master. - # Persists all the files synced to the master. - volumeMounts: - - name: "data" - mountPath: "/multipaper/data" - # Template for Persistent Volume Claims (https://kubernetes.io/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims) - # This setup automatically creates Persistent Volumes for you, if no Persistent Volume is found. - claimTemplates: - - metadata: - name: "data" - spec: - accessModes: [ "ReadWriteOnce" ] - storageClassName: null - resources: - requests: - storage: "30Gi" labels: {} From 03594c3bf37cdf0b0aa0386d3cc99aecd515197e Mon Sep 17 00:00:00 2001 From: RemcoDev <106870142+RemcoSpigot@users.noreply.github.com> Date: Tue, 14 Jun 2022 22:48:05 +0200 Subject: [PATCH 4/6] Integrate Velocity succesfully with MultiPaper - Change Velocity image to the correct version - Move persistent from global back to master - Enable secret forwarding customization for velocity - Automatically disable master when velocity active - Automatically configure Spigot, Paper and Minecraft for velocity --- templates/_helpers.tpl | 19 ++++++ templates/multipaper-config-configmap.yaml | 6 +- templates/multipaper-minecraft-configmap.yaml | 2 +- templates/multipaper-paper-configmap.yaml | 6 +- templates/multipaper-service.yaml | 15 +++++ templates/multipaper-spigot-configmap.yaml | 2 +- templates/velocity-configmap.yaml | 16 +++-- templates/velocity-multipaper-configmap.yaml | 12 ++++ templates/velocity-statefulset.yaml | 13 ++-- values.yaml | 62 ++++++++++--------- 10 files changed, 104 insertions(+), 49 deletions(-) create mode 100644 templates/multipaper-service.yaml create mode 100644 templates/velocity-multipaper-configmap.yaml diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl index 6059f41..98d568e 100644 --- a/templates/_helpers.tpl +++ b/templates/_helpers.tpl @@ -96,4 +96,23 @@ Selector labels server {{- define "multipaper-helm.velocity.selectorLabels" -}} app.kubernetes.io/name: {{ include "multipaper-helm.name" . }}-velocity app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Whether or not online mode should be used. +*/}} +{{- define "multipaper-helm.onlineMode" -}} +{{- if .Values.velocity.enabled }} +{{- printf "false" }} +{{- else }} +{{- printf "true" }} +{{- end }} +{{- end }} + +{{/* +Whether or not to support Bungeecord forwarding. +TODO: Add the option to disable this based on the forwarding setting. Currently this is only modern. +*/}} +{{- define "multipaper-helm.bungeecord" -}} +{{- printf "%s" (include "multipaper-helm.onlineMode" .) -}} {{- end }} \ No newline at end of file diff --git a/templates/multipaper-config-configmap.yaml b/templates/multipaper-config-configmap.yaml index d4ddaaf..98e3fc3 100644 --- a/templates/multipaper-config-configmap.yaml +++ b/templates/multipaper-config-configmap.yaml @@ -13,9 +13,9 @@ data: useLocalPlayerCountForServerIsFullKick: false {{- if .Values.velocity.enabled }} - multipaperMasterAddress: {{ template "multipaper-helm.fullname" . }}-master:{{ .Values.master.service.targetPort }} + multipaperMasterAddress: {{ template "multipaper-helm.fullname" . }}-velocity-master:{{ .Values.velocity.master.service.targetPort }} {{- else }} - multipaperMasterAddress: {{ template "multipaper-helm.fullname" . }}-velocity:{{ .Values.velocity.master.service.targetPort }} + multipaperMasterAddress: {{ template "multipaper-helm.fullname" . }}-master:{{ .Values.master.service.targetPort }} {{- end }} advertiseToBuiltInProxy: {{ .Values.velocity.enabled }} filesToSyncOnStartup: @@ -32,5 +32,5 @@ data: {{- if .Values.velocity.enabled }} bungeecordName: $HOSTNAME {{- else }} - bungeecordName: event + bungeecordName: {{ template "multipaper-helm.fullname" . }} {{- end }} diff --git a/templates/multipaper-minecraft-configmap.yaml b/templates/multipaper-minecraft-configmap.yaml index 76a527e..feec32a 100644 --- a/templates/multipaper-minecraft-configmap.yaml +++ b/templates/multipaper-minecraft-configmap.yaml @@ -29,7 +29,7 @@ data: max-tick-time=60000 use-native-transport=true max-players=20 - online-mode=true + online-mode={{ template "multipaper-helm.onlineMode" . }} enable-status=true allow-flight=false broadcast-rcon-to-ops=true diff --git a/templates/multipaper-paper-configmap.yaml b/templates/multipaper-paper-configmap.yaml index 23b2c37..8a31ae2 100644 --- a/templates/multipaper-paper-configmap.yaml +++ b/templates/multipaper-paper-configmap.yaml @@ -74,9 +74,9 @@ data: tab-spam-limit: 500 bungee-online-mode: true velocity-support: - enabled: false - online-mode: false - secret: '' + enabled: {{ .Values.velocity.enabled }} + online-mode: true + secret: {{ .Values.velocity.secret | quote }} max-joins-per-tick: 3 player-auto-save-rate: -1 max-player-auto-save-per-tick: -1 diff --git a/templates/multipaper-service.yaml b/templates/multipaper-service.yaml new file mode 100644 index 0000000..f1a844e --- /dev/null +++ b/templates/multipaper-service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "multipaper-helm.fullname" . }} + labels: + {{- include "multipaper-helm.server.labels" . | nindent 4 }} +spec: + type: ClusterIP + ports: + - port: {{ .Values.server.service.port }} + targetPort: {{ .Values.server.service.targetPort }} + protocol: TCP + name: server + selector: + {{- include "multipaper-helm.server.selectorLabels" . | nindent 4 }} \ No newline at end of file diff --git a/templates/multipaper-spigot-configmap.yaml b/templates/multipaper-spigot-configmap.yaml index 27fbeeb..47ff05f 100644 --- a/templates/multipaper-spigot-configmap.yaml +++ b/templates/multipaper-spigot-configmap.yaml @@ -39,7 +39,7 @@ data: log-named-deaths: true save-user-cache-on-stop-only: false sample-count: 12 - bungeecord: {{ .Values.master.proxy.enabled }} + bungeecord: {{ template "multipaper-helm.bungeecord" . }} commands: log: true tab-complete: 0 diff --git a/templates/velocity-configmap.yaml b/templates/velocity-configmap.yaml index d0f72c5..a9e51c6 100644 --- a/templates/velocity-configmap.yaml +++ b/templates/velocity-configmap.yaml @@ -6,14 +6,14 @@ metadata: labels: {{- include "multipaper-helm.velocity.labels" . | nindent 4 }} data: - config.toml: | + velocity.toml: | # Config version. Do not change this config-version = "1.0" # What port should the proxy be bound to? By default, we'll bind to all addresses on port 25577. bind = "0.0.0.0:25577" # What should be the MOTD? This gets displayed when the player adds your server to # their server list. Legacy color codes and JSON are accepted. - motd = " add3A Velocity Server" + motd = " add3MultiPaper" # What should we display for the maximum number of players? (Velocity does not support a cap # on the number of players online.) show-max-players = 1000 @@ -34,9 +34,9 @@ data: # unable to implement network level firewalling (on a shared host). # - "modern": Forward player IPs and UUIDs as part of the login process using # Velocity's native forwarding. Only applicable for Minecraft 1.13 or higher. - player-info-forwarding-mode = "NONE" + player-info-forwarding-mode = "modern" # If you are using modern or BungeeGuard IP forwarding, configure a unique secret here. - forwarding-secret = "M7VISLIhNnT5" + forwarding-secret = {{ .Values.velocity.secret | quote }} # Announce whether or not your server supports Forge. If you run a modded server, we # suggest turning this on. # @@ -64,9 +64,13 @@ data: [servers] # Configure your servers here. Each key represents the server's name, and the value # represents the IP address of the server to connect to. - event = "127.0.0.1:35353" + {{ template "multipaper-helm.fullname" . }} = "{{ template "multipaper-helm.fullname" . }}:{{ .Values.server.service.targetPort }}" # In what order we should try servers when a player logs in or is kicked from a server. - try = ["event"] + try = [{{- include "multipaper-helm.fullname" . | quote }}] + + [forced-hosts] + # Configure your forced hosts here. + "{{ template "multipaper-helm.fullname" . }}.internal" = [{{- include "multipaper-helm.fullname" . | quote }}] [advanced] # How large a Minecraft packet has to be before we compress it. Setting this to zero will diff --git a/templates/velocity-multipaper-configmap.yaml b/templates/velocity-multipaper-configmap.yaml new file mode 100644 index 0000000..a8d01a5 --- /dev/null +++ b/templates/velocity-multipaper-configmap.yaml @@ -0,0 +1,12 @@ +{{- if .Values.velocity.enabled }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ template "multipaper-helm.fullname" . }}-velocity-multipaper + labels: + {{- include "multipaper-helm.velocity.labels" . | nindent 4 }} +data: + config.toml: | + port = {{ .Values.velocity.master.service.targetPort }} + balance-nodes = true +{{- end }} \ No newline at end of file diff --git a/templates/velocity-statefulset.yaml b/templates/velocity-statefulset.yaml index 6195f2d..4ecd9d5 100644 --- a/templates/velocity-statefulset.yaml +++ b/templates/velocity-statefulset.yaml @@ -35,7 +35,10 @@ spec: protocol: TCP volumeMounts: - name: velocity-config - mountPath: /multipaper/plugins/multipaper-velocity/config.toml + mountPath: /multipaper/data/velocity.toml + subPath: velocity.toml + - name: multipaper-config + mountPath: /multipaper/data/plugins/multipaper-velocity/config.toml subPath: config.toml {{- if .Values.velocity.probes.readinessProbe.startupProbe }} startupProbe: @@ -67,10 +70,8 @@ spec: volumes: - name: velocity-config configMap: - # Provide the name of the ConfigMap containing the files you want - # to add to the container name: {{ template "multipaper-helm.fullname" . }}-velocity - {{- if .Values.global.persistent }} - volumeClaimTemplates: {{ .Values.global.persistent.claimTemplates | toYaml | nindent 4}} - {{- end }} + - name: multipaper-config + configMap: + name: {{ template "multipaper-helm.fullname" . }}-velocity-multipaper {{- end }} \ No newline at end of file diff --git a/values.yaml b/values.yaml index f930e26..5d2861a 100644 --- a/values.yaml +++ b/values.yaml @@ -8,30 +8,15 @@ global: # When empty the full name of the Helm deployment would be used. name: "" - # Own control over persistent volumes. - # Normally this would hold non arbitrary values that are templated, - # but since Minecraft can have other worlds, we decided not to. - persistent: - # Defines Volumes (https://kubernetes.io/docs/concepts/storage/volume) to be linked to the master. - # Persists all the files synced to the master. - volumeMounts: - - name: "data" - mountPath: "/multipaper/plugins/multipaper-velocity/world" - # Template for Persistent Volume Claims (https://kubernetes.io/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims) - # This setup automatically creates Persistent Volumes for you, if no Persistent Volume is found. - claimTemplates: - - metadata: - name: "data" - spec: - accessModes: [ "ReadWriteOnce" ] - storageClassName: null - resources: - requests: - storage: "30Gi" # Velocity velocity: # Whether or not Velocity is enabled enabled: true + + # Secret used by when forwarding to another server. + # !! CHANGE THIS VALUE !! + secret: "sdfslKkdsdf" + # The id of the group that will be running the Velocity server process. # By default this is 1001, multipaper user. # Image dependant. @@ -42,17 +27,19 @@ velocity: uid: 1001 image: - repository: "velocity" + repository: "remcospigot/velocity" # Tag of the Docker image to be used. # Defaults to the Chart's app version if left blank. - tag: "3.1.1-98" - pullPolicy: IfNotPresent + tag: "3.1.2-SNAPSHOT-153" + pullPolicy: Always resources: requests: - memory: 1Gi + cpu: 2 + memory: 4Gi limits: - memory: 1Gi + cpu: 4 + memory: 4Gi master: service: @@ -148,9 +135,26 @@ master: # See https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#update-strategies updateStrategyType: "RollingUpdate" - pdb: - enabled: false - minAvailable: 1 + # Own control over persistent volumes. + # Normally this would hold non arbitrary values that are templated, + # but since Minecraft can have other worlds, we decided not to. + persistent: + # Defines Volumes (https://kubernetes.io/docs/concepts/storage/volume) to be linked to the master. + # Persists all the files synced to the master. + volumeMounts: + - name: "data" + mountPath: "/multipaper/plugins/multipaper-velocity/world" + # Template for Persistent Volume Claims (https://kubernetes.io/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims) + # This setup automatically creates Persistent Volumes for you, if no Persistent Volume is found. + claimTemplates: + - metadata: + name: "data" + spec: + accessModes: [ "ReadWriteOnce" ] + storageClassName: null + resources: + requests: + storage: "30Gi" resources: {} # resources: @@ -169,7 +173,7 @@ master: # Section for startup, readiness and liveness probes probes: - + # Probe used to weed out slow pods startupProbe: enabled: true From 093c4082087536043da40167d63cef8cc4512ff8 Mon Sep 17 00:00:00 2001 From: RemcoDev <106870142+RemcoSpigot@users.noreply.github.com> Date: Tue, 14 Jun 2022 23:05:58 +0200 Subject: [PATCH 5/6] Change master service name for velocity --- .../{velocity-service.yaml => velocity-master-service.yaml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename templates/{velocity-service.yaml => velocity-master-service.yaml} (87%) diff --git a/templates/velocity-service.yaml b/templates/velocity-master-service.yaml similarity index 87% rename from templates/velocity-service.yaml rename to templates/velocity-master-service.yaml index a0bf3e1..a160d9e 100644 --- a/templates/velocity-service.yaml +++ b/templates/velocity-master-service.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: Service metadata: - name: {{ template "multipaper-helm.fullname" . }}-velocity + name: {{ template "multipaper-helm.fullname" . }}-velocity-master labels: {{- include "multipaper-helm.velocity.labels" . | nindent 4 }} spec: From af4206903c95504419add4b6fbeba68e3f42207c Mon Sep 17 00:00:00 2001 From: RemcoDev <106870142+RemcoSpigot@users.noreply.github.com> Date: Wed, 22 Jun 2022 00:31:10 +0200 Subject: [PATCH 6/6] Use consistent bungeecordName when velocity is enabled --- templates/multipaper-config-configmap.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/multipaper-config-configmap.yaml b/templates/multipaper-config-configmap.yaml index 98e3fc3..3879948 100644 --- a/templates/multipaper-config-configmap.yaml +++ b/templates/multipaper-config-configmap.yaml @@ -30,7 +30,7 @@ data: filesToNotSync: - plugins/bStats {{- if .Values.velocity.enabled }} - bungeecordName: $HOSTNAME - {{- else }} bungeecordName: {{ template "multipaper-helm.fullname" . }} + {{- else }} + bungeecordName: $HOSTNAME {{- end }}