Skip to content

Commit

Permalink
fix: support custom crontab (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
DrPsychick authored Feb 23, 2024
1 parent 7b8c2e4 commit d732d97
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 3 deletions.
2 changes: 1 addition & 1 deletion charts/ark-cluster/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: ark-cluster
version: 0.1.14
version: 0.2.0
description: A Helm chart for an Ark - Survival Evolved cluster
type: application
appVersion: latest
Expand Down
13 changes: 13 additions & 0 deletions charts/ark-cluster/files/crontab
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed

# Examples for arkmanager:
# 0 * * * * arkmanager update --update-mods --warn --saveworld # check for updates every hour
# */15 * * * * arkmanager saveworld && arkmanager backup # backup every 15min
# 0 0 * * * arkmanager restart --warn --saveworld # restart every day at midnight
9 changes: 9 additions & 0 deletions charts/ark-cluster/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
{{- $engineini := default dict $.Values.customConfigMap.EngineIni }}
{{- $gameini := default dict $.Values.customConfigMap.GameIni }}
{{- $gameusersettingsini := default dict $.Values.customConfigMap.GameUserSettingsIni }}
{{- $crontab := default dict $.Values.customConfigMap.crontab }}
{{- if .customConfigMap }}
{{- $gameini = default $gameini .customConfigMap.GameIni }}
{{- $gameusersettingsini = default $gameusersettingsini .customConfigMap.GameUserSettingsIni }}
{{- $engineini = default $engineini .customConfigMap.EngineIni }}
{{- $crontab = default $crontab .customConfigMap.crontab }}
{{- end }}
apiVersion: v1
kind: ConfigMap
Expand Down Expand Up @@ -51,4 +53,11 @@ data:
{{- else }}
{{- tpl ($.Files.Get "files/GameUserSettings.ini") (dict "server" $server "Template" $.Template) | nindent 4 }}
{{- end }}
crontab: |
{{- if $crontab }}
# from {{ $name }}.customConfig.GameUserSettingsIni
{{- tpl $crontab (dict "server" $server "Template" $.Template) | nindent 4 }}
{{- else }}
{{- tpl ($.Files.Get "files/crontab") (dict "server" $server "Template" $.Template) | nindent 4 }}
{{- end }}
{{- end }}
14 changes: 12 additions & 2 deletions charts/ark-cluster/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,14 @@ spec:
successThreshold: {{ $.Values.livenessProbe.successThreshold }}
failureThreshold: {{ $.Values.livenessProbe.failureThreshold }}
volumeMounts:
{{- /*- ark-cluster config files */}}
{{- /*- ark-cluster config files and crontab */}}
# config files
- mountPath: /arkconfig
name: {{ $chart_name }}-config-volume
- mountPath: /ark/config
name: {{ $chart_name }}-crontab-volume
subPath: "crontab"
readOnly: true
{{- /*- ark-cluster game files */}}
# shared game files
- mountPath: {{ $.Values.persistence.game.mountPath }}
Expand All @@ -230,10 +234,16 @@ spec:
{{- toYaml $.Values.extraContainers | nindent 8 }}
{{- end }}
volumes:
{{- /* ark-cluster configuration files in a configmap */}}
{{- /* ark-cluster configuration files in configmaps */}}
- name: {{ $chart_name }}-config-volume
configMap:
name: {{ $chart_name }}-{{ $name }}
- name: {{ $chart_name }}-crontab-volume
configMap:
name: {{ $chart_name }}-{{ $name }}
items:
- key: "crontab"
path: "crontab"
{{- /* ark-cluster shared game data persistence */}}
- name: {{ $chart_name }}-game-volume
{{- if not $.Values.persistence.enabled }}
Expand Down
1 change: 1 addition & 0 deletions charts/ark-cluster/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ customConfigMap:
GameIni:
GameUserSettingsIni:
EngineIni:
crontab:

# Servers in the ARK cluster
servers: {}
Expand Down

0 comments on commit d732d97

Please sign in to comment.