Skip to content

Commit

Permalink
Share env variable NEXTCLOUD_DATA_DIR
Browse files Browse the repository at this point in the history
Signed-off-by: Stephan Austermühle <[email protected]>
  • Loading branch information
stephan2012 committed Mar 4, 2024
1 parent f8e3f58 commit 97f9875
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
8 changes: 4 additions & 4 deletions charts/nextcloud/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -528,9 +528,9 @@ Check out the [official Nextcloud backup docs](https://docs.nextcloud.com/server
Configure `.nextcloud.backupCronjobs` to install Kubernetes Cronjobs
to backup the Nextcloud data volume. The Helm chart automatically
adds `volumes` and `volumeMounts` to the Cronjobs to make the
Nextcloud data folder accessible at the same paths as the Nextcloud
containers.
shares the Nextcloud data folder to (`volumes`, `volumeMounts`) on the
same path. Additionally, it provides the environment variable
`NEXTCLOUD_DATA_DIR`.
Example:
Expand All @@ -556,7 +556,7 @@ Example:
command:
- /bin/sh
- -c
- "restic --quiet --json --host nextcloud-data --tag cron backup /var/www/html/data"
- "restic --quiet --json --host nextcloud-data --tag cron backup ${NEXTCLOUD_DATA_DIR}"
env:
- name: RESTIC_CACHE_DIR
value: /run/restic/cache
Expand Down
5 changes: 5 additions & 0 deletions charts/nextcloud/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,11 @@ Create volume mounts for the nextcloud container as well as the cron sidecar con
{{- end }}
{{- end -}}

{{- define "nextcloud.backupCronJobEnv" -}}
- name: NEXTCLOUD_DATA_DIR
value: {{ .Values.nextcloud.datadir | quote }}
{{- end -}}

{{- define "nextcloud.backupCronJobVolumes" -}}
{{- if and .Values.persistence.nextcloudData.enabled .Values.persistence.enabled }}
- name: nextcloud-data
Expand Down
9 changes: 5 additions & 4 deletions charts/nextcloud/templates/cronjobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ spec:
{{- $volumes := dict "spec" (dict "template" (dict "spec" (dict "volumes" $volumeList))) -}}
{{- $jobTemplate := merge $volumes .jobTemplate -}}

{{/* Add the volumeMounts to every container */}}
{{/* Add the volumeMounts and environment variables to every container */}}
{{- $containers := list -}}
{{- range .jobTemplate.spec.template.spec.containers -}}
{{- $vm := concat (default list .volumeMounts) (include "nextcloud.backupCronJobVolumeMounts" $ | fromYamlArray) -}}
{{- $this := dict "volumeMounts" $vm -}}
{{- $containers = append $containers (merge $this .) -}}
{{- $vm := dict "volumeMounts" (concat (default list .volumeMounts) (include "nextcloud.backupCronJobVolumeMounts" $ | fromYamlArray)) -}}
{{- $containers = append $containers (merge $vm .) -}}
{{- $env := concat (default list .env) (include "nextcloud.backupCronJobEnv" $ | fromYamlArray) -}}
{{- $containers = append $containers (merge (dict "env" $env) .) -}}
{{- end -}}

{{- $newContainers := dict "spec" (dict "template" (dict "spec" (dict "containers" $containers))) -}}
Expand Down
2 changes: 1 addition & 1 deletion charts/nextcloud/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ nextcloud:
# command:
# - /bin/sh
# - -c
# - "restic --quiet --json --host nextcloud-data --tag cron backup /var/www/html/data"
# - "restic --quiet --json --host nextcloud-data --tag cron backup ${NEXTCLOUD_DATA_DIR}"
# env:
# - name: TZ
# value: "Europe/Berlin"
Expand Down

0 comments on commit 97f9875

Please sign in to comment.