Skip to content

Commit 44c31ef

Browse files
committed
feat(nextcloud): add notify_push support
Signed-off-by: WrenIX <dev.github@wrenix.eu>
1 parent 8c88ee2 commit 44c31ef

File tree

19 files changed

+413
-115
lines changed

19 files changed

+413
-115
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
@@ -26,3 +26,6 @@ Here we list all major versions and their breaking changes for migration.
2626
- update mariadb to v19 (see [CHANGELOG](https://github.com/bitnami/charts/blob/main/bitnami/mariadb/CHANGELOG.md#1900-2024-07-11))
2727
- update mariadb to v20 (see [CHANGELOG](https://github.com/bitnami/charts/blob/main/bitnami/mariadb/CHANGELOG.md#2000-2024-11-08))
2828
- update nextcloud to v31 (see [CHANGELOG](https://nextcloud.com/changelog/#31-0-0))
29+
30+
## v8
31+
- move `metrics.serviceMonitor` to `prometheus.serviceMonitor`: It us used for nextcloud-exporter and notify-push

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: 7.0.0
3+
version: 8.0.0
44
# renovate: image=docker.io/library/nextcloud
55
appVersion: 31.0.7
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)
@@ -505,6 +506,38 @@ The nextcloud deployment includes a series of different probes you can use to de
505506
> [!Note]
506507
> 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.
507508

509+
### Notify Push
510+
511+
We include an optional Client Push [nextcloud/notify_push](https://github.com/nextcloud/notify_push).
512+
513+
514+
| Parameter | Description | Default |
515+
|----------------------------------------|----------------------------------------------------------------------------------|------------------------|
516+
| `notifyPush.enabled` | Enable another deployment to handle notify_push (sometimes called ClientPush) | `false` |
517+
| `notifyPush.autoSetup` | Setup notify_push on nextcloud per docker-entrypoint-hooks before start | `false` |
518+
| `notifyPush.replicaCount` | Number of notify-push pod replicas to deploy | `1` |
519+
| `notifyPush.image.registry` | notify-push image registry | `docker.io` |
520+
| `notifyPush.image.repository` | notify-push image name | `miles170/notify_push` |
521+
| `notifyPush.image.tag` | notify-push image tag | `v0.7.0` |
522+
| `notifyPush.image.pullPolicy` | notify-push image pull policy | `IfNotPresent` |
523+
| `notifyPush.image.pullSecrets` | notify-push image pull secrets | `[]` |
524+
| `notifyPush.extraEnv` | option additional env (if a external redis is used, you need to set REDIS_URL) | `""` |
525+
| `notifyPush.podAnnotations` | Additional annotations for notify-push pods | `{}` |
526+
| `notifyPush.podLabels` | Additional labels for notify-push pods | `{}` |
527+
| `notifyPush.podSecurityContext` | Optional security context for the notify-push pod | `nil` |
528+
| `notifyPush.securityContext` | Optional security context for the notify-push container | `nil` |
529+
| `notifyPush.resources` | notify-push resources | `{}` |
530+
| `notifyPush.service.type` | notify-push: Kubernetes Service type | `ClusterIP` |
531+
| `notifyPush.service.loadBalancerIP` | Use serviceLoadBalancerIP to request a specific static IP, otherwise leave blank | `nil` |
532+
| `notifyPush.service.nodePort` | notify-push: NodePort for service type NodePort | `nil` |
533+
| `notifyPush.service.annotations` | Additional annotations for service notify-push | `{}` |
534+
| `notifyPush.service.labels` | Additional labels for service notify-push | `{}` |
535+
| `notifyPush.ingress.path` | Add path in default ingress to notify_push service | `/push` |
536+
| `notifyPush.ingress.pathType` | PathType for additional path in default ingress for notify-push path | `Prefix` |
537+
538+
> [!Note]
539+
> notify-push needs an redis (`redis.enabled=true` or `notifyPush.extraEnv=[{name:"REDIS_URL",...}]` )
540+
508541
### Collabora Configuration
509542

510543
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: 48 additions & 28 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,45 @@ 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+
- name: REDIS_HOST
181+
value: {{ template "nextcloud.redis.fullname" . }}-master
182+
- name: REDIS_HOST_PORT
183+
value: {{ .Values.redis.master.service.ports.redis | quote }}
184+
{{- if .Values.redis.auth.enabled }}
185+
{{- if and .Values.redis.auth.existingSecret .Values.redis.auth.existingSecretPasswordKey }}
186+
- name: REDIS_HOST_PASSWORD
187+
valueFrom:
188+
secretKeyRef:
189+
name: {{ .Values.redis.auth.existingSecret }}
190+
key: {{ .Values.redis.auth.existingSecretPasswordKey }}
191+
{{- else }}
192+
- name: REDIS_HOST_PASSWORD
193+
value: {{ .Values.redis.auth.password }}
194+
{{- end }}
195+
- name: REDIS_URL
196+
value: "redis://:$(REDIS_HOST_PASSWORD)@$(REDIS_HOST):$(REDIS_HOST_PORT)"
197+
{{- else }}
198+
- name: REDIS_URL
199+
value: "redis://$(REDIS_HOST):$(REDIS_HOST_PORT)"
200+
{{- end }}
201+
{{- end }}
202+
203+
{{- define "nextcloud.env" -}}
204+
{{- if .Values.phpClientHttpsFix.enabled }}
205+
- name: OVERWRITEPROTOCOL
206+
value: {{ .Values.phpClientHttpsFix.protocol | quote }}
169207
{{- end }}
208+
{{- template "nextcloud.env.database" . }}
170209
- name: NEXTCLOUD_ADMIN_USER
171210
valueFrom:
172211
secretKeyRef:
@@ -216,26 +255,8 @@ Create environment variables used to configure the nextcloud container as well a
216255
name: {{ .Values.nextcloud.existingSecret.secretName | default (include "nextcloud.fullname" .) }}
217256
key: {{ .Values.nextcloud.existingSecret.smtpPasswordKey }}
218257
{{- end }}
219-
{{/*
220-
Redis env vars
221-
*/}}
222258
{{- 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 }}
259+
{{ template "nextcloud.env.redis" . }}
239260
{{- end }}{{/* end if redis.enabled */}}
240261
{{/*
241262
S3 as primary object store env vars
@@ -342,7 +363,6 @@ Swift as primary object store env vars
342363
{{- end }}
343364
{{- end -}}
344365

345-
346366
{{/*
347367
Create volume mounts for the nextcloud container as well as the cron sidecar container.
348368
*/}}

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
@@ -286,45 +292,30 @@ spec:
286292
{{- end }}
287293
{{- if .Values.mariadb.enabled }}
288294
- name: mariadb-isalive
289-
image: {{ .Values.mariadb.image.registry | default "docker.io" }}/{{ .Values.mariadb.image.repository }}:{{ .Values.mariadb.image.tag }}
295+
image: {{ .Values.mariadb.image.registry }}/{{ .Values.mariadb.image.repository }}:{{ .Values.mariadb.image.tag }}
290296
{{- with .Values.nextcloud.mariaDbInitContainer }}
291297
resources:
292298
{{- toYaml .resources | nindent 12 }}
293299
securityContext:
294300
{{- toYaml .securityContext | nindent 12 }}
295301
{{- end }}
296302
env:
297-
- name: MYSQL_USER
298-
valueFrom:
299-
secretKeyRef:
300-
name: {{ .Values.externalDatabase.existingSecret.secretName | default (printf "%s-db" .Release.Name) }}
301-
key: {{ .Values.externalDatabase.existingSecret.usernameKey }}
302-
- name: MYSQL_PASSWORD
303-
valueFrom:
304-
secretKeyRef:
305-
name: {{ .Values.externalDatabase.existingSecret.secretName | default (printf "%s-db" .Release.Name) }}
306-
key: {{ .Values.externalDatabase.existingSecret.passwordKey }}
303+
{{- include "nextcloud.env.database" . | nindent 12 }}
307304
command:
308305
- "sh"
309306
- "-c"
310-
- {{ 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 }}
307+
- {{ printf "until mysql --host=${MYSQL_HOST} --user=${MYSQL_USER} --password=${MYSQL_PASSWORD} --execute=\"SELECT 1;\"; do echo waiting for mysql; sleep 2; done;" }}
311308
{{- else if .Values.postgresql.enabled }}
312309
- name: postgresql-isready
313-
image: {{ .Values.postgresql.image.registry | default "docker.io" }}/{{ .Values.postgresql.image.repository }}:{{ .Values.postgresql.image.tag }}
310+
image: {{ .Values.postgresql.image.registry }}/{{ .Values.postgresql.image.repository }}:{{ .Values.postgresql.image.tag }}
314311
{{- with .Values.nextcloud.postgreSqlInitContainer }}
315312
resources:
316313
{{- toYaml .resources | nindent 12 }}
317314
securityContext:
318315
{{- toYaml .securityContext | nindent 12 }}
319316
{{- end }}
320317
env:
321-
- name: POSTGRES_USER
322-
valueFrom:
323-
secretKeyRef:
324-
name: {{ .Values.externalDatabase.existingSecret.secretName | default (printf "%s-db" .Release.Name) }}
325-
key: {{ .Values.externalDatabase.existingSecret.usernameKey }}
326-
- name: POSTGRES_HOST
327-
value: {{ template "postgresql.v1.primary.fullname" .Subcharts.postgresql }}
318+
{{- include "nextcloud.env.database" . | nindent 12 }}
328319
command:
329320
- "sh"
330321
- "-c"
@@ -367,6 +358,15 @@ spec:
367358
configMap:
368359
name: {{ template "nextcloud.fullname" . }}-nginxconfig
369360
{{- end }}
361+
{{- if and .Values.notifyPush.enabled .Values.notifyPush.autoSetup }}
362+
- name: nextcloud-notify-hooks
363+
configMap:
364+
name: {{ template "nextcloud.fullname" . }}-notify-push
365+
defaultMode: 0o755
366+
items:
367+
- key: hook.sh
368+
path: notify_push.sh
369+
{{- end }}
370370
{{- if not (values .Values.nextcloud.hooks | compact | empty) }}
371371
- name: nextcloud-hooks
372372
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 }}
Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,32 @@
11
{{- if .Values.metrics.enabled }}
2+
{{- with .Values.metrics.service }}
23
---
34
apiVersion: v1
45
kind: Service
56
metadata:
6-
name: {{ template "nextcloud.fullname" . }}-metrics
7+
name: {{ template "nextcloud.fullname" $ }}-metrics
78
labels:
89
{{- include "nextcloud.labels" ( dict "component" "metrics" "rootContext" $ ) | nindent 4 }}
9-
{{- with .Values.metrics.service.labels }}
10+
app.kubernetes.io/monitor: enabled
11+
{{- with .labels }}
1012
{{- toYaml . | nindent 4 }}
1113
{{- end }}
12-
{{- with .Values.metrics.service.annotations }}
14+
{{- with .annotations }}
1315
annotations:
1416
{{- toYaml . | nindent 4 }}
1517
{{- end }}
1618
spec:
17-
type: {{ .Values.metrics.service.type }}
18-
{{- if eq .Values.metrics.service.type "LoadBalancer" }}
19-
{{- with .Values.metrics.service.loadBalancerIP }}
19+
type: {{ .type }}
20+
{{- if eq .type "LoadBalancer" }}
21+
{{- with .loadBalancerIP }}
2022
loadBalancerIP: {{ . }}
2123
{{- end }}
2224
{{- end }}
25+
selector:
26+
{{- include "nextcloud.selectorLabels" ( dict "component" "metrics" "rootContext" $ ) | nindent 4 }}
2327
ports:
2428
- name: metrics
25-
port: 9205
29+
port: 9100
2630
targetPort: metrics
27-
selector:
28-
{{- include "nextcloud.selectorLabels" ( dict "component" "metrics" "rootContext" $ ) | nindent 4 }}
31+
{{- end }}
2932
{{- end }}

0 commit comments

Comments
 (0)