Skip to content

Commit

Permalink
feat: added tunnel for headless clients and makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
fbuchmeier committed Nov 3, 2022
1 parent 20080a5 commit 3450b16
Show file tree
Hide file tree
Showing 20 changed files with 5,254 additions and 157 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target/*
2 changes: 2 additions & 0 deletions .helmignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
docs/*
test-values/*
staging/*
target/
Makefile
2 changes: 1 addition & 1 deletion Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type: application
# 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: 0.4.0
version: 0.5.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
38 changes: 38 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
define validate =
set -e
for v in $(find ./test-values -name "*.yaml") ; do
helm template -f ${v} . | kubeconform
echo "✓ Validating chart with ${v}"
done
endef

define snapshot =
set -e
mkdir -p test-fixtures
for v in $(find ./test-values -name "*.yaml") ; do
helm template -f ${v} . > ./test-fixtures/$(basename ${v})
echo "✓ Updating snapshot for ${v}"
done
endef

define test =
set -e
for v in $(find ./test-values -name "*.yaml") ; do
helm template -f ${v} . | diff - ./test-fixtures/$(basename ${v})
echo "✓ Diffing ${v} with ./test-fixtures/$(basename ${v})"
done
endef

.SILENT: validate package snapshot test

.ONESHELL:

validate: ; $(value validate)

package: validate
mkdir -p target
helm package --dependency-update --destination target/ .

snapshot: validate ; $(value snapshot)

test: ; $(value test)
74 changes: 0 additions & 74 deletions staging/arma3-baboon-deploy.yaml

This file was deleted.

20 changes: 0 additions & 20 deletions staging/arma3-baboon-headlessclient.yaml

This file was deleted.

45 changes: 0 additions & 45 deletions staging/arma3-envoy-baboon-svc.yaml

This file was deleted.

12 changes: 12 additions & 0 deletions templates/configmap-headlessclient.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "arma3.fullname" . }}-headlessclient
labels:
{{- include "arma3.labels" . | nindent 4 }}
{{- with .Values.deploymentAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
data:
# TODO The profile name == the container name
{{ .Values.headlessclient.name }}.Arma3Profile: |-
Expand All @@ -14,6 +20,12 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "arma3.fullname" . }}-headlessclient-env
labels:
{{- include "arma3.labels" . | nindent 4 }}
{{- with .Values.deploymentAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
data:
ARMA_LIMITFPS: "100"
{{- with .Values.config.env }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# TODO: Can this go into one "cluster" config?
# TODO: Can this go into one "listener" config?
{{- if .Values.headlessclient.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "arma3.fullname" . }}-tunnel
labels:
{{- include "arma3.labels" . | nindent 4 }}
{{- with .Values.deploymentAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
data:
envoy.yaml: |
admin:
Expand Down Expand Up @@ -162,10 +172,4 @@ data:
socket_address:
address: 127.0.0.1
port_value: 2306
kind: ConfigMap
metadata:
creationTimestamp: "2022-11-02T21:30:07Z"
name: arma3-envoy-baboon
namespace: game-servers
resourceVersion: "39076310"
uid: 5fd02a1c-92fd-4b48-8225-9eb49c674352
{{- end }}
12 changes: 12 additions & 0 deletions templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "arma3.fullname" . }}
labels:
{{- include "arma3.labels" . | nindent 4 }}
{{- with .Values.deploymentAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
data:
main.cfg: |-
// GENERAL SETTINGS
Expand Down Expand Up @@ -29,6 +35,12 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "arma3.fullname" . }}-env
labels:
{{- include "arma3.labels" . | nindent 4 }}
{{- with .Values.deploymentAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
data:
ARMA_CONFIG: main.cfg
ARMA_LIMITFPS: "100"
Expand Down
28 changes: 28 additions & 0 deletions templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,28 @@ spec:
mountPath: /opt/rsyncd
readOnly: false
{{- end }}
{{- if .Values.headlessclient.enabled }}
- name: tunnel
image: "{{ .Values.tunnel.image.repository }}:{{ .Values.tunnel.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: 2502
protocol: UDP
- containerPort: 2503
protocol: UDP
- containerPort: 2504
protocol: UDP
- containerPort: 2505
protocol: UDP
- containerPort: 2506
protocol: UDP
resources:
{{- toYaml .Values.tunnel.resources | nindent 12 }}
volumeMounts:
- mountPath: /etc/envoy
name: envoy-config
readOnly: true
{{- end }}
- name: server
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
Expand Down Expand Up @@ -195,6 +217,12 @@ spec:
emptyDir: {}
- name: steamcmd
emptyDir: {}
{{- if .Values.headlessclient.enabled }}
- name: envoy-config
configMap:
defaultMode: 420
name: {{ include "arma3.fullname" . }}-tunnel
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand Down
2 changes: 1 addition & 1 deletion templates/headlessclient.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ spec:
- name: SKIP_INSTALL
value: "true"
- name: ARMA_PARAMS
value: -client -connect={{ include "arma3.fullname" . }} -password={{ include "serverPassword" . }} -nosound -name={{ .Values.headlessclient.name }}
value: -client -connect={{ include "arma3.fullname" . }}-tunnel -password={{ include "serverPassword" . }} -nosound -name={{ .Values.headlessclient.name }}
{{- if .Values.config.env.MODS_PRESET }}
- name: MODS_PRESET
value: {{ .Values.config.env.MODS_PRESET }}
Expand Down
39 changes: 39 additions & 0 deletions templates/service-tunnel.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{{- if .Values.headlessclient.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "arma3.fullname" . }}-tunnel
labels:
{{- include "arma3.labels" . | nindent 4 }}
{{- with .Values.service.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
ports:
- name: udp-1
port: 2302
targetPort: 2302
protocol: UDP
- name: udp-2
port: 2303
targetPort: 2303
protocol: UDP
- name: upd-3
port: 2304
targetPort: 2304
protocol: UDP
- name: upd-4
port: 2305
targetPort: 2305
protocol: UDP
- name: upd-5
port: 2306
targetPort: 2306
protocol: UDP
selector:
{{- include "arma3.selectorLabels" . | nindent 4 }}
app.kubernetes.io/component: server
sessionAffinity: None
type: ClusterIP
{{- end }}
Loading

0 comments on commit 3450b16

Please sign in to comment.