Skip to content

Commit 543347d

Browse files
committed
feat(nextcloud): add notify_push support
Signed-off-by: WrenIX <dev.github@wrenix.eu>
1 parent 1a8f7b3 commit 543347d

File tree

19 files changed

+436
-134
lines changed

19 files changed

+436
-134
lines changed

.github/workflows/lint-test.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ jobs:
8383
- name: Horizontal Pod Autoscaling Enabled
8484
helm_args: '--helm-extra-set-args "--values charts/nextcloud/test-values/hpa.yaml"'
8585

86+
# test the helm chart with notify push enabled
87+
- name: Notify Push Enabled
88+
helm_args: '--helm-extra-set-args "--values charts/nextcloud/test-values/notify_push.yaml"'
89+
8690
# test the helm chart with s3 as the primary storage
8791
- name: S3 Enabled as Primary Storage
8892
# we need to skip the clean up so we can test adding a file

charts/nextcloud/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ This Helm-Chart increase there major version on every breaking change (or major
44

55
Here we list all major versions and their breaking changes for migration.
66

7+
## v9
8+
- move `metrics.serviceMonitor` to `prometheus.serviceMonitor`: It us used for nextcloud-exporter and notify-push
9+
710
## v8
811
- `cronjob.command` was renamed to `cronjob.sidecar.command` to avoid confusion with the cronjob command. Please update your `values.yaml` accordingly.
912

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: 8.5.1
3+
version: 9.2.0
44
# renovate: image=docker.io/library/nextcloud
55
appVersion: 32.0.1
66
description: A file sharing server that puts the control and security of your own data back into your hands.

charts/nextcloud/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ helm install my-release nextcloud/nextcloud
2929
* [Headers set on NGINX](#headers-set-on-nginx)
3030
* [Probes Configurations](#probes-configurations)
3131
* [Collabora Configuration](#collabora-configuration)
32+
* [Notify Push](#notify-push)
3233
* [Imaginary](#imaginary)
3334
* [Cron jobs](#cron-jobs)
3435
* [Using the nextcloud docker image auto-configuration via env vars](#using-the-nextcloud-docker-image-auto-configuration-via-env-vars)
@@ -529,6 +530,38 @@ The nextcloud deployment includes a series of different probes you can use to de
529530
> [!Note]
530531
> If you are getting errors on initialization (such as `Fatal error: require_once(): Failed opening required '/var/www/html/lib/versioncheck.php'`, but you can get other errors as well), a good first step is to try and enable the startupProbe and/or increase the `initialDelaySeconds` for the `livenessProbe` and `readinessProbe` to something much greater (consider using `120` seconds instead of `10`. This is an especially good idea if your cluster is running on older hardware, has a slow internet connection, or you're using a slower storage class, such as NFS that's running with older disks or a slow connection.
531532

533+
### Notify Push
534+
535+
We include an optional Client Push [nextcloud/notify_push](https://github.com/nextcloud/notify_push).
536+
537+
538+
| Parameter | Description | Default |
539+
|----------------------------------------|----------------------------------------------------------------------------------|------------------------|
540+
| `notifyPush.enabled` | Enable another deployment to handle notify_push (sometimes called ClientPush) | `false` |
541+
| `notifyPush.autoSetup` | Setup notify_push on nextcloud per docker-entrypoint-hooks before start | `false` |
542+
| `notifyPush.replicaCount` | Number of notify-push pod replicas to deploy | `1` |
543+
| `notifyPush.image.registry` | notify-push image registry | `docker.io` |
544+
| `notifyPush.image.repository` | notify-push image name | `miles170/notify_push` |
545+
| `notifyPush.image.tag` | notify-push image tag | `v0.7.0` |
546+
| `notifyPush.image.pullPolicy` | notify-push image pull policy | `IfNotPresent` |
547+
| `notifyPush.image.pullSecrets` | notify-push image pull secrets | `[]` |
548+
| `notifyPush.extraEnv` | option additional env (if a external redis is used, you need to set REDIS_URL) | `""` |
549+
| `notifyPush.podAnnotations` | Additional annotations for notify-push pods | `{}` |
550+
| `notifyPush.podLabels` | Additional labels for notify-push pods | `{}` |
551+
| `notifyPush.podSecurityContext` | Optional security context for the notify-push pod | `nil` |
552+
| `notifyPush.securityContext` | Optional security context for the notify-push container | `nil` |
553+
| `notifyPush.resources` | notify-push resources | `{}` |
554+
| `notifyPush.service.type` | notify-push: Kubernetes Service type | `ClusterIP` |
555+
| `notifyPush.service.loadBalancerIP` | Use serviceLoadBalancerIP to request a specific static IP, otherwise leave blank | `nil` |
556+
| `notifyPush.service.nodePort` | notify-push: NodePort for service type NodePort | `nil` |
557+
| `notifyPush.service.annotations` | Additional annotations for service notify-push | `{}` |
558+
| `notifyPush.service.labels` | Additional labels for service notify-push | `{}` |
559+
| `notifyPush.ingress.path` | Add path in default ingress to notify_push service | `/push` |
560+
| `notifyPush.ingress.pathType` | PathType for additional path in default ingress for notify-push path | `Prefix` |
561+
562+
> [!Note]
563+
> notify-push needs an redis (`redis.enabled=true` or `notifyPush.extraEnv=[{name:"REDIS_URL",...}]` )
564+
532565
### Collabora Configuration
533566

534567
This section provides options to enable and configure the Collabora Online server within your deployment. Please ensure to review the [Collabora Online Helm chart documentation](https://github.com/CollaboraOnline/online/tree/master/kubernetes/helm/collabora-online) for additional details and recommended values.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
/var/www/html/occ app:enable notify_push
3+
/var/www/html/occ config:app:set notify_push base_endpoint --value="http{{ if .Values.ingress.tls }}s{{ end }}://{{ .Values.nextcloud.host }}{{ .Values.notifyPush.ingress.path }}"
4+
{{/*
5+
The command "setup" runs a check, which need a running nextcloud (but we try to configurate it during startup).
6+
So that command always failure and we stuck in bootloop.
7+
/var/www/html/occ notify_push:setup "http{{ if .Values.ingress.tls }}s{{ end }}://{{ .Values.nextcloud.host }}{{ .Values.notifyPush.ingress.path }}"
8+
*/}}

charts/nextcloud/templates/_helpers.tpl

Lines changed: 74 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,7 @@ Create image name that is used in the deployment
6464
{{/*
6565
Create environment variables used to configure the nextcloud container as well as the cron sidecar container.
6666
*/}}
67-
{{- define "nextcloud.env" -}}
68-
{{- if .Values.phpClientHttpsFix.enabled }}
69-
- name: OVERWRITEPROTOCOL
70-
value: {{ .Values.phpClientHttpsFix.protocol | quote }}
71-
{{- end }}
67+
{{- define "nextcloud.env.database" -}}
7268
{{- if .Values.internalDatabase.enabled }}
7369
- name: SQLITE_DATABASE
7470
value: {{ .Values.internalDatabase.name | quote }}
@@ -87,6 +83,8 @@ Create environment variables used to configure the nextcloud container as well a
8783
secretKeyRef:
8884
name: {{ .Values.externalDatabase.existingSecret.secretName | default (printf "%s-db" .Release.Name) }}
8985
key: {{ .Values.externalDatabase.existingSecret.passwordKey }}
86+
- name: DATABASE_URL
87+
value: "mysql://$(MYSQL_USER):$(MYSQL_PASSWORD)@$(MYSQL_HOST)/$(MYSQL_DATABASE)"
9088
{{- else if .Values.postgresql.enabled }}
9189
- name: POSTGRES_HOST
9290
value: {{ template "postgresql.v1.primary.fullname" .Subcharts.postgresql }}
@@ -106,7 +104,9 @@ Create environment variables used to configure the nextcloud container as well a
106104
secretKeyRef:
107105
name: {{ .Values.externalDatabase.existingSecret.secretName | default (printf "%s-db" .Release.Name) }}
108106
key: {{ .Values.externalDatabase.existingSecret.passwordKey }}
109-
{{- else }}
107+
- name: DATABASE_URL
108+
value: "postgres://$(POSTGRES_USER):$(POSTGRES_PASSWORD)@$(POSTGRES_HOST)/$(POSTGRES_DB)"
109+
{{- else }}{{/* mariadb.enable or postgresql.enabled -> now external */}}
110110
{{- if eq .Values.externalDatabase.type "postgresql" }}
111111
- name: POSTGRES_HOST
112112
{{- if .Values.externalDatabase.existingSecret.hostKey }}
@@ -136,7 +136,9 @@ Create environment variables used to configure the nextcloud container as well a
136136
secretKeyRef:
137137
name: {{ .Values.externalDatabase.existingSecret.secretName | default (printf "%s-db" .Release.Name) }}
138138
key: {{ .Values.externalDatabase.existingSecret.passwordKey }}
139-
{{- else }}
139+
- name: DATABASE_URL
140+
value: "postgres://$(POSTGRES_USER):$(POSTGRES_PASSWORD)@$(POSTGRES_HOST)/$(POSTGRES_DB)"
141+
{{- else }}{{/* external.type = postgresql */}}
140142
- name: MYSQL_HOST
141143
{{- if .Values.externalDatabase.existingSecret.hostKey }}
142144
valueFrom:
@@ -165,8 +167,72 @@ Create environment variables used to configure the nextcloud container as well a
165167
secretKeyRef:
166168
name: {{ .Values.externalDatabase.existingSecret.secretName | default (printf "%s-db" .Release.Name) }}
167169
key: {{ .Values.externalDatabase.existingSecret.passwordKey }}
168-
{{- end }}
170+
- name: DATABASE_URL
171+
value: "mysql://$(MYSQL_USER):$(MYSQL_PASSWORD)@$(MYSQL_HOST)/$(MYSQL_DATABASE)"
172+
{{- end }}{{/* external.type = postgresql */}}
173+
{{- end }}{{/* not mariadb.enable or postgresql.enabled -> just external*/}}
174+
{{- end }}
175+
176+
{{/*
177+
Redis env vars
178+
*/}}
179+
{{- define "nextcloud.env.redis" -}}
180+
{{- if .Values.redis.enabled }}
181+
- name: REDIS_HOST
182+
value: {{ template "nextcloud.redis.fullname" . }}-master
183+
- name: REDIS_HOST_PORT
184+
value: {{ .Values.redis.master.service.ports.redis | quote }}
185+
{{- if .Values.redis.auth.enabled }}
186+
{{- if and .Values.redis.auth.existingSecret .Values.redis.auth.existingSecretPasswordKey }}
187+
- name: REDIS_HOST_PASSWORD
188+
valueFrom:
189+
secretKeyRef:
190+
name: {{ .Values.redis.auth.existingSecret }}
191+
key: {{ .Values.redis.auth.existingSecretPasswordKey }}
192+
{{- else }}
193+
- name: REDIS_HOST_PASSWORD
194+
value: {{ .Values.redis.auth.password }}
195+
{{- end }}
196+
{{- end }}
197+
{{- else if .Values.externalRedis.enabled }}
198+
- name: REDIS_HOST
199+
value: {{ .Values.externalRedis.host | quote }}
200+
- name: REDIS_HOST_PORT
201+
value: {{ .Values.externalRedis.port | quote }}
202+
{{- if .Values.externalRedis.existingSecret.enabled }}
203+
{{- if and .Values.externalRedis.existingSecret.secretName .Values.externalRedis.existingSecret.passwordKey }}
204+
- name: REDIS_HOST_PASSWORD
205+
valueFrom:
206+
secretKeyRef:
207+
name: {{ .Values.externalRedis.existingSecret.secretName | quote }}
208+
key: {{ .Values.externalRedis.existingSecret.passwordKey | quote }}
209+
{{- end }}
210+
{{- else if .Values.externalRedis.password }}
211+
- name: REDIS_HOST_PASSWORD
212+
value: {{ .Values.externalRedis.password | quote }}
169213
{{- end }}
214+
{{- end }}{{/* end-of redis-enabled*/}}
215+
{{- if or
216+
(and .Values.redis.auth.enabled .Values.redis.auth.password)
217+
(and .Values.redis.auth.enabled .Values.redis.auth.existingSecret .Values.redis.auth.existingSecretPasswordKey)
218+
(and .Values.externalRedis.enabled .Values.externalRedis.existingSecret.secretName .Values.externalRedis.existingSecret.passwordKey)
219+
(and .Values.externalRedis.enabled .Values.externalRedis.password)
220+
}}
221+
- name: REDIS_URL
222+
value: "redis://:$(REDIS_HOST_PASSWORD)@$(REDIS_HOST):$(REDIS_HOST_PORT)"
223+
{{- else }}
224+
- name: REDIS_URL
225+
value: "redis://$(REDIS_HOST):$(REDIS_HOST_PORT)"
226+
{{- end }}{{/* end-of redis-url*/}}
227+
{{- end }}{{/* end-of env.redis definition */}}
228+
229+
{{- define "nextcloud.env" -}}
230+
{{- if .Values.phpClientHttpsFix.enabled }}
231+
- name: OVERWRITEPROTOCOL
232+
value: {{ .Values.phpClientHttpsFix.protocol | quote }}
233+
{{- end }}
234+
{{- template "nextcloud.env.database" . }}
235+
{{- template "nextcloud.env.redis" . }}
170236
- name: NEXTCLOUD_ADMIN_USER
171237
valueFrom:
172238
secretKeyRef:
@@ -217,44 +283,6 @@ Create environment variables used to configure the nextcloud container as well a
217283
key: {{ .Values.nextcloud.existingSecret.smtpPasswordKey }}
218284
{{- end }}
219285
{{/*
220-
Redis env vars
221-
*/}}
222-
{{- if .Values.redis.enabled }}
223-
- name: REDIS_HOST
224-
value: {{ template "nextcloud.redis.fullname" . }}-master
225-
- name: REDIS_HOST_PORT
226-
value: {{ .Values.redis.master.service.ports.redis | quote }}
227-
{{- if .Values.redis.auth.enabled }}
228-
{{- if and .Values.redis.auth.existingSecret .Values.redis.auth.existingSecretPasswordKey }}
229-
- name: REDIS_HOST_PASSWORD
230-
valueFrom:
231-
secretKeyRef:
232-
name: {{ .Values.redis.auth.existingSecret }}
233-
key: {{ .Values.redis.auth.existingSecretPasswordKey }}
234-
{{- else }}
235-
- name: REDIS_HOST_PASSWORD
236-
value: {{ .Values.redis.auth.password }}
237-
{{- end }}
238-
{{- end }}
239-
{{- else if .Values.externalRedis.enabled }}
240-
- name: REDIS_HOST
241-
value: {{ .Values.externalRedis.host | quote }}
242-
- name: REDIS_HOST_PORT
243-
value: {{ .Values.externalRedis.port | quote }}
244-
{{- if .Values.externalRedis.existingSecret.enabled }}
245-
{{- if and .Values.externalRedis.existingSecret.secretName .Values.externalRedis.existingSecret.passwordKey }}
246-
- name: REDIS_HOST_PASSWORD
247-
valueFrom:
248-
secretKeyRef:
249-
name: {{ .Values.externalRedis.existingSecret.secretName | quote }}
250-
key: {{ .Values.externalRedis.existingSecret.passwordKey | quote }}
251-
{{- end }}
252-
{{- else if .Values.externalRedis.password }}
253-
- name: REDIS_HOST_PASSWORD
254-
value: {{ .Values.externalRedis.password | quote }}
255-
{{- end }}
256-
{{- end }}{{/* end if redis.enabled */}}
257-
{{/*
258286
S3 as primary object store env vars
259287
*/}}
260288
{{- if .Values.nextcloud.objectStore.s3.enabled }}
@@ -359,7 +387,6 @@ Swift as primary object store env vars
359387
{{- end }}
360388
{{- end -}}
361389

362-
363390
{{/*
364391
Create volume mounts for the nextcloud container as well as the cron sidecar container.
365392
*/}}

charts/nextcloud/templates/db-secret.yaml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,20 @@ metadata:
1010
type: Opaque
1111
data:
1212
{{- if .Values.mariadb.enabled }}
13-
db-username: {{ .Values.mariadb.auth.username | b64enc | quote }}
14-
db-password: {{ .Values.mariadb.auth.password | b64enc | quote }}
13+
{{- with .Values.mariadb.auth }}
14+
db-username: {{ .username | b64enc | quote }}
15+
db-password: {{ .password | b64enc | quote }}
16+
{{- end }}
1517
{{- else if .Values.postgresql.enabled }}
16-
db-username: {{ .Values.postgresql.global.postgresql.auth.username | b64enc | quote }}
17-
db-password: {{ .Values.postgresql.global.postgresql.auth.password | b64enc | quote }}
18+
{{- with .Values.postgresql.global.postgresql.auth }}
19+
db-username: {{ .username | b64enc | quote }}
20+
db-password: {{ .password | b64enc | quote }}
21+
{{- end }}
1822
{{- else }}
19-
db-username: {{ .Values.externalDatabase.user | b64enc | quote }}
20-
db-password: {{ .Values.externalDatabase.password | b64enc | quote }}
23+
{{- with .Values.externalDatabase }}
24+
db-username: {{ .user | b64enc | quote }}
25+
db-password: {{ .password | b64enc | quote }}
26+
{{- end }}
2127
{{- end }}
2228
{{- end }}
2329
{{- end }}

charts/nextcloud/templates/deployment.yaml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ spec:
7777
{{- end }}
7878
volumeMounts:
7979
{{- include "nextcloud.volumeMounts" . | trim | nindent 12 }}
80+
{{- if and .Values.notifyPush.enabled .Values.notifyPush.autoSetup }}
81+
- name: nextcloud-notify-hooks
82+
mountPath: /docker-entrypoint-hooks.d/before-starting/notify_push.sh
83+
subPath: notify_push.sh
84+
readOnly: true
85+
{{- end }}
8086
{{- range $hook, $shell := .Values.nextcloud.hooks }}
8187
{{- if $shell }}
8288
- name: nextcloud-hooks
@@ -288,45 +294,30 @@ spec:
288294
{{- end }}
289295
{{- if .Values.mariadb.enabled }}
290296
- name: mariadb-isalive
291-
image: {{ .Values.mariadb.image.registry | default "docker.io" }}/{{ .Values.mariadb.image.repository }}:{{ .Values.mariadb.image.tag }}
297+
image: {{ .Values.mariadb.image.registry }}/{{ .Values.mariadb.image.repository }}:{{ .Values.mariadb.image.tag }}
292298
{{- with .Values.nextcloud.mariaDbInitContainer }}
293299
resources:
294300
{{- toYaml .resources | nindent 12 }}
295301
securityContext:
296302
{{- toYaml .securityContext | nindent 12 }}
297303
{{- end }}
298304
env:
299-
- name: MYSQL_USER
300-
valueFrom:
301-
secretKeyRef:
302-
name: {{ .Values.externalDatabase.existingSecret.secretName | default (printf "%s-db" .Release.Name) }}
303-
key: {{ .Values.externalDatabase.existingSecret.usernameKey }}
304-
- name: MYSQL_PASSWORD
305-
valueFrom:
306-
secretKeyRef:
307-
name: {{ .Values.externalDatabase.existingSecret.secretName | default (printf "%s-db" .Release.Name) }}
308-
key: {{ .Values.externalDatabase.existingSecret.passwordKey }}
305+
{{- include "nextcloud.env.database" . | nindent 12 }}
309306
command:
310307
- "sh"
311308
- "-c"
312-
- {{ printf "until mysql --host=%s-mariadb --user=${MYSQL_USER} --password=${MYSQL_PASSWORD} --execute=\"SELECT 1;\"; do echo waiting for mysql; sleep 2; done;" .Release.Name }}
309+
- {{ printf "until mysql --host=${MYSQL_HOST} --user=${MYSQL_USER} --password=${MYSQL_PASSWORD} --execute=\"SELECT 1;\"; do echo waiting for mysql; sleep 2; done;" }}
313310
{{- else if .Values.postgresql.enabled }}
314311
- name: postgresql-isready
315-
image: {{ .Values.postgresql.image.registry | default "docker.io" }}/{{ .Values.postgresql.image.repository }}:{{ .Values.postgresql.image.tag }}
312+
image: {{ .Values.postgresql.image.registry }}/{{ .Values.postgresql.image.repository }}:{{ .Values.postgresql.image.tag }}
316313
{{- with .Values.nextcloud.postgreSqlInitContainer }}
317314
resources:
318315
{{- toYaml .resources | nindent 12 }}
319316
securityContext:
320317
{{- toYaml .securityContext | nindent 12 }}
321318
{{- end }}
322319
env:
323-
- name: POSTGRES_USER
324-
valueFrom:
325-
secretKeyRef:
326-
name: {{ .Values.externalDatabase.existingSecret.secretName | default (printf "%s-db" .Release.Name) }}
327-
key: {{ .Values.externalDatabase.existingSecret.usernameKey }}
328-
- name: POSTGRES_HOST
329-
value: {{ template "postgresql.v1.primary.fullname" .Subcharts.postgresql }}
320+
{{- include "nextcloud.env.database" . | nindent 12 }}
330321
command:
331322
- "sh"
332323
- "-c"
@@ -373,6 +364,15 @@ spec:
373364
configMap:
374365
name: {{ template "nextcloud.fullname" . }}-nginxconfig
375366
{{- end }}
367+
{{- if and .Values.notifyPush.enabled .Values.notifyPush.autoSetup }}
368+
- name: nextcloud-notify-hooks
369+
configMap:
370+
name: {{ template "nextcloud.fullname" . }}-notify-push
371+
defaultMode: 0o755
372+
items:
373+
- key: hook.sh
374+
path: notify_push.sh
375+
{{- end }}
376376
{{- if not (values .Values.nextcloud.hooks | compact | empty) }}
377377
- name: nextcloud-hooks
378378
configMap:

charts/nextcloud/templates/ingress.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ spec:
3535
serviceName: {{ template "nextcloud.fullname" . }}
3636
servicePort: {{ .Values.service.port }}
3737
{{- end }}
38+
{{- if .Values.notifyPush.enabled }}
39+
- path: {{ .Values.notifyPush.ingress.path }}
40+
pathType: {{ .Values.notifyPush.ingress.pathType }}
41+
backend:
42+
service:
43+
name: {{ template "nextcloud.fullname" . }}-notify-push
44+
port:
45+
name: http
46+
{{- end }}
3847
{{- with .Values.ingress.tls }}
3948
tls:
4049
{{- toYaml . | nindent 4 }}

0 commit comments

Comments
 (0)