Skip to content

add rcon-rest-api container #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Nov 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion charts/factorio-server-charts/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 32 additions & 2 deletions charts/factorio-server-charts/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand All @@ -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 }}
Expand Down Expand Up @@ -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 }}"
Expand Down Expand Up @@ -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 }}
Expand Down
41 changes: 41 additions & 0 deletions charts/factorio-server-charts/templates/rcon-api-ingress.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
34 changes: 34 additions & 0 deletions charts/factorio-server-charts/templates/rcon-api-service.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
45 changes: 43 additions & 2 deletions charts/factorio-server-charts/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -322,15 +327,15 @@ 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
rcon:
external: true
type: LoadBalancer
serviceAnnotations: {}
# Existing secret containing a `password` data field
# Existing secret containing a `rconpw` data field
passwordSecret: ""

# Password for rcon
Expand All @@ -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
Expand Down
Loading