Skip to content

Commit

Permalink
feat(nextcloud): add notify_push support
Browse files Browse the repository at this point in the history
Signed-off-by: WrenIX <[email protected]>
  • Loading branch information
wrenix committed Jun 9, 2024
1 parent 3dfd22e commit 4c3cee5
Show file tree
Hide file tree
Showing 8 changed files with 213 additions and 44 deletions.
2 changes: 1 addition & 1 deletion charts/nextcloud/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: nextcloud
version: 5.0.0
version: 5.1.0
appVersion: 29.0.1
description: A file sharing server that puts the control and security of your own data back into your hands.
keywords:
Expand Down
21 changes: 15 additions & 6 deletions charts/nextcloud/templates/db-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,23 @@ metadata:
type: Opaque
data:
{{- if .Values.mariadb.enabled }}
db-username: {{ .Values.mariadb.auth.username | b64enc | quote }}
db-password: {{ .Values.mariadb.auth.password | b64enc | quote }}
{{- with .Values.mariadb.auth }}
db-username: {{ .username | b64enc | quote }}
db-password: {{ .password | b64enc | quote }}
db-url: {{ printf "mysql://%s:%s@%s/%s" .username .password (template "mariadb.primary.fullname" $.Subcharts.mariadb) .database | b64enc | quote }}
{{- end }}
{{- else if .Values.postgresql.enabled }}
db-username: {{ .Values.postgresql.global.postgresql.auth.username | b64enc | quote }}
db-password: {{ .Values.postgresql.global.postgresql.auth.password | b64enc | quote }}
{{- with .Values.postgresql.global.postgresql.auth }}
db-username: {{ .username | b64enc | quote }}
db-password: {{ .password | b64enc | quote }}
db-url: {{ printf "postgres://%s:%s@%s/%s" .username .password (template "postgresql.v1.primary.fullname" $.Subcharts.postgresql) .database | b64enc | quote }}
{{- end }}
{{- else }}
db-username: {{ .Values.externalDatabase.user | b64enc | quote }}
db-password: {{ .Values.externalDatabase.password | b64enc | quote }}
{{- with .Values.externalDatabase }}
db-username: {{ .user | b64enc | quote }}
db-password: {{ .password | b64enc | quote }}
db-url: {{ printf "%s://%s:%s@%s/%s" .type .user .password .host .database | b64enc | quote }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
9 changes: 9 additions & 0 deletions charts/nextcloud/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ spec:
serviceName: {{ template "nextcloud.fullname" . }}
servicePort: {{ .Values.service.port }}
{{- end }}
{{- if .Values.notifyPush.enabled }}
- path: {{ .Values.notifyPush.ingress.path }}
pathType: {{ .Values.notifyPush.ingress.pathType }}
backend:
service:
name: {{ template "nextcloud.fullname" . }}-notify-push
port:
name: http
{{- end }}
{{- with .Values.ingress.tls }}
tls:
{{- toYaml . | nindent 4 }}
Expand Down
33 changes: 18 additions & 15 deletions charts/nextcloud/templates/metrics/service.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
{{- if .Values.metrics.enabled }}
{{- with .Values.metrics.service }}
---
apiVersion: v1
kind: Service
metadata:
name: {{ template "nextcloud.fullname" . }}-metrics
name: {{ template "nextcloud.fullname" $ }}-metrics
labels:
app.kubernetes.io/name: {{ include "nextcloud.name" . }}
helm.sh/chart: {{ include "nextcloud.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/name: {{ include "nextcloud.name" $ }}
helm.sh/chart: {{ include "nextcloud.chart" $ }}
app.kubernetes.io/instance: {{ $.Release.Name }}
app.kubernetes.io/managed-by: {{ $.Release.Service }}
app.kubernetes.io/component: metrics
{{- with .Values.metrics.service.labels }}
app.kubernetes.io/monitor: enabled
{{- with .labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.metrics.service.annotations }}
{{- with .annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.metrics.service.type }}
{{- if eq .Values.metrics.service.type "LoadBalancer" }}
{{- with .Values.metrics.service.loadBalancerIP }}
type: {{ .type }}
{{- if eq .type "LoadBalancer" }}
{{- with .loadBalancerIP }}
loadBalancerIP: {{ . }}
{{- end }}
{{- end }}
selector:
app.kubernetes.io/name: {{ include "nextcloud.name" $ }}
app.kubernetes.io/instance: {{ $.Release.Name }}
app.kubernetes.io/component: metrics
ports:
- name: metrics
port: 9205
port: 9100
targetPort: metrics
selector:
app.kubernetes.io/name: {{ include "nextcloud.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: metrics
{{- end }}
{{- end }}
37 changes: 19 additions & 18 deletions charts/nextcloud/templates/metrics/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -1,40 +1,41 @@
{{- if and .Values.metrics.enabled .Values.metrics.serviceMonitor.enabled }}
{{- with .Values.prometheus.serviceMonitor }}
{{- if .enabled }}
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "nextcloud.fullname" . }}
namespace: {{ .Values.metrics.serviceMonitor.namespace | default .Release.Namespace | quote }}
name: {{ template "nextcloud.fullname" $ }}
namespace: {{ .namespace | default $.Release.Namespace | quote }}
labels:
app.kubernetes.io/name: {{ include "nextcloud.name" . }}
helm.sh/chart: {{ include "nextcloud.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/component: metrics
{{- with .Values.metrics.serviceMonitor.labels }}
app.kubernetes.io/name: {{ include "nextcloud.name" $ }}
helm.sh/chart: {{ include "nextcloud.chart" $ }}
app.kubernetes.io/instance: {{ $.Release.Name }}
app.kubernetes.io/managed-by: {{ $.Release.Service }}
{{- with .labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
jobLabel: {{ .Values.metrics.serviceMonitor.jobLabel | quote }}
jobLabel: {{ .jobLabel | quote }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "nextcloud.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: metrics
app.kubernetes.io/name: {{ include "nextcloud.name" $ }}
app.kubernetes.io/instance: {{ $.Release.Name }}
app.kubernetes.io/monitor: enabled
namespaceSelector:
{{- with .Values.metrics.serviceMonitor.namespaceSelector }}
{{- with .namespaceSelector }}
{{- toYaml . | nindent 4 }}
{{- else }}
matchNames:
- {{ .Release.Namespace | quote }}
- {{ $.Release.Namespace | quote }}
{{- end }}
endpoints:
- port: metrics
path: "/"
{{- with .Values.metrics.serviceMonitor.interval }}
path: "/metrics"
{{- with .interval }}
interval: {{ . }}
{{- end }}
{{- with .Values.metrics.serviceMonitor.scrapeTimeout }}
{{- with .scrapeTimeout }}
scrapeTimeout: {{ . }}
{{- end }}
{{- end }}
{{- end }}
68 changes: 68 additions & 0 deletions charts/nextcloud/templates/notify_push/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{{- if .Values.notifyPush.enabled }}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "nextcloud.fullname" . }}-notify-push
labels:
app.kubernetes.io/name: {{ include "nextcloud.name" . }}
helm.sh/chart: {{ include "nextcloud.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/component: notify-push
spec:
replicas: {{ .Values.notifyPush.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "nextcloud.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: notify-push
template:
metadata:
annotations:
{{- toYaml .Values.notifyPush.podAnnotations | nindent 8 }}
labels:
app.kubernetes.io/name: {{ include "nextcloud.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: notify-push
{{- with .Values.notifyPush.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.notifyPush.image.pullSecrets }}
imagePullSecrets:
{{- range . }}
- name: {{ . }}
{{- end}}
{{- end }}
containers:
- name: notify-push
image: "{{ .Values.metrics.image.repository }}:{{ .Values.metrics.image.tag }}"
imagePullPolicy: {{ .Values.metrics.image.pullPolicy }}
env:
- name: PORT
value: "7867"
- name: METRICS_PORT
value: "9867"
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: {{ .Values.externalDatabase.existingSecret.secretName | default (printf "%s-db" .Release.Name) }}
key: {{ .Values.externalDatabase.existingSecret.databaseURLKey }}
- name: REDIS_URL
value: "redis://{{ template "nextcloud.redis.fullname" . }}-master:{{ .Values.redis.master.service.ports.redis | quote }}"
- name: NEXTCLOUD_URL # deployment.namespace.svc.cluster.local
value: "http{{ if .Values.notifyPush.https }}s{{ end }}://{{ template "nextcloud.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local:{{ .Values.service.port }}"
ports:
- name: http
containerPort: 7867
- name: metrics
containerPort: 9867
{{- with .Values.notifyPush.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
securityContext:
runAsUser: 1000
runAsNonRoot: true
{{- end }}
41 changes: 41 additions & 0 deletions charts/nextcloud/templates/notify_push/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{{- if .Values.notifyPush.enabled }}
{{- with .Values.notifyPush.service }}
---
apiVersion: v1
kind: Service
metadata:
name: {{ template "nextcloud.fullname" $ }}-notify-push
labels:
app.kubernetes.io/name: {{ include "nextcloud.name" $ }}
helm.sh/chart: {{ include "nextcloud.chart" $ }}
app.kubernetes.io/instance: {{ $.Release.Name }}
app.kubernetes.io/managed-by: {{ $.Release.Service }}
app.kubernetes.io/component: notify-push
app.kubernetes.io/monitor: enabled
{{- with .labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: {{ .type }}
{{- if eq .type "LoadBalancer" }}
{{- with .loadBalancerIP }}
loadBalancerIP: {{ . }}
{{- end }}
{{- end }}
selector:
app.kubernetes.io/name: {{ include "nextcloud.name" $ }}
app.kubernetes.io/instance: {{ $.Release.Name }}
app.kubernetes.io/component: notify-push
ports:
- name: http
port: 80
targetPort: http
- name: metrics
port: 9100
targetPort: metrics
{{- end }}
{{- end }}
46 changes: 42 additions & 4 deletions charts/nextcloud/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,16 @@ externalDatabase:
## Use a existing secret
existingSecret:
enabled: false
# secretName: nameofsecret
# -- e.g. nameofsecret
secretName:
usernameKey: db-username
passwordKey: db-password
# hostKey: db-hostname-or-ip
# databaseKey: db-name
# -- e.g. db-hostname-or-ip
hostKey:
# -- e.g. db-name
databaseKey:
# -- complete URL with type, username and password (current only for notify_push used)
databaseURLKey: db-url

##
## MariaDB chart configuration
Expand Down Expand Up @@ -479,6 +484,37 @@ tolerations: []

affinity: {}

# Notify Push (Clientpush)
notifyPush:
enabled: false

replicaCount: 1

image:
registry: docker.io
repository: icewind1991/notify_push
tag: 0.6.11
pullPolicy: IfNotPresent
pullSecrets:
# - myRegistrKeySecretName

resources: {}

podAnnotations: {}
podLabels: {}

service:
type: ClusterIP
# -- Use serviceLoadBalancerIP to request a specific static IP, otherwise leave blank
loadBalancerIP:
annotations: {}
labels: {}

ingress:
path: /push
pathType: Prefix



Check failure on line 518 in charts/nextcloud/values.yaml

View workflow job for this annotation

GitHub Actions / lint

518:1 [empty-lines] too many blank lines (3 > 2)
## Prometheus Exporter / Metrics
##
Expand Down Expand Up @@ -523,8 +559,10 @@ metrics:
prometheus.io/port: "9205"
labels: {}

#
prometheus:
## Prometheus Operator ServiceMonitor configuration
##
## collects data from nextcloud metrics and notify_push if enabled
serviceMonitor:
## @param metrics.serviceMonitor.enabled Create ServiceMonitor Resource for scraping metrics using PrometheusOperator
##
Expand Down

0 comments on commit 4c3cee5

Please sign in to comment.