diff --git a/CHANGELOG.md b/CHANGELOG.md index a75e860..5dbc24a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ ## Changelog +### V2.2.0 + +#### Non-Breaking Changes + +- Added support for [nekomeowww/factorio-rcon-api](https://github.com/nekomeowww/factorio-rcon-api) including corresponding fields for values.yaml + ### V2.1.0 #### Non-Breaking Changes diff --git a/charts/factorio-server-charts/Chart.yaml b/charts/factorio-server-charts/Chart.yaml index dae0ccc..057c278 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.1.0 +version: 2.2.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 f320dfb..8532aa6 100644 --- a/charts/factorio-server-charts/templates/deployment.yaml +++ b/charts/factorio-server-charts/templates/deployment.yaml @@ -121,7 +121,7 @@ spec: mountPath: /factorio - name: {{ template "factorio-server-charts.fullname" . }}-save-importer-configmap mountPath: /scripts - {{- end }} + {{- end }} containers: - name: {{ template "factorio-server-charts.fullname" . }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" @@ -143,7 +143,7 @@ spec: - name: factorio containerPort: {{ .Values.factorioServer.port }} protocol: UDP - - containerPort: 27015 + - containerPort: {{ .Values.factorioServer.rcon_port }} protocol: TCP resources: {{ toYaml .Values.resources | indent 10 }} @@ -173,6 +173,8 @@ spec: value: /factorio/configs - name: PORT value: {{ .Values.factorioServer.port | quote }} + - name: RCON_PORT + value: {{ .Values.factorioServer.rcon_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 }}" @@ -206,6 +208,34 @@ spec: - pingpong3.factorio.com - pingpong4.factorio.com {{- end }} +{{- if .Values.rconAPI.enabled }} + - name: {{ template "factorio-server-charts.fullname" . }}-rcon-api + image: "{{ .Values.rconAPI.image.repository }}:{{ .Values.rconAPI.image.tag }}" + imagePullPolicy: {{ .Values.rconAPI.image.pullPolicy }} + livenessProbe: + httpGet: + path: /healthz + port: rcon-api + - name: rcon-api + containerPort: 24180 + protocol: TCP + - containerPort: 24181 + protocol: TCP + env: + - name: FACTORIO_RCON_HOST + value: "localhost" + - name: FACTORIO_RCON_PORT + value: {{ .Values.factorioServer.rcon_port | quote }} + - name: FACTORIO_RCON_PASSWORD + {{- if .Values.rcon.passwordSecret }} + valueFrom: + secretKeyRef: + name: {{ .Values.rcon.passwordSecret }} + key: rconpw + {{- else }} + value: {{ .Values.rcon.password | quote }} + {{- end }} +{{- end }} {{- if .Values.nodeSelector }} nodeSelector: {{ toYaml .Values.nodeSelector | indent 8 }} diff --git a/charts/factorio-server-charts/templates/rcon-api-ingress.yaml b/charts/factorio-server-charts/templates/rcon-api-ingress.yaml new file mode 100644 index 0000000..51781bf --- /dev/null +++ b/charts/factorio-server-charts/templates/rcon-api-ingress.yaml @@ -0,0 +1,41 @@ +{{- if and .Values.rconAPI.enabled .Values.rconAPI.ingress.enabled }} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ template "factorio-server-charts.fullname" . }}-rcon-api + annotations: + {{- range $key, $value := .Values.rconAPI.ingress.annotations }} + {{ $key }}: {{ $value | quote }} + {{- end }} + labels: + app: {{ template "factorio-server-charts.fullname" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +spec: + ingressClassName: {{ .Values.rconAPI.ingress.className }} + rules: + - host: {{ .Values.rconAPI.ingress.hostname }} + http: + paths: + - backend: + service: + name: {{ template "factorio-server-charts.fullname" . }}-rcon-api + port: + number: {{ .Values.rconAPI.httpPort }} + path: / + pathType: Prefix + - backend: + service: + name: {{ template "factorio-server-charts.fullname" . }}-rcon-api + port: + number: {{ .Values.rconAPI.grpcPort }} + path: /grpc + pathType: Prefix + {{- if and .Values.rconAPI.ingress.tls.enabled .Values.rconAPI.ingress.tls.secretName }} + tls: + - hosts: + - {{ .Values.rconAPI.ingress.hostname }} + secretName: {{ .Values.rconAPI.ingress.tls.secretName }} + {{- end }} +{{- end }} diff --git a/charts/factorio-server-charts/templates/rcon-api-service.yaml b/charts/factorio-server-charts/templates/rcon-api-service.yaml new file mode 100644 index 0000000..d7c4684 --- /dev/null +++ b/charts/factorio-server-charts/templates/rcon-api-service.yaml @@ -0,0 +1,34 @@ +{{- if .Values.rconAPI.enabled }} +apiVersion: v1 +kind: Service +metadata: + name: {{ template "factorio-server-charts.fullname" . }}-rcon-api + labels: + app: {{ template "factorio-server-charts.fullname" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" + annotations: + {{- range $key, $value := .Values.rconAPI.serviceAnnotations }} + {{ $key }}: {{ $value | quote }} + {{- end }} +spec: + type: {{ .Values.rconAPI.type }} + ports: + - name: http + port: {{ .Values.rconAPI.httpPort }} + targetPort: 24180 + {{- if eq .Values.rconAPI.type "NodePort" }} + nodePort: {{ .Values.rconAPI.httpPort }} + {{- end }} + protocol: TCP + - name: grpc + port: {{ .Values.rconAPI.grpcPort }} + targetPort: 24181 + {{- if eq .Values.rconAPI.type "NodePort" }} + nodePort: {{ .Values.rconAPI.grpcPort }} + {{- end }} + protocol: TCP + selector: + app: {{ template "factorio-server-charts.fullname" . }} +{{- end }} diff --git a/charts/factorio-server-charts/templates/rcon-service.yaml b/charts/factorio-server-charts/templates/rcon-service.yaml index 248e184..74ff326 100644 --- a/charts/factorio-server-charts/templates/rcon-service.yaml +++ b/charts/factorio-server-charts/templates/rcon-service.yaml @@ -17,7 +17,7 @@ spec: ports: - name: rcon port: {{ .Values.rcon.port }} - targetPort: 27015 + targetPort: {{ .Values.factorioServer.rcon_port }} {{- if eq .Values.rcon.type "NodePort" }} nodePort: {{ .Values.rcon.port}} {{- end }} diff --git a/charts/factorio-server-charts/values.yaml b/charts/factorio-server-charts/values.yaml index cd6917c..6df23a6 100644 --- a/charts/factorio-server-charts/values.yaml +++ b/charts/factorio-server-charts/values.yaml @@ -149,6 +149,7 @@ mods: ## @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 +## @param factorioServer.rcon_port Factorio Server RCON port factorioServer: # name to use for the save file save_name: "replaceMe" @@ -165,6 +166,10 @@ factorioServer: # 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 + # factorio game rcon port + # 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 rcon server port where you connect to it, update the "rcon.port" value accordingly. + rcon_port: 27015 import_save: # enable save importer @@ -322,7 +327,7 @@ port_fixer: ## @param rcon.external Enable RCON external access (deploy RCON service) ## @param rcon.type RCON service type ## @param rcon.serviceAnnotations RCON service annotations -## @param rcon.passwordSecret Existing secret containing a `password` data field +## @param rcon.passwordSecret Existing secret containing a `rconpw` data field ## @param rcon.password Password for RCON, ignored if `rcon.passwordSecret` is set ## @param rcon.port RCON service external port # Password and port for the rcon service @@ -330,7 +335,7 @@ rcon: external: true type: LoadBalancer serviceAnnotations: {} - # Existing secret containing a `password` data field + # Existing secret containing a `rconpw` data field passwordSecret: "" # Password for rcon @@ -339,6 +344,42 @@ rcon: # rcon port port: 30100 +## @param rconAPI.enabled Enable or disable the RCON API service +## @param rconAPI.image.repository RCON-API image repository +## @param rconAPI.image.tag RCON-API image tag (immutable tags are recommended) +## @param rconAPI.image.pullPolicy RCON-API image pull policy +## @param rconAPI.type Kubernetes service type for the RCON API (e.g., ClusterIP, NodePort, LoadBalancer) +## @param rconAPI.serviceAnnotations Annotations to add to the RCON API service +## @param rconAPI.httpPort Internal port on which the HTTP API for RCON is exposed +## @param rconAPI.grpcPort Internal port on which the gRPC API for RCON is exposed +## @param rconAPI.ingress.enabled Enable or disable the Ingress for the RCON API service +## @param rconAPI.ingress.hostname Hostname for the RCON API Ingress +## @param rconAPI.ingress.className Ingress class name for selecting the Ingress controller (e.g., nginx, cilium) +## @param rconAPI.ingress.annotations Additional annotations for the Ingress resource +## @param rconAPI.ingress.tls.enabled Enable or disable TLS for the Ingress +## @param rconAPI.ingress.tls.secretName Kubernetes Secret name for TLS certificates used by the Ingress +rconAPI: + enabled: false + image: + repository: "ghcr.io/nekomeowww/factorio-rcon-api" + pullPolicy: Always + tag: latest + type: ClusterIP + serviceAnnotations: {} + httpPort: 30110 + grpcPort: 30111 + + ingress: + enabled: true + hostname: "factorio.example.com" + className: "nginx" + annotations: + nginx.ingress.kubernetes.io/ssl-redirect: "true" + nginx.ingress.kubernetes.io/backend-protocol: "GRPC" + tls: + enabled: false + secretName: "cert-factorio.example.com" + ## @param map_gen_settings.width Map width in tiles; 0 means infinite ## @param map_gen_settings.height Map height in tiles; 0 means infinite ## @param map_gen_settings.starting_area Multiplier for biter free zone radius