Skip to content

Commit 7e87bbf

Browse files
Merge pull request #740 from Manuelraa/cronjob-instead-of-crond
feat: add option to run cronjob as CronJob instead of sidecar
2 parents 714c4f2 + 81c85ca commit 7e87bbf

File tree

9 files changed

+410
-209
lines changed

9 files changed

+410
-209
lines changed

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+
## v8
8+
- `cronjob.command` was renamed to `cronjob.sidecar.command` to avoid confusion with the cronjob command. Please update your `values.yaml` accordingly.
9+
710
## v7
811

912
- update redis to v20 (see [CHANGELOG](https://github.com/bitnami/charts/blob/main/bitnami/redis/CHANGELOG.md#2000-2024-08-09))

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.4
3+
version: 8.0.0
44
# renovate: image=docker.io/library/nextcloud
55
appVersion: 31.0.8
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: 171 additions & 158 deletions
Large diffs are not rendered by default.

charts/nextcloud/templates/_helpers.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,4 +448,4 @@ app.kubernetes.io/managed-by: {{ .rootContext.Release.Service }}
448448
{{- with .rootContext.Chart.AppVersion }}
449449
app.kubernetes.io/version: {{ quote . }}
450450
{{- end }}
451-
{{- end -}}
451+
{{- end -}}
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
---
2+
{{- if and .Values.cronjob.enabled (eq .Values.cronjob.type "cronjob") }}
3+
{{- with .Values.cronjob.cronjob }}{{/* begin with cronjob */}}
4+
apiVersion: batch/v1
5+
kind: CronJob
6+
metadata:
7+
name: {{ template "nextcloud.fullname" $ }}-cron
8+
labels:
9+
{{- include "nextcloud.labels" ( dict "component" "cron" "rootContext" $ ) | nindent 4 }}
10+
{{- with .labels }}
11+
{{- toYaml . | nindent 4 }}
12+
{{- end }}
13+
{{- with .annotations }}
14+
annotations:
15+
{{- toYaml . | nindent 4 }}
16+
{{- end }}
17+
spec:
18+
schedule: {{ .schedule | quote }}
19+
concurrencyPolicy: Forbid
20+
successfulJobsHistoryLimit: {{ .successfulJobsHistoryLimit }}
21+
failedJobsHistoryLimit: {{ .failedJobsHistoryLimit }}
22+
jobTemplate:
23+
metadata:
24+
labels:
25+
{{- include "nextcloud.selectorLabels" ( dict "component" "cron" "rootContext" $ ) | nindent 8 }}
26+
{{- with $.Values.podLabels }}
27+
{{- toYaml . | nindent 8 }}
28+
{{- end }}
29+
spec:
30+
backoffLimit: {{ .backoffLimit }}
31+
template:
32+
spec:
33+
restartPolicy: Never
34+
containers:
35+
- name: {{ $.Chart.Name }}-cron
36+
image: {{ include "nextcloud.image" $ }}
37+
imagePullPolicy: {{ $.Values.image.pullPolicy }}
38+
command:
39+
{{- toYaml .commandCronJob | nindent 16 }}
40+
env:
41+
{{- include "nextcloud.env" $ | nindent 16 }}
42+
resources:
43+
{{- toYaml .resources | nindent 16 }}
44+
{{- with .securityContext }}
45+
securityContext:
46+
{{- toYaml . | nindent 16 }}
47+
{{- end }}
48+
volumeMounts:
49+
{{- include "nextcloud.volumeMounts" $ | trim | nindent 16 }}
50+
{{- with $.Values.nodeSelector }}
51+
nodeSelector:
52+
{{- toYaml . | nindent 12 }}
53+
{{- end }}
54+
{{- with .affinity }}
55+
affinity:
56+
{{- toYaml . | nindent 12 }}
57+
{{- end }}
58+
{{- with $.Values.tolerations }}
59+
tolerations:
60+
{{- toYaml . | nindent 12 }}
61+
{{- end }}
62+
{{- end }}{{/* end with cronjob */}}
63+
volumes:
64+
- name: nextcloud-main
65+
{{- if .Values.persistence.enabled }}
66+
persistentVolumeClaim:
67+
claimName: {{ if .Values.persistence.existingClaim }}{{ .Values.persistence.existingClaim }}{{- else }}{{ template "nextcloud.fullname" . }}-nextcloud{{- end }}
68+
{{- else }}
69+
emptyDir: {}
70+
{{- end }}
71+
{{- if and .Values.persistence.nextcloudData.enabled .Values.persistence.enabled }}
72+
- name: nextcloud-data
73+
persistentVolumeClaim:
74+
claimName: {{ if .Values.persistence.nextcloudData.existingClaim }}{{ .Values.persistence.nextcloudData.existingClaim }}{{- else }}{{ template "nextcloud.fullname" . }}-nextcloud-data{{- end }}
75+
{{- end }}
76+
{{- if .Values.nextcloud.configs }}
77+
- name: nextcloud-config
78+
configMap:
79+
name: {{ template "nextcloud.fullname" . }}-config
80+
{{- end }}
81+
{{- if .Values.nextcloud.phpConfigs }}
82+
- name: nextcloud-phpconfig
83+
configMap:
84+
name: {{ template "nextcloud.fullname" . }}-phpconfig
85+
{{- end }}
86+
{{- if .Values.nginx.enabled }}
87+
- name: nextcloud-nginx-config
88+
configMap:
89+
name: {{ template "nextcloud.fullname" . }}-nginxconfig
90+
{{- end }}
91+
{{- if not (values .Values.nextcloud.hooks | compact | empty) }}
92+
- name: nextcloud-hooks
93+
configMap:
94+
name: {{ template "nextcloud.fullname" . }}-hooks
95+
defaultMode: 0o755
96+
{{- end }}
97+
{{- with .Values.nextcloud.extraVolumes }}
98+
{{- toYaml . | nindent 12 }}
99+
{{- end }}
100+
securityContext:
101+
{{- with .Values.securityContext }}
102+
{{- toYaml . | nindent 12 }}
103+
{{- end }}
104+
{{- with .Values.nextcloud.podSecurityContext }}
105+
{{- toYaml . | nindent 12 }}
106+
{{- else }}
107+
{{- if .Values.nginx.enabled }}
108+
# Will mount configuration files as www-data (id: 82) for nextcloud
109+
fsGroup: 82
110+
{{- else }}
111+
# Will mount configuration files as www-data (id: 33) for nextcloud
112+
fsGroup: 33
113+
{{- end }}
114+
{{- end }}{{/* end-with podSecurityContext */}}
115+
{{- if .Values.rbac.enabled }}
116+
serviceAccountName: {{ .Values.rbac.serviceaccount.name }}
117+
{{- end }}
118+
{{- with .Values.dnsConfig }}
119+
dnsConfig:
120+
{{- toYaml . | nindent 12 }}
121+
{{- end }}
122+
{{- end }}

charts/nextcloud/templates/deployment.yaml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,14 @@ spec:
240240
{{- toYaml . | nindent 12 }}
241241
{{- end }}
242242
{{- end }}{{/* end-if nginx.enabled */}}
243-
{{- if .Values.cronjob.enabled }}
244-
- name: {{ .Chart.Name }}-cron
245-
image: {{ include "nextcloud.image" . }}
246-
imagePullPolicy: {{ .Values.image.pullPolicy }}
243+
{{- if and .Values.cronjob.enabled (eq .Values.cronjob.type "sidecar") }}
244+
{{- with .Values.cronjob.sidecar }}
245+
- name: {{ $.Chart.Name }}-cron
246+
image: {{ include "nextcloud.image" $ }}
247+
imagePullPolicy: {{ $.Values.image.pullPolicy }}
247248
command:
248-
{{- toYaml .Values.cronjob.command | nindent 12 }}
249-
{{- with .Values.cronjob.lifecycle }}
249+
{{- toYaml .command | nindent 12 }}
250+
{{- with .lifecycle }}
250251
lifecycle:
251252
{{- with .postStartCommand }}
252253
postStart:
@@ -262,15 +263,16 @@ spec:
262263
{{- end }}
263264
{{- end }}
264265
env:
265-
{{- include "nextcloud.env" . | nindent 12 }}
266+
{{- include "nextcloud.env" $ | nindent 12 }}
266267
resources:
267-
{{- toYaml .Values.cronjob.resources | nindent 12 }}
268-
{{- with .Values.cronjob.securityContext }}
268+
{{- toYaml .resources | nindent 12 }}
269+
{{- with .securityContext }}
269270
securityContext:
270271
{{- toYaml . | nindent 12 }}
271272
{{- end }}
272273
volumeMounts:
273-
{{- include "nextcloud.volumeMounts" . | trim | nindent 12 }}
274+
{{- include "nextcloud.volumeMounts" $ | trim | nindent 12 }}
275+
{{- end }}
274276
{{- end }}{{/* end-if cronjob.enabled */}}
275277
{{- with .Values.nextcloud.extraSidecarContainers }}
276278
{{- toYaml . | nindent 8 }}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
cronjob:
2+
enabled: true
3+
type: cronjob
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
cronjob:
2+
enabled: true

0 commit comments

Comments
 (0)