Skip to content

Commit b55eec4

Browse files
authored
Merge pull request #36 from fbuchmeier/main
added second volume to Valheim pod to persist server installation on pod recreation
2 parents 6d54616 + baea2ce commit b55eec4

File tree

5 files changed

+53
-2
lines changed

5 files changed

+53
-2
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,23 @@ helm install valheim-server valheim-k8s/valheim-k8s \
2828
| `storage.hostvol.path` | The folder to be mounted into /config in the game-server pod | `/data/valheim` |
2929
| `storage.pvc.storageClassName` | The storageClass used to create the persistentVolumeClaim | `default` |
3030
| `storage.pvc.size` | The size of the persistent volume to be created | `1Gi` |
31+
| `serverStorage.kind` | Storage strategy/soln used to save the server installation files | `hostvol` |
32+
| `serverStorage.hostvol.path` | The folder to be mounted into /opt/valheim in the game-server pod | `/data/valheim-server` |
33+
| `serverStorage.pvc.storageClassName` | The storageClass used to create the persistentVolumeClaim | `default` |
34+
| `serverStorage.pvc.size` | The size of the persistent volume to be created | `5Gi` |
3135
| `networking.serviceType` | The type of service e.g `NodePort`, `LoadBalancer` or `ClusterIP` | `LoadBalancer` |
3236
| `networking.gamePort` | The UDP start port the server will listen on | `2456` |
37+
| `networking.nodePort` | When service type is `NodePort`, assign a fixed UDP port to the server | `""` |
3338
| `networking.publishQueryPort` | Expose the Steam query port (gamePort + 1) | `true` |
3439
| `nodeSelector` | | `{}` |
3540
| `image.repository` | Specifies container image repository | `lloesche/valheim-server` |
3641
| `image.tag` | Specifies container image tag | `latest` |
3742

3843
## Persistence
3944

40-
Currently persistence is supported through mounting a `hostvol` or via a `persistentVolumeClaim`. Please create an issue if you would like support for specific cloud storage solutions via PVCs / storageclasses. They vary by provider so PRs / testers welcome for this.
45+
Currently persistence is supported through mounting a `hostvol` or via a `persistentVolumeClaim`. Please create an issue if you would like support for specific cloud storage solutions via PVCs / storageclasses. They vary by provider so PRs / testers welcome for this.
46+
47+
You can enable persistence for both the server data (your worlds, mounted at `/config` and configured with the `storage` parameter) and the server installation (to skip downloading it every time a pod is created, mounted at `/opt/valheim`, configured with the `serverStorage` parameter).
4148

4249
### Using a Host Volume
4350

chart/templates/deployment.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ spec:
4545
- mountPath: /config
4646
name: gamefiles
4747
{{ end }}
48+
{{ if .Values.serverStorage.kind }}
49+
- mountPath: /opt/valheim
50+
name: serverfiles
51+
{{ end }}
4852
{{ range .Values.extraVolumes }}
4953
- name: {{ .name }}
5054
readOnly: true
@@ -58,11 +62,22 @@ spec:
5862
path: {{ .Values.storage.hostvol.path }}
5963
type: DirectoryOrCreate
6064
{{ end }}
65+
{{ if eq .Values.serverStorage.kind "hostvol" }}
66+
- name: serverfiles
67+
hostPath:
68+
path: {{ .Values.serverStorage.hostvol.path }}
69+
type: DirectoryOrCreate
70+
{{ end }}
6171
{{ if eq .Values.storage.kind "persistentVolumeClaim" }}
6272
- name: gamefiles
6373
persistentVolumeClaim:
6474
claimName: valheim-server-world-data
6575
{{ end }}
76+
{{ if eq .Values.serverStorage.kind "persistentVolumeClaim" }}
77+
- name: serverfiles
78+
persistentVolumeClaim:
79+
claimName: valheim-server-base-data
80+
{{ end }}
6681
{{ range .Values.extraVolumes }}
6782
- name: {{ .name }}
6883
{{ .type }}:

chart/templates/persistentvolumeclaim.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,20 @@ spec:
1212
resources:
1313
requests:
1414
storage: {{ .Values.storage.pvc.size }}
15+
{{ end }}
16+
---
17+
{{ if eq .Values.serverStorage.kind "persistentVolumeClaim" }}
18+
apiVersion: v1
19+
kind: PersistentVolumeClaim
20+
metadata:
21+
name: valheim-server-base-data
22+
spec:
23+
{{ if .Values.serverStorage.pvc.storageClassName }}
24+
storageClassName: {{ .Values.serverStorage.pvc.storageClassName }}
25+
{{ end }}
26+
accessModes:
27+
- ReadWriteOnce
28+
resources:
29+
requests:
30+
storage: {{ .Values.serverStorage.pvc.size }}
1531
{{ end }}

chart/templates/service.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,17 @@ spec:
88
port: {{ .Values.networking.gamePort | int }}
99
targetPort: {{ .Values.networking.gamePort | int }}
1010
protocol: UDP
11+
{{- if eq .Values.networking.serviceType "NodePort" }}
12+
nodePort: {{ default "" .Values.networking.nodePort }}
13+
{{- end }}
1114
{{ if .Values.networking.publishQueryPort }}
1215
- name: queryport
1316
port: {{ .Values.networking.gamePort | int | add 1 }}
1417
targetPort: {{ .Values.networking.gamePort | int | add 1 }}
1518
protocol: UDP
19+
{{- if eq .Values.networking.serviceType "NodePort" }}
20+
nodePort: {{ default "" (.Values.networking.nodePort | int | add 1) }}
21+
{{- end }}
1622
{{ end }}
1723
type: {{ .Values.networking.serviceType }}
1824
selector:

chart/values.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,18 @@ storage:
1515
pvc:
1616
size: 1Gi
1717

18+
serverStorage:
19+
kind: hostvol
20+
hostvol:
21+
path: /data/valheim-server
22+
pvc:
23+
size: 5Gi
24+
1825
networking:
1926
serviceType: LoadBalancer
2027
gamePort: 2456
2128
publishQueryPort: "true"
22-
29+
nodePort: 2456
2330

2431

2532
nodeSelector: {}

0 commit comments

Comments
 (0)