Skip to content

Commit

Permalink
Merge pull request #50 from todaywasawesome/fixes
Browse files Browse the repository at this point in the history
Dynamically tag resources and add password from secret support
  • Loading branch information
Addyvan authored Nov 23, 2022
2 parents 7cabace + b463829 commit eec28a7
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ helm install valheim-server valheim-k8s/valheim-k8s \
| `worldName` | Prefix of the world files to use (will make new if missing) | `example-world-name` |
| `serverName` | Server name displayed in the server browser(s) | `example-server-name` |
| `password` | Server password | `password` |
| `passwordSecret` | Name of Kubernetes secret to pull secret from. Secret should contain a single field labeled `password` | None |
| `storage.kind` | Storage strategy/soln used to provide the game-server with persistence | `hostvol` |
| `storage.hostvol.path` | The folder to be mounted into /config in the game-server pod | `/data/valheim` |
| `storage.pvc.storageClassName` | The storageClass used to create the persistentVolumeClaim | `default` |
Expand Down
25 changes: 19 additions & 6 deletions chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: valheim-server
name: {{ .Release.Name }}
namespace: {{ .Release.Namespace }}
spec:
selector:
matchLabels:
app: valheim-server
app: {{ .Release.Name }}
strategy:
type: Recreate
template:
metadata:
labels:
app: valheim-server
app: {{ .Release.Name }}
spec:
{{- with .Values.nodeSelector }}
nodeSelector:
Expand All @@ -23,14 +24,26 @@ spec:
{{- end }}
containers:
- image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
name: valheim-server
name: {{ .Release.Name }}
env:
- name: SERVER_NAME
value: {{ .Values.serverName }}
- name: WORLD_NAME
value: {{ .Values.worldName }}
{{ if .Values.passwordSecret -}}
- name: SERVER_PASS
valueFrom:
secretKeyRef:
name: {{ .Values.passwordSecret }}
key: password
optional: false
{{ else if .Values.password -}}
- name: SERVER_PASS
value: {{ .Values.password }}
{{ else -}}
- name: SERVER_PASS
value: "password"
{{end -}}
- name: SERVER_PORT
value: {{ .Values.networking.gamePort | quote }}
{{ if .Values.extraEnvironmentVars -}}
Expand Down Expand Up @@ -75,12 +88,12 @@ spec:
{{ if eq .Values.storage.kind "persistentVolumeClaim" }}
- name: gamefiles
persistentVolumeClaim:
claimName: valheim-server-world-data
claimName: {{ .Release.Name }}-world-data
{{ end }}
{{ if eq .Values.serverStorage.kind "persistentVolumeClaim" }}
- name: serverfiles
persistentVolumeClaim:
claimName: valheim-server-base-data
claimName: {{ .Release.Name }}-server-base-data
{{ end }}
{{ range .Values.extraVolumes }}
- name: {{ .name }}
Expand Down
6 changes: 4 additions & 2 deletions chart/templates/persistentvolumeclaim.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: valheim-server-world-data
name: {{ .Release.Name }}-world-data
namespace: {{ .Release.Namespace }}
spec:
{{ if .Values.storage.pvc.storageClassName }}
storageClassName: {{ .Values.storage.pvc.storageClassName }}
Expand All @@ -18,7 +19,8 @@ spec:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: valheim-server-base-data
name: {{ .Release.Name }}-server-base-data
namespace: {{ .Release.Namespace }}
spec:
{{ if .Values.serverStorage.pvc.storageClassName }}
storageClassName: {{ .Values.serverStorage.pvc.storageClassName }}
Expand Down
5 changes: 3 additions & 2 deletions chart/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
apiVersion: v1
kind: Service
metadata:
name: valheim-server
name: {{ .Release.Name }}
namespace: {{ .Release.Namespace }}
spec:
ports:
- name: gameport
Expand All @@ -22,4 +23,4 @@ spec:
{{ end }}
type: {{ .Values.networking.serviceType }}
selector:
app: valheim-server
app: {{ .Release.Name }}

0 comments on commit eec28a7

Please sign in to comment.