diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl index 01b0f2d..98d568e 100644 --- a/templates/_helpers.tpl +++ b/templates/_helpers.tpl @@ -77,4 +77,42 @@ 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 }} + +{{/* +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/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-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 2120b32..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: @@ -33,9 +34,11 @@ spec: - 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: @@ -67,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..3879948 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" . }}-velocity-master:{{ .Values.velocity.master.service.targetPort }} + {{- else }} multipaperMasterAddress: {{ template "multipaper-helm.fullname" . }}-master:{{ .Values.master.service.targetPort }} - advertiseToBuiltInProxy: {{ .Values.master.proxy.enabled }} + {{- end }} + advertiseToBuiltInProxy: {{ .Values.velocity.enabled }} filesToSyncOnStartup: filesToSyncInRealTime: filesToOnlyUploadOnServerStop: @@ -25,4 +29,8 @@ data: syncJsonFiles: false filesToNotSync: - plugins/bStats + {{- if .Values.velocity.enabled }} + bungeecordName: {{ template "multipaper-helm.fullname" . }} + {{- else }} bungeecordName: $HOSTNAME + {{- 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 new file mode 100644 index 0000000..a9e51c6 --- /dev/null +++ b/templates/velocity-configmap.yaml @@ -0,0 +1,116 @@ +{{- 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: | + # 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 = " 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 + # 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 = "modern" + # If you are using modern or BungeeGuard IP forwarding, configure a unique secret here. + 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. + # + # 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. + {{ 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 = [{{- 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 + # 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-master-service.yaml b/templates/velocity-master-service.yaml new file mode 100644 index 0000000..a160d9e --- /dev/null +++ b/templates/velocity-master-service.yaml @@ -0,0 +1,18 @@ +{{- if .Values.velocity.enabled }} +apiVersion: v1 +kind: Service +metadata: + name: {{ template "multipaper-helm.fullname" . }}-velocity-master + labels: + {{- include "multipaper-helm.velocity.labels" . | nindent 4 }} +spec: + type: ClusterIP + clusterIP: None + ports: + - port: {{ .Values.velocity.master.service.port }} + targetPort: {{ .Values.velocity.master.service.targetPort }} + protocol: TCP + name: master + selector: + {{- include "multipaper-helm.velocity.selectorLabels" . | nindent 4 }} +{{- end }} \ No newline at end of file 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-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-statefulset.yaml b/templates/velocity-statefulset.yaml new file mode 100644 index 0000000..4ecd9d5 --- /dev/null +++ b/templates/velocity-statefulset.yaml @@ -0,0 +1,77 @@ +{{- if .Values.velocity.enabled }} +apiVersion: apps/v1 +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 }} + 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: master + containerPort: {{ .Values.velocity.master.service.port }} + protocol: TCP + - name: proxy + containerPort: {{ .Values.velocity.proxy.service.port }} + protocol: TCP + volumeMounts: + - name: velocity-config + 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: + 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 }} + volumes: + - name: velocity-config + configMap: + name: {{ template "multipaper-helm.fullname" . }}-velocity + - 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 7808a6a..5d2861a 100644 --- a/values.yaml +++ b/values.yaml @@ -8,6 +8,100 @@ global: # When empty the full name of the Helm deployment would be used. name: "" +# 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. + 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: "remcospigot/velocity" + # Tag of the Docker image to be used. + # Defaults to the Chart's app version if left blank. + tag: "3.1.2-SNAPSHOT-153" + pullPolicy: Always + + resources: + requests: + cpu: 2 + memory: 4Gi + limits: + cpu: 4 + memory: 4Gi + + master: + service: + # Port on which the Velocity server is listening. + port: 35353 + # Target port to which the service should be mapped to. + targetPort: 35353 + + 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: + + # 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 +115,6 @@ master: # Built-in Proxy settings proxy: - enabled: true service: # Type can be ClusterIP or NodePort type: NodePort @@ -42,6 +135,27 @@ master: # See https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#update-strategies updateStrategyType: "RollingUpdate" + # 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: # requests: @@ -59,7 +173,7 @@ master: # Section for startup, readiness and liveness probes probes: - + # Probe used to weed out slow pods startupProbe: enabled: true @@ -98,27 +212,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: {}