feat: add valheim chart and argo app
Some checks failed
checks / pre-commit (push) Failing after 30s
checks / k8s (push) Failing after 31s
checks / tflint (push) Failing after 31s
OpenTofu deployments / adguard (push) Failing after 30s
OpenTofu deployments / authentik (push) Failing after 30s

This commit is contained in:
cătălin 2025-04-01 19:24:08 +02:00
commit 4b60b6b8ad
No known key found for this signature in database
15 changed files with 1048 additions and 3 deletions

View file

@ -0,0 +1,40 @@
Thank you for installing the Valheim Dedicated Server Helm chart!
Your server should be starting up now with the following settings:
Server Name: {{ .Values.server.name }}
World: {{ .Values.server.world }}
Game Port: {{ .Values.server.port }} (UDP)
{{- if eq .Values.service.type "LoadBalancer" }}
To connect to your server:
1. Get the external IP address:
kubectl get svc {{ include "valheim-server.fullname" . }} --namespace {{ .Release.Namespace }}
2. In Valheim, select "Join Game" and add the server manually using:
<EXTERNAL-IP>:{{ .Values.server.port }}
3. Enter your server password when prompted.
{{- else if eq .Values.service.type "NodePort" }}
To connect to your server:
1. Get the NodePort assigned to your service:
kubectl get svc {{ include "valheim-server.fullname" . }} --namespace {{ .Release.Namespace }}
2. In Valheim, select "Join Game" and add the server manually using:
<NODE-IP>:<NODEPORT>
3. Enter your server password when prompted.
{{- else }}
Note: You've deployed with service type "{{ .Values.service.type }}" which may not be accessible from outside the cluster.
You might need to set up port forwarding or ingress to access your server.
{{- end }}
IMPORTANT SECURITY NOTES:
- Make sure your server password is at least 5 characters long
- Properly secure access to your Kubernetes cluster
- Consider changing the default port if your server is public
For more information and troubleshooting, please visit:
{{ .Chart.Home }}

View file

@ -0,0 +1,51 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "valheim-server.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "valheim-server.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "valheim-server.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Common labels
*/}}
{{- define "valheim-server.labels" -}}
helm.sh/chart: {{ include "valheim-server.chart" . }}
{{ include "valheim-server.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "valheim-server.selectorLabels" -}}
app.kubernetes.io/name: {{ include "valheim-server.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

View file

@ -0,0 +1,208 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "valheim-server.fullname" . }}
labels:
{{- include "valheim-server.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "valheim-server.selectorLabels" . | nindent 6 }}
strategy:
type: Recreate
template:
metadata:
labels:
{{- include "valheim-server.selectorLabels" . | nindent 8 }}
spec:
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- if .Values.initContainers.enabled }}
initContainers:
- name: init-valheim
image: {{ .Values.initContainers.image }}
{{- if .Values.initContainers.command }}
command: {{ toYaml .Values.initContainers.command | nindent 12 }}
{{- end }}
{{- if .Values.initContainers.args }}
args: {{ toYaml .Values.initContainers.args | nindent 12 }}
{{- end }}
volumeMounts:
- name: saves
mountPath: /home/steam/.config/unity3d/IronGate/Valheim
- name: server
mountPath: /home/steam/valheim
- name: backups
mountPath: /home/steam/backups
{{- end }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: PORT
value: "{{ .Values.server.port }}"
- name: NAME
value: "{{ .Values.server.name }}"
- name: WORLD
value: "{{ .Values.server.world }}"
- name: PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.secret.name }}
key: {{ .Values.secret.key }}
- name: TZ
value: "{{ .Values.server.timezone }}"
- name: PUID
value: "{{ .Values.securityContext.runAsUser | default "111" }}"
- name: PGID
value: "{{ .Values.securityContext.runAsGroup | default "1000" }}"
- name: PUBLIC
value: "{{ .Values.server.public }}"
- name: AUTO_UPDATE
value: "{{ .Values.automation.autoUpdate }}"
- name: AUTO_UPDATE_SCHEDULE
value: "{{ .Values.automation.autoUpdateSchedule }}"
- name: UPDATE_ON_STARTUP
value: "{{ .Values.automation.updateOnStartup }}"
- name: AUTO_BACKUP
value: "{{ .Values.automation.autoBackup }}"
- name: AUTO_BACKUP_SCHEDULE
value: "{{ .Values.automation.autoBackupSchedule }}"
- name: AUTO_BACKUP_REMOVE_OLD
value: "{{ .Values.automation.autoBackupRemoveOld }}"
- name: AUTO_BACKUP_DAYS_TO_LIVE
value: "{{ .Values.automation.autoBackupDaysToLive }}"
- name: AUTO_BACKUP_ON_UPDATE
value: "{{ .Values.automation.autoBackupOnUpdate }}"
- name: AUTO_BACKUP_ON_SHUTDOWN
value: "{{ .Values.automation.autoBackupOnShutdown }}"
{{- if .Values.notifications.webhookUrl }}
- name: WEBHOOK_URL
value: "{{ .Values.notifications.webhookUrl }}"
- name: WEBHOOK_INCLUDE_PUBLIC_IP
value: "{{ .Values.notifications.includePublicIp }}"
{{- end }}
{{- if eq (.Values.modding.bepInEx | toString) "1" }}
- name: BEPINEX
value: "1"
{{- end }}
{{- with .Values.extraEnv }}
{{- toYaml . | nindent 12 }}
{{- end }}
ports:
- name: game
containerPort: {{ .Values.server.port }}
protocol: UDP
- name: game-1
containerPort: {{ add .Values.server.port 1 }}
protocol: UDP
- name: game-2
containerPort: {{ add .Values.server.port 2 }}
protocol: UDP
lifecycle:
preStop:
exec:
command: [ "/bin/sh", "-c", "kill -SIGINT 1 && sleep 5" ]
volumeMounts:
- name: saves
mountPath: /home/steam/.config/unity3d/IronGate/Valheim
- name: server
mountPath: /home/steam/valheim
- name: backups
mountPath: /home/steam/backups
{{- if eq (.Values.modding.bepInEx | toString) "1" }}
- name: mods
mountPath: {{ .Values.modding.modPath }}
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
# Startup probe - wait for server to initialize
{{- if .Values.startupProbe.enabled }}
startupProbe:
exec:
command:
- pgrep
- -f
- valheim_server
initialDelaySeconds: {{ .Values.startupProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.startupProbe.periodSeconds }}
timeoutSeconds: {{ .Values.startupProbe.timeoutSeconds }}
failureThreshold: {{ .Values.startupProbe.failureThreshold }}
{{- end }}
# Readiness probe - verify is server is ready
{{- if .Values.readinessProbe.enabled }}
readinessProbe:
exec:
command:
- pgrep
- -f
- valheim_server
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
{{- end }}
# Liveness probe - check if server is running
{{- if .Values.livenessProbe.enabled }}
livenessProbe:
exec:
command:
- pgrep
- -f
- valheim_server
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
{{- end }}
volumes:
- name: saves
{{- if and .Values.persistence.enabled .Values.persistence.saves.existingClaim }}
persistentVolumeClaim:
claimName: {{ .Values.persistence.saves.existingClaim }}
{{- else if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ include "valheim-server.fullname" . }}-saves
{{- else }}
emptyDir: { }
{{- end }}
- name: server
{{- if and .Values.persistence.enabled .Values.persistence.server.existingClaim }}
persistentVolumeClaim:
claimName: {{ .Values.persistence.server.existingClaim }}
{{- else if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ include "valheim-server.fullname" . }}-server
{{- else }}
emptyDir: { }
{{- end }}
- name: backups
{{- if and .Values.persistence.enabled .Values.persistence.backups.existingClaim }}
persistentVolumeClaim:
claimName: {{ .Values.persistence.backups.existingClaim }}
{{- else if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ include "valheim-server.fullname" . }}-backups
{{- else }}
emptyDir: { }
{{- end }}
{{- if eq (.Values.modding.bepInEx | toString) "1" }}
- name: mods
emptyDir: { }
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}

View file

@ -0,0 +1,67 @@
{{- if and .Values.persistence.enabled (not .Values.persistence.saves.existingClaim) }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ include "valheim-server.fullname" . }}-saves
labels:
{{- include "valheim-server.labels" . | nindent 4 }}
spec:
accessModes:
- {{ .Values.persistence.saves.accessMode }}
{{- if .Values.persistence.storageClass }}
{{- if (eq "-" .Values.persistence.storageClass) }}
storageClassName: ""
{{- else }}
storageClassName: "{{ .Values.persistence.storageClass }}"
{{- end }}
{{- end }}
resources:
requests:
storage: {{ .Values.persistence.saves.size }}
{{- end }}
{{- if and .Values.persistence.enabled (not .Values.persistence.server.existingClaim) }}
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ include "valheim-server.fullname" . }}-server
labels:
{{- include "valheim-server.labels" . | nindent 4 }}
spec:
accessModes:
- {{ .Values.persistence.server.accessMode }}
{{- if .Values.persistence.storageClass }}
{{- if (eq "-" .Values.persistence.storageClass) }}
storageClassName: ""
{{- else }}
storageClassName: "{{ .Values.persistence.storageClass }}"
{{- end }}
{{- end }}
resources:
requests:
storage: {{ .Values.persistence.server.size }}
{{- end }}
{{- if and .Values.persistence.enabled (not .Values.persistence.backups.existingClaim) }}
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ include "valheim-server.fullname" . }}-backups
labels:
{{- include "valheim-server.labels" . | nindent 4 }}
spec:
accessModes:
- {{ .Values.persistence.backups.accessMode }}
{{- if .Values.persistence.storageClass }}
{{- if (eq "-" .Values.persistence.storageClass) }}
storageClassName: ""
{{- else }}
storageClassName: "{{ .Values.persistence.storageClass }}"
{{- end }}
{{- end }}
resources:
requests:
storage: {{ .Values.persistence.backups.size }}
{{- end }}

View file

@ -0,0 +1,34 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "valheim-server.fullname" . }}
labels:
{{- include "valheim-server.labels" . | nindent 4 }}
{{- with .Values.service.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.service.type }}
{{- if and (eq .Values.service.type "LoadBalancer") .Values.service.loadBalancerIP }}
loadBalancerIP: {{ .Values.service.loadBalancerIP }}
{{- end }}
{{- if and (eq .Values.service.type "LoadBalancer") .Values.service.loadBalancerSourceRanges }}
loadBalancerSourceRanges:
{{- toYaml .Values.service.loadBalancerSourceRanges | nindent 4 }}
{{- end }}
ports:
- port: {{ .Values.server.port }}
targetPort: game
protocol: UDP
name: game
- port: {{ add .Values.server.port 1 }}
targetPort: game-1
protocol: UDP
name: game-1
- port: {{ add .Values.server.port 2 }}
targetPort: game-2
protocol: UDP
name: game-2
selector:
{{- include "valheim-server.selectorLabels" . | nindent 4 }}