Add Helm chart to deploy Valheim dedicated server

StatefulSet with persistent world data, NodePort service for game/query/
crossplay ports, and secret for the server password.

Co-authored-by: Copilot <[email protected]>
This commit is contained in:
2026-09-18 19:34:51 +02:00
co-authored by Copilot
parent 5204de63d0
commit a62faa0d73
7 changed files with 297 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
apiVersion: v2
name: valheim
description: Helm chart to run a Valheim dedicated game server on Kubernetes
type: application
version: 0.1.0
appVersion: "latest"
home: https://git.smokyzone.de/SmokyZone/valheim-gitops
sources:
- https://git.smokyzone.de/SmokyZone/valheim-gitops
keywords:
- valheim
- gameserver
maintainers:
- name: SmokyZone
+43
View File
@@ -0,0 +1,43 @@
# valheim-gitops
Helm chart to run a [Valheim](https://www.valheimgame.com/) dedicated server on Kubernetes,
using the community [`lloesche/valheim-server`](https://github.com/lloesche/valheim-server-docker)
image.
## What's included
- **Namespace** (`valheim` by default, toggle with `namespace.create`)
- **StatefulSet** running the game server with a persistent volume for world data
(`/config` and `/opt/valheim`) so the world survives restarts/upgrades
- **Secret** holding the server join password (`SERVER_PASS`)
- **Service** (`NodePort` by default) exposing the game (2456/udp), query (2457/udp)
and crossplay (2458/udp) ports
- Headless **Service** for the StatefulSet
## Configuration
See [`values.yaml`](values.yaml) for all options. Important ones:
| Key | Description | Default |
|---|---|---|
| `server.name` | Server name shown in the browser | `Valtersheim` |
| `server.worldName` | World save name | `Midgard` |
| `server.password` | Join password (override via `-f secret-values.yaml`, never commit real passwords) | `changeme-please-override` |
| `service.type` | `NodePort` or `LoadBalancer` | `NodePort` |
| `persistence.storageClassName` | StorageClass for world data, empty = cluster default | `""` |
| `persistence.size` | Size of the world data volume | `10Gi` |
## Usage
```sh
helm upgrade --install valheim . -n valheim --create-namespace \
--set server.password=<your-password>
```
### Deploying via ArgoCD
This repository is intended to be deployed as an ArgoCD `Application` using this
chart as the Helm source (see `apps-in-apps` repo for the bootstrap Application).
> Never commit real passwords in `values.yaml`. Use `--set`, a separate values file
> excluded from git, or a secrets manager (SealedSecrets/ExternalSecrets) for production.
+9
View File
@@ -0,0 +1,9 @@
{{- if .Values.namespace.create }}
apiVersion: v1
kind: Namespace
metadata:
name: {{ .Values.namespace.name }}
labels:
app.kubernetes.io/name: valheim
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
+10
View File
@@ -0,0 +1,10 @@
apiVersion: v1
kind: Secret
metadata:
name: valheim-server
namespace: {{ .Values.namespace.name }}
labels:
app.kubernetes.io/name: valheim
type: Opaque
stringData:
SERVER_PASS: {{ .Values.server.password | quote }}
+49
View File
@@ -0,0 +1,49 @@
apiVersion: v1
kind: Service
metadata:
name: valheim-headless
namespace: {{ .Values.namespace.name }}
labels:
app.kubernetes.io/name: valheim
spec:
clusterIP: None
selector:
app.kubernetes.io/name: valheim
ports:
- name: game
port: {{ .Values.service.gamePort }}
protocol: UDP
---
apiVersion: v1
kind: Service
metadata:
name: valheim
namespace: {{ .Values.namespace.name }}
labels:
app.kubernetes.io/name: valheim
spec:
type: {{ .Values.service.type }}
selector:
app.kubernetes.io/name: valheim
ports:
- name: game
port: {{ .Values.service.gamePort }}
targetPort: {{ .Values.service.gamePort }}
protocol: UDP
{{- if and (eq .Values.service.type "NodePort") .Values.service.nodePorts.game }}
nodePort: {{ .Values.service.nodePorts.game }}
{{- end }}
- name: query
port: {{ .Values.service.queryPort }}
targetPort: {{ .Values.service.queryPort }}
protocol: UDP
{{- if and (eq .Values.service.type "NodePort") .Values.service.nodePorts.query }}
nodePort: {{ .Values.service.nodePorts.query }}
{{- end }}
- name: crossplay
port: {{ .Values.service.crossplayPort }}
targetPort: {{ .Values.service.crossplayPort }}
protocol: UDP
{{- if and (eq .Values.service.type "NodePort") .Values.service.nodePorts.crossplay }}
nodePort: {{ .Values.service.nodePorts.crossplay }}
{{- end }}
+106
View File
@@ -0,0 +1,106 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: valheim
namespace: {{ .Values.namespace.name }}
labels:
app.kubernetes.io/name: valheim
spec:
serviceName: valheim-headless
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: valheim
template:
metadata:
labels:
app.kubernetes.io/name: valheim
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
securityContext:
{{- toYaml .Values.securityContext | nindent 8 }}
containers:
- name: valheim-server
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: game
containerPort: {{ .Values.service.gamePort }}
protocol: UDP
- name: query
containerPort: {{ .Values.service.queryPort }}
protocol: UDP
- name: crossplay
containerPort: {{ .Values.service.crossplayPort }}
protocol: UDP
env:
- name: SERVER_NAME
value: {{ .Values.server.name | quote }}
- name: WORLD_NAME
value: {{ .Values.server.worldName | quote }}
- name: SERVER_PASS
valueFrom:
secretKeyRef:
name: valheim-server
key: SERVER_PASS
- name: SERVER_PUBLIC
value: {{ .Values.server.public | ternary "1" "0" | quote }}
{{- if .Values.server.admins }}
- name: ADMINLIST_IDS
value: {{ .Values.server.admins | quote }}
{{- end }}
- name: UPDATE_INTERVAL
value: {{ .Values.server.updateIntervalSeconds | quote }}
- name: BACKUPS_INTERVAL
value: {{ .Values.server.backupIntervalSeconds | quote }}
{{- if .Values.server.backupCronExpression }}
- name: BACKUPS_CRON
value: {{ .Values.server.backupCronExpression | quote }}
{{- end }}
{{- range .Values.server.extraEnv }}
- name: {{ .name }}
value: {{ .value | quote }}
{{- end }}
volumeMounts:
- name: valheim-data
mountPath: /config
subPath: config
- name: valheim-data
mountPath: /opt/valheim
subPath: server
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- if not .Values.persistence.enabled }}
volumes:
- name: valheim-data
emptyDir: {}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.persistence.enabled }}
volumeClaimTemplates:
- metadata:
name: valheim-data
spec:
accessModes:
{{- toYaml .Values.persistence.accessModes | nindent 10 }}
{{- if .Values.persistence.storageClassName }}
storageClassName: {{ .Values.persistence.storageClassName }}
{{- end }}
resources:
requests:
storage: {{ .Values.persistence.size }}
{{- end }}
+66
View File
@@ -0,0 +1,66 @@
## Default values for the valheim chart
namespace:
# If true, the chart creates the namespace itself.
create: true
name: valheim
image:
repository: lloesche/valheim-server
tag: latest
pullPolicy: IfNotPresent
server:
name: "Valtersheim"
worldName: "Midgard"
# Leave empty to auto-generate a random password on first deploy via the secret below.
# It is strongly recommended to override this via --set or a separate values file that is
# NOT committed to git (or use SealedSecrets/ExternalSecrets in production).
password: "changeme-please-override"
public: true
# Comma separated SteamIDs allowed to join/admin the server (optional)
admins: ""
updateIntervalSeconds: 900
backupIntervalSeconds: 3600
backupCronExpression: ""
# extra env vars appended to the container, e.g. SERVER_ARGS, CROSSPLAY, etc.
extraEnv: []
# - name: CROSSPLAY
# value: "true"
service:
type: NodePort
# Game (2456), query (2457) and crossplay (2458) ports.
gamePort: 2456
queryPort: 2457
crossplayPort: 2458
# Only used when type is NodePort. Leave 0 to let Kubernetes pick a random port.
nodePorts:
game: 30456
query: 30457
crossplay: 30458
persistence:
enabled: true
size: 10Gi
# Leave empty to use the cluster default StorageClass.
storageClassName: ""
accessModes:
- ReadWriteOnce
resources:
requests:
cpu: 1000m
memory: 3Gi
limits:
cpu: 2000m
memory: 6Gi
securityContext:
fsGroup: 1000
podAnnotations: {}
nodeSelector: {}
tolerations: []
affinity: {}