Skip to content

Commit 43ba133

Browse files
committed
feat(nextcloud): add notify_push support
Signed-off-by: Jesse Hitch <[email protected]> Signed-off-by: WrenIX <[email protected]>
1 parent c78a292 commit 43ba133

File tree

14 files changed

+286
-72
lines changed

14 files changed

+286
-72
lines changed

.github/workflows/lint-test.yaml

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

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

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: 6.2.4
3+
version: 7.0.0
44
appVersion: 30.0.2
55
description: A file sharing server that puts the control and security of your own data back into your hands.
66
keywords:
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
/var/www/html/occ app:install notify_push
3+
/var/www/html/occ notify_push:setup --server "https://{{ .Values.nextcloud.host }}{{ .Values.notifyPush.ingress.path }}"

charts/nextcloud/templates/db-secret.yaml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,23 @@ metadata:
1313
type: Opaque
1414
data:
1515
{{- if .Values.mariadb.enabled }}
16-
db-username: {{ .Values.mariadb.auth.username | b64enc | quote }}
17-
db-password: {{ .Values.mariadb.auth.password | b64enc | quote }}
16+
{{- with .Values.mariadb.auth }}
17+
db-username: {{ .username | b64enc | quote }}
18+
db-password: {{ .password | b64enc | quote }}
19+
db-url: {{ printf "mysql://%s:%s@%s/%s" .username .password (include "mariadb.primary.fullname" $.Subcharts.mariadb) .database | b64enc | quote }}
20+
{{- end }}
1821
{{- else if .Values.postgresql.enabled }}
19-
db-username: {{ .Values.postgresql.global.postgresql.auth.username | b64enc | quote }}
20-
db-password: {{ .Values.postgresql.global.postgresql.auth.password | b64enc | quote }}
22+
{{- with .Values.postgresql.global.postgresql.auth }}
23+
db-username: {{ .username | b64enc | quote }}
24+
db-password: {{ .password | b64enc | quote }}
25+
db-url: {{ printf "postgres://%s:%s@%s/%s" .username .password (include "postgresql.v1.primary.fullname" $.Subcharts.postgresql) .database | b64enc | quote }}
26+
{{- end }}
2127
{{- else }}
22-
db-username: {{ .Values.externalDatabase.user | b64enc | quote }}
23-
db-password: {{ .Values.externalDatabase.password | b64enc | quote }}
28+
{{- with .Values.externalDatabase }}
29+
db-username: {{ .user | b64enc | quote }}
30+
db-password: {{ .password | b64enc | quote }}
31+
db-url: {{ printf "%s://%s:%s@%s/%s" .type .user .password .host .database | b64enc | quote }}
32+
{{- end }}
2433
{{- end }}
2534
{{- end }}
2635
{{- end }}

charts/nextcloud/templates/deployment.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,12 @@ spec:
139139
{{- end }}
140140
volumeMounts:
141141
{{- include "nextcloud.volumeMounts" . | trim | nindent 12 }}
142+
{{- if and .Values.notifyPush.enabled .Values.notifyPush.autoSetup }}
143+
- name: nextcloud-notify-hooks
144+
mountPath: /docker-entrypoint-hooks.d/before-starting/notify_push.sh
145+
subPath: notify_push.sh
146+
readOnly: true
147+
{{- end }}
142148
{{- range $hook, $shell := .Values.nextcloud.hooks }}
143149
{{- if $shell }}
144150
- name: nextcloud-hooks
@@ -371,6 +377,15 @@ spec:
371377
configMap:
372378
name: {{ template "nextcloud.fullname" . }}-nginxconfig
373379
{{- end }}
380+
{{- if and .Values.notifyPush.enabled .Values.notifyPush.autoSetup }}
381+
- name: nextcloud-notify-hooks
382+
configMap:
383+
name: {{ template "nextcloud.fullname" . }}-notify-push
384+
defaultMode: 0o755
385+
items:
386+
- key: hook.sh
387+
path: notify_push.sh
388+
{{- end }}
374389
{{- if not (values .Values.nextcloud.hooks | compact | empty) }}
375390
- name: nextcloud-hooks
376391
configMap:

charts/nextcloud/templates/ingress.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ spec:
3939
serviceName: {{ template "nextcloud.fullname" . }}
4040
servicePort: {{ .Values.service.port }}
4141
{{- end }}
42+
{{- if .Values.notifyPush.enabled }}
43+
- path: {{ .Values.notifyPush.ingress.path }}
44+
pathType: {{ .Values.notifyPush.ingress.pathType }}
45+
backend:
46+
service:
47+
name: {{ template "nextcloud.fullname" . }}-notify-push
48+
port:
49+
name: http
50+
{{- end }}
4251
{{- with .Values.ingress.tls }}
4352
tls:
4453
{{- toYaml . | nindent 4 }}
Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,38 @@
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:
8-
app.kubernetes.io/name: {{ include "nextcloud.name" . }}
9-
helm.sh/chart: {{ include "nextcloud.chart" . }}
10-
app.kubernetes.io/instance: {{ .Release.Name }}
11-
app.kubernetes.io/managed-by: {{ .Release.Service }}
9+
app.kubernetes.io/name: {{ include "nextcloud.name" $ }}
10+
helm.sh/chart: {{ include "nextcloud.chart" $ }}
11+
app.kubernetes.io/instance: {{ $.Release.Name }}
12+
app.kubernetes.io/managed-by: {{ $.Release.Service }}
1213
app.kubernetes.io/component: metrics
13-
{{- with .Values.metrics.service.labels }}
14+
app.kubernetes.io/monitor: enabled
15+
{{- with .labels }}
1416
{{- toYaml . | nindent 4 }}
1517
{{- end }}
16-
{{- with .Values.metrics.service.annotations }}
18+
{{- with .annotations }}
1719
annotations:
1820
{{- toYaml . | nindent 4 }}
1921
{{- end }}
2022
spec:
21-
type: {{ .Values.metrics.service.type }}
22-
{{- if eq .Values.metrics.service.type "LoadBalancer" }}
23-
{{- with .Values.metrics.service.loadBalancerIP }}
23+
type: {{ .type }}
24+
{{- if eq .type "LoadBalancer" }}
25+
{{- with .loadBalancerIP }}
2426
loadBalancerIP: {{ . }}
2527
{{- end }}
2628
{{- end }}
29+
selector:
30+
app.kubernetes.io/name: {{ include "nextcloud.name" $ }}
31+
app.kubernetes.io/instance: {{ $.Release.Name }}
32+
app.kubernetes.io/component: metrics
2733
ports:
2834
- name: metrics
29-
port: 9205
35+
port: 9100
3036
targetPort: metrics
31-
selector:
32-
app.kubernetes.io/name: {{ include "nextcloud.name" . }}
33-
app.kubernetes.io/instance: {{ .Release.Name }}
34-
app.kubernetes.io/component: metrics
37+
{{- end }}
3538
{{- end }}

charts/nextcloud/templates/metrics/servicemonitor.yaml

Lines changed: 0 additions & 40 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{{- if and .Values.notifyPush.enabled .Values.notifyPush.autoSetup }}
2+
---
3+
apiVersion: v1
4+
kind: ConfigMap
5+
metadata:
6+
name: {{ template "nextcloud.fullname" . }}-notify-push
7+
labels:
8+
app.kubernetes.io/name: {{ include "nextcloud.name" . }}
9+
helm.sh/chart: {{ include "nextcloud.chart" . }}
10+
app.kubernetes.io/instance: {{ .Release.Name }}
11+
app.kubernetes.io/managed-by: {{ .Release.Service }}
12+
data:
13+
hook.sh: |-
14+
{{- tpl (.Files.Get "files/notify_push.sh.tpl" ) . | nindent 4 }}
15+
{{- end }}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{{- if .Values.notifyPush.enabled }}
2+
---
3+
apiVersion: apps/v1
4+
kind: Deployment
5+
metadata:
6+
name: {{ template "nextcloud.fullname" . }}-notify-push
7+
labels:
8+
app.kubernetes.io/name: {{ include "nextcloud.name" . }}
9+
helm.sh/chart: {{ include "nextcloud.chart" . }}
10+
app.kubernetes.io/instance: {{ .Release.Name }}
11+
app.kubernetes.io/managed-by: {{ .Release.Service }}
12+
app.kubernetes.io/component: notify-push
13+
spec:
14+
replicas: {{ .Values.notifyPush.replicaCount }}
15+
selector:
16+
matchLabels:
17+
app.kubernetes.io/name: {{ include "nextcloud.name" . }}
18+
app.kubernetes.io/instance: {{ .Release.Name }}
19+
app.kubernetes.io/component: notify-push
20+
template:
21+
metadata:
22+
annotations:
23+
{{- toYaml .Values.notifyPush.podAnnotations | nindent 8 }}
24+
labels:
25+
app.kubernetes.io/name: {{ include "nextcloud.name" . }}
26+
app.kubernetes.io/instance: {{ .Release.Name }}
27+
app.kubernetes.io/component: notify-push
28+
{{- with .Values.notifyPush.podLabels }}
29+
{{- toYaml . | nindent 8 }}
30+
{{- end }}
31+
spec:
32+
{{- with .Values.notifyPush.image.pullSecrets }}
33+
imagePullSecrets:
34+
{{- range . }}
35+
- name: {{ . }}
36+
{{- end}}
37+
{{- end }}
38+
containers:
39+
- name: notify-push
40+
{{- with .Values.notifyPush.image }}
41+
image: "{{ .registry }}/{{ .repository }}:{{ .tag }}"
42+
imagePullPolicy: {{ .pullPolicy }}
43+
{{- end }}
44+
env:
45+
- name: PORT
46+
value: "7867"
47+
- name: METRICS_PORT
48+
value: "9867"
49+
- name: DATABASE_URL
50+
valueFrom:
51+
secretKeyRef:
52+
name: {{ .Values.externalDatabase.existingSecret.secretName | default (printf "%s-db" .Release.Name) }}
53+
key: {{ .Values.externalDatabase.existingSecret.databaseURLKey }}
54+
- name: REDIS_URL
55+
value: "redis://{{ if .Values.redis.auth.enabled }}:{{ .Values.redis.auth.password }}@{{ end }}{{ template "nextcloud.redis.fullname" . }}-master:{{ .Values.redis.master.service.ports.redis }}"
56+
- name: NEXTCLOUD_URL # deployment.namespace.svc.cluster.local
57+
value: "http{{ if .Values.notifyPush.https }}s{{ end }}://{{ template "nextcloud.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local:{{ .Values.service.port }}"
58+
ports:
59+
- name: http
60+
containerPort: 7867
61+
- name: metrics
62+
containerPort: 9867
63+
{{- with .Values.notifyPush.resources }}
64+
resources:
65+
{{- toYaml . | nindent 12 }}
66+
{{- end }}
67+
securityContext:
68+
runAsUser: 1000
69+
runAsNonRoot: true
70+
{{- end }}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{{- if .Values.notifyPush.enabled }}
2+
{{- with .Values.notifyPush.service }}
3+
---
4+
apiVersion: v1
5+
kind: Service
6+
metadata:
7+
name: {{ template "nextcloud.fullname" $ }}-notify-push
8+
labels:
9+
app.kubernetes.io/name: {{ include "nextcloud.name" $ }}
10+
helm.sh/chart: {{ include "nextcloud.chart" $ }}
11+
app.kubernetes.io/instance: {{ $.Release.Name }}
12+
app.kubernetes.io/managed-by: {{ $.Release.Service }}
13+
app.kubernetes.io/component: notify-push
14+
app.kubernetes.io/monitor: enabled
15+
{{- with .labels }}
16+
{{- toYaml . | nindent 4 }}
17+
{{- end }}
18+
{{- with .annotations }}
19+
annotations:
20+
{{- toYaml . | nindent 4 }}
21+
{{- end }}
22+
spec:
23+
type: {{ .type }}
24+
{{- if eq .type "LoadBalancer" }}
25+
{{- with .loadBalancerIP }}
26+
loadBalancerIP: {{ . }}
27+
{{- end }}
28+
{{- end }}
29+
selector:
30+
app.kubernetes.io/name: {{ include "nextcloud.name" $ }}
31+
app.kubernetes.io/instance: {{ $.Release.Name }}
32+
app.kubernetes.io/component: notify-push
33+
ports:
34+
- name: http
35+
port: 80
36+
targetPort: http
37+
- name: metrics
38+
port: 9100
39+
targetPort: metrics
40+
{{- end }}
41+
{{- end }}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{{- with .Values.prometheus.serviceMonitor }}
2+
{{- if .enabled }}
3+
---
4+
apiVersion: monitoring.coreos.com/v1
5+
kind: ServiceMonitor
6+
metadata:
7+
name: {{ template "nextcloud.fullname" $ }}
8+
namespace: {{ .namespace | default $.Release.Namespace | quote }}
9+
labels:
10+
app.kubernetes.io/name: {{ include "nextcloud.name" $ }}
11+
helm.sh/chart: {{ include "nextcloud.chart" $ }}
12+
app.kubernetes.io/instance: {{ $.Release.Name }}
13+
app.kubernetes.io/managed-by: {{ $.Release.Service }}
14+
{{- with .labels }}
15+
{{- toYaml . | nindent 4 }}
16+
{{- end }}
17+
spec:
18+
jobLabel: {{ .jobLabel | quote }}
19+
selector:
20+
matchLabels:
21+
app.kubernetes.io/name: {{ include "nextcloud.name" $ }}
22+
app.kubernetes.io/instance: {{ $.Release.Name }}
23+
app.kubernetes.io/monitor: enabled
24+
namespaceSelector:
25+
{{- with .namespaceSelector }}
26+
{{- toYaml . | nindent 4 }}
27+
{{- else }}
28+
matchNames:
29+
- {{ $.Release.Namespace | quote }}
30+
{{- end }}
31+
endpoints:
32+
- port: metrics
33+
path: "/metrics"
34+
{{- with .interval }}
35+
interval: {{ . }}
36+
{{- end }}
37+
{{- with .scrapeTimeout }}
38+
scrapeTimeout: {{ . }}
39+
{{- end }}
40+
{{- end }}
41+
{{- end }}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
notifyPush:
2+
enabled: true

0 commit comments

Comments
 (0)