Compare commits
3
Commits
5204de63d0
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e00a4b4fd1 | ||
|
|
a0cb2f4348 | ||
|
|
a62faa0d73 |
+14
@@ -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
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
# 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
|
||||||
|
- **ExternalSecret** that pulls the server name, world name and join password
|
||||||
|
(`SERVER_NAME`, `WORLD_NAME`, `SERVER_PASS`) from OpenBao via the `openbao`
|
||||||
|
`ClusterSecretStore` into a Secret named `valheim-server`
|
||||||
|
- **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 |
|
||||||
|
|---|---|---|
|
||||||
|
| `externalSecret.storeName` / `externalSecret.storeKind` | Secret store the `ExternalSecret` reads from | `openbao` / `ClusterSecretStore` |
|
||||||
|
| `externalSecret.remoteKey` | Path of the secret in the store's KV v2 mount | `valheim/server` |
|
||||||
|
| `externalSecret.properties.*` | Property names inside that secret (`password`, `serverName`, `worldName`) | `password`, `server_name`, `world_name` |
|
||||||
|
| `externalSecret.refreshInterval` | How often ESO re-reads OpenBao | `1h` |
|
||||||
|
| `service.type` | `NodePort` or `LoadBalancer` | `NodePort` |
|
||||||
|
| `persistence.storageClassName` | StorageClass for world data, empty = cluster default | `""` |
|
||||||
|
| `persistence.size` | Size of the world data volume | `10Gi` |
|
||||||
|
|
||||||
|
## Secrets (OpenBao)
|
||||||
|
|
||||||
|
Server name, world name and join password are not stored in git. Create them in
|
||||||
|
OpenBao (KV v2 mount `secret/`) at `valheim/server` with the keys `password`,
|
||||||
|
`server_name` and `world_name`:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
bao kv put secret/valheim/server \
|
||||||
|
password=<join-password> server_name=<name> world_name=<world>
|
||||||
|
```
|
||||||
|
|
||||||
|
Requirements: the `openbao` `ClusterSecretStore` must be `Ready` (OpenBao unsealed,
|
||||||
|
see the `openbao` chart) and its role must be allowed to read `secret/data/valheim/*`
|
||||||
|
(the default `eso-read` policy covers all of `secret/data/*`).
|
||||||
|
|
||||||
|
Environment variables are read when the container starts. After changing a value in
|
||||||
|
OpenBao, ESO updates the Secret at the next refresh, but you must restart the pod for
|
||||||
|
the server to pick it up:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
kubectl -n valheim rollout restart statefulset/valheim
|
||||||
|
```
|
||||||
|
|
||||||
|
Note: changing `world_name` makes the server load/create a different world.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```sh
|
||||||
|
helm upgrade --install valheim . -n valheim --create-namespace
|
||||||
|
```
|
||||||
|
|
||||||
|
### 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 to git - keep them in OpenBao.
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
apiVersion: external-secrets.io/v1
|
||||||
|
kind: ExternalSecret
|
||||||
|
metadata:
|
||||||
|
name: valheim-server
|
||||||
|
namespace: {{ .Values.namespace.name }}
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: valheim
|
||||||
|
spec:
|
||||||
|
refreshInterval: {{ .Values.externalSecret.refreshInterval }}
|
||||||
|
secretStoreRef:
|
||||||
|
kind: {{ .Values.externalSecret.storeKind }}
|
||||||
|
name: {{ .Values.externalSecret.storeName }}
|
||||||
|
target:
|
||||||
|
# Name/keys are referenced by the StatefulSet (SERVER_PASS, SERVER_NAME, WORLD_NAME).
|
||||||
|
name: valheim-server
|
||||||
|
creationPolicy: Owner
|
||||||
|
data:
|
||||||
|
- secretKey: SERVER_PASS
|
||||||
|
remoteRef:
|
||||||
|
key: {{ .Values.externalSecret.remoteKey }}
|
||||||
|
property: {{ .Values.externalSecret.properties.password }}
|
||||||
|
- secretKey: SERVER_NAME
|
||||||
|
remoteRef:
|
||||||
|
key: {{ .Values.externalSecret.remoteKey }}
|
||||||
|
property: {{ .Values.externalSecret.properties.serverName }}
|
||||||
|
- secretKey: WORLD_NAME
|
||||||
|
remoteRef:
|
||||||
|
key: {{ .Values.externalSecret.remoteKey }}
|
||||||
|
property: {{ .Values.externalSecret.properties.worldName }}
|
||||||
@@ -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 }}
|
||||||
@@ -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 }}
|
||||||
@@ -0,0 +1,116 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: StatefulSet
|
||||||
|
metadata:
|
||||||
|
name: valheim
|
||||||
|
namespace: {{ .Values.namespace.name }}
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: valheim
|
||||||
|
annotations:
|
||||||
|
# Stakater Reloader: rolling restart when ESO refreshes the secret from OpenBao
|
||||||
|
# (env vars are only read at container start). Harmless if Reloader is not installed.
|
||||||
|
secret.reloader.stakater.com/reload: "valheim-server"
|
||||||
|
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
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: valheim-server
|
||||||
|
key: SERVER_NAME
|
||||||
|
- name: WORLD_NAME
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: valheim-server
|
||||||
|
key: WORLD_NAME
|
||||||
|
- 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 }}
|
||||||
+75
@@ -0,0 +1,75 @@
|
|||||||
|
## 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, world name and join password are NOT configured here - they are read from
|
||||||
|
# OpenBao via External Secrets Operator (see `externalSecret` below).
|
||||||
|
externalSecret:
|
||||||
|
# ClusterSecretStore (deployed by the openbao chart) to read from.
|
||||||
|
storeKind: ClusterSecretStore
|
||||||
|
storeName: openbao
|
||||||
|
refreshInterval: 1h
|
||||||
|
# Path of the secret inside the KV v2 mount configured on the store (`secret/`).
|
||||||
|
remoteKey: valheim/server
|
||||||
|
# Property names inside that secret.
|
||||||
|
properties:
|
||||||
|
password: password
|
||||||
|
serverName: server_name
|
||||||
|
worldName: world_name
|
||||||
|
|
||||||
|
server:
|
||||||
|
public: false
|
||||||
|
# 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: {}
|
||||||
Reference in New Issue
Block a user