From d364cdf602e64ca9bc732ccb6efbb56e897ab03d Mon Sep 17 00:00:00 2001 From: Kariton <67470612+Kariton@users.noreply.github.com> Date: Fri, 1 Nov 2024 08:09:05 +0100 Subject: [PATCH 1/2] squashed; add factorio-port-fixer --- CHANGELOG.md | 6 +++ charts/factorio-server-charts/Chart.yaml | 2 +- .../templates/deployment.yaml | 37 ++++++++++++++++++- .../templates/service.yaml | 2 +- charts/factorio-server-charts/values.yaml | 29 +++++++++++++++ 5 files changed, 73 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3fdef32..a75e860 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ ## Changelog +### V2.1.0 + +#### Non-Breaking Changes + +- Added support for [ZCube/factorio-port-fixer](https://github.com/ZCube/factorio-port-fixer) including corresponding fields for values.yaml + ### V2.0.4 #### Non-Breaking Changes diff --git a/charts/factorio-server-charts/Chart.yaml b/charts/factorio-server-charts/Chart.yaml index fa62915..dae0ccc 100644 --- a/charts/factorio-server-charts/Chart.yaml +++ b/charts/factorio-server-charts/Chart.yaml @@ -20,7 +20,7 @@ sources: # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 2.0.4 +version: 2.1.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/factorio-server-charts/templates/deployment.yaml b/charts/factorio-server-charts/templates/deployment.yaml index 23ded48..f320dfb 100644 --- a/charts/factorio-server-charts/templates/deployment.yaml +++ b/charts/factorio-server-charts/templates/deployment.yaml @@ -141,7 +141,7 @@ spec: failureThreshold: 3 ports: - name: factorio - containerPort: 34197 + containerPort: {{ .Values.factorioServer.port }} protocol: UDP - containerPort: 27015 protocol: TCP @@ -171,6 +171,41 @@ spec: value: {{ .Values.factorioServer.enable_space_age | quote }} - name: CONFIG value: /factorio/configs + - name: PORT + value: {{ .Values.factorioServer.port | quote }} +{{- if .Values.port_fixer.enabled }} + - name: {{ template "factorio-server-charts.fullname" . }}-port-fixer + image: "{{ .Values.port_fixer.image.repository }}:{{ .Values.port_fixer.image.tag }}" + imagePullPolicy: {{ .Values.port_fixer.image.pullPolicy }} + {{- with .Values.securityContext }} + securityContext: + {{- toYaml . | nindent 10 }} + {{- end }} + command: ["/factorio-port-fixer"] + args: + - local + - --ip=127.0.0.1 + - --port=34197 + - --remotePort={{ .Values.port_fixer.port | default .Values.service.port }} + livenessProbe: + httpGet: + path: /health + port: port-fixer + periodSeconds: 10 + initialDelaySeconds: 5 + failureThreshold: 3 + ports: + - name: port-fixer + containerPort: 34197 + protocol: TCP + hostAliases: + - ip: "127.0.0.1" + hostnames: + - pingpong1.factorio.com + - pingpong2.factorio.com + - pingpong3.factorio.com + - pingpong4.factorio.com +{{- end }} {{- if .Values.nodeSelector }} nodeSelector: {{ toYaml .Values.nodeSelector | indent 8 }} diff --git a/charts/factorio-server-charts/templates/service.yaml b/charts/factorio-server-charts/templates/service.yaml index 0314e0c..0c23d13 100644 --- a/charts/factorio-server-charts/templates/service.yaml +++ b/charts/factorio-server-charts/templates/service.yaml @@ -20,7 +20,7 @@ spec: {{- end }} ports: - name: factorio - targetPort: 34197 + targetPort: {{ .Values.factorioServer.port }} port: {{ .Values.service.port }} protocol: UDP {{- if eq .Values.service.type "NodePort" }} diff --git a/charts/factorio-server-charts/values.yaml b/charts/factorio-server-charts/values.yaml index ac6a91a..3439507 100644 --- a/charts/factorio-server-charts/values.yaml +++ b/charts/factorio-server-charts/values.yaml @@ -148,6 +148,7 @@ mods: ## @param factorioServer.generate_new_save Generate a new save if `save_name` is not found ## @param factorioServer.update_mods_on_start Update mods on server start ## @param factorioServer.load_latest_save Lets the game know if you want to load the latest save +## @param factorioServer.port Factorio Game Server port factorioServer: # name to use for the save file save_name: "replaceMe" @@ -159,6 +160,11 @@ factorioServer: load_latest_save: true # enables or disables the mods for DLC Space Age in mod-list.json enable_space_age: true + # factorio game server port + # the default game port (34197) has been changed to 31497 to resolve issues when using the port-fixer. + # this port setting is typically for internal Kubernetes configuration only, and in most cases, it does not need to be modified. + # if it is necessary to change the game server port where you connect to the game, update the "service.port" value accordingly. + port: 31497 import_save: # enable save importer @@ -290,6 +296,29 @@ server_settings: maximum_segment_size: 100 maximum_segment_size_peer_count: 10 +## @section Port-Fixer Parameters +## @param port_fixer.enabled Enable the Factorio Port Fixer +## @param image.repository Factorio port-fixer image repository +## @param image.tag Factorio port fixer image tag (immutable tags are recommended) +## @param image.pullPolicy Factorio port fixer image pull policy +## @param image.port Factorio port to announce via port-fixer, defaults to service.port +port_fixer: + # Adds an extra container that tries to help with connection issues via the public server browser. + # This is especially useful when you can’t set up outgoing static port mappings and see log messages like these: + # > Warning ServerRouter.cpp:541: Received own address message reply with conflicting address (got IP ADDR:({:19296}), expected IP ADDR:({:58037})) + # > Warning ServerMultiplayerManager.cpp:651: Determining own address has failed. Best guess: IP ADDR:({:58037}) + # > Warning ServerRouter.cpp:541: Received own address message reply with conflicting address (got IP ADDR:({:19297}), expected IP ADDR:({:58037})) + # > Warning ServerRouter.cpp:541: Received own address message reply with conflicting address (got IP ADDR:({:24105}), expected IP ADDR:({:58037})) + # Note: Port forwarding for incoming traffic still needs to be set up properly for this to work. + # For more info, check out: + # - https://github.com/SQLJames/factorio-server-charts/issues/15 + enabled: false + image: + repository: "ghcr.io/zcube/factorio-port-fixer" + pullPolicy: Always + tag: latest + # port: '34197' + ## @param rcon.external Enable RCON external access (deploy RCON service) ## @param rcon.type RCON service type ## @param rcon.serviceAnnotations RCON service annotations From 53421bc80f0f6397e96f44df04a85bd8fe316cc4 Mon Sep 17 00:00:00 2001 From: Kariton <67470612+Kariton@users.noreply.github.com> Date: Fri, 1 Nov 2024 08:13:44 +0100 Subject: [PATCH 2/2] port_fixer.port values.yaml entry corrected --- charts/factorio-server-charts/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/factorio-server-charts/values.yaml b/charts/factorio-server-charts/values.yaml index 3439507..cd6917c 100644 --- a/charts/factorio-server-charts/values.yaml +++ b/charts/factorio-server-charts/values.yaml @@ -317,7 +317,7 @@ port_fixer: repository: "ghcr.io/zcube/factorio-port-fixer" pullPolicy: Always tag: latest - # port: '34197' + port: '' ## @param rcon.external Enable RCON external access (deploy RCON service) ## @param rcon.type RCON service type