Skip to content

Commit c19c15c

Browse files
committed
feat: add hook scripts to pod
Signed-off-by: WrenIX <dev.github@wrenix.eu>
1 parent 9e51e9c commit c19c15c

File tree

4 files changed

+59
-2
lines changed

4 files changed

+59
-2
lines changed

charts/nextcloud/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
apiVersion: v2
22
name: nextcloud
3-
version: 4.5.17
3+
version: 4.6.0
44
appVersion: 28.0.2
55
description: A file sharing server that puts the control and security of your own data back into your hands.
66
keywords:

charts/nextcloud/templates/deployment.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ spec:
4343
{{- if .Values.nginx.enabled }}
4444
nginx-config-hash: {{ print .Values.nginx.config.default "-" .Values.nginx.config.custom | sha256sum }}
4545
{{- end }}
46+
hooks-hash: {{ toYaml .Values.nextcloud.hooks | sha256sum }}
4647
{{- with .Values.podAnnotations }}
4748
{{- toYaml . | nindent 8 }}
4849
{{- end }}
@@ -136,6 +137,14 @@ spec:
136137
{{- end }}
137138
volumeMounts:
138139
{{- include "nextcloud.volumeMounts" . | trim | nindent 12 }}
140+
{{- range $hook, $config := .Values.nextcloud.hooks }}
141+
{{- if $config.shell }}
142+
- name: nextcloud-hooks
143+
mountPath: /docker-entrypoint-hooks.d/before-starting/{{ $hook }}.sh
144+
subPath: {{ $hook }}.sh
145+
readOnly: true
146+
{{- end }}
147+
{{- end }}
139148
{{- if .Values.nginx.enabled }}
140149
- name: {{ .Chart.Name }}-nginx
141150
image: "{{ .Values.nginx.image.repository }}:{{ .Values.nginx.image.tag }}"
@@ -348,6 +357,18 @@ spec:
348357
configMap:
349358
name: {{ template "nextcloud.fullname" . }}-nginxconfig
350359
{{- end }}
360+
{{- if or
361+
(get .Values.nextcloud.hooks "pre-installation").shell
362+
(get .Values.nextcloud.hooks "post-installation").shell
363+
(get .Values.nextcloud.hooks "pre-upgrade").shell
364+
(get .Values.nextcloud.hooks "post-upgrade").shell
365+
(get .Values.nextcloud.hooks "before-starting").shell
366+
}}
367+
- name: nextcloud-hooks
368+
secret:
369+
secretName: {{ template "nextcloud.fullname" . }}-hooks
370+
defaultMode: 0o755
371+
{{- end }}
351372
{{- with .Values.nextcloud.extraVolumes }}
352373
{{- toYaml . | nindent 8 }}
353374
{{- end }}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{{- if or
2+
(get .Values.nextcloud.hooks "pre-installation").shell
3+
(get .Values.nextcloud.hooks "post-installation").shell
4+
(get .Values.nextcloud.hooks "pre-upgrade").shell
5+
(get .Values.nextcloud.hooks "post-upgrade").shell
6+
(get .Values.nextcloud.hooks "before-starting").shell
7+
}}
8+
---
9+
apiVersion: v1
10+
kind: Secret
11+
type: Opaque
12+
metadata:
13+
name: {{ template "nextcloud.fullname" . }}-hooks
14+
labels:
15+
app.kubernetes.io/name: {{ include "nextcloud.name" . }}
16+
helm.sh/chart: {{ include "nextcloud.chart" . }}
17+
app.kubernetes.io/instance: {{ .Release.Name }}
18+
app.kubernetes.io/managed-by: {{ .Release.Service }}
19+
data:
20+
{{- range $hook, $config := .Values.nextcloud.hooks }}
21+
{{- if $config.shell }}
22+
{{ $hook }}.sh: {{ $config.shell | b64enc }}
23+
{{- end }}
24+
{{- end }}
25+
{{- end }}

charts/nextcloud/values.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,18 @@ nextcloud:
146146
# )
147147
# )
148148
# );
149-
149+
# Hooks for auto configuration
150+
# Here you could write small scripts which are placed in `/docker-entrypoint-hooks.d/<hook-name>/<hook-name>.sh`
151+
# ref: https://github.com/nextcloud/docker?tab=readme-ov-file#auto-configuration-via-hook-folders
152+
hooks:
153+
pre-installation:
154+
shell:
155+
post-installation:
156+
shell:
157+
pre-upgrade:
158+
shell:
159+
before-starting:
160+
shell:
150161
## Strategy used to replace old pods
151162
## IMPORTANT: use with care, it is suggested to leave as that for upgrade purposes
152163
## ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy

0 commit comments

Comments
 (0)