From 87dc2b77b76a55e19aa92b6d898c2db63a4e2bfb Mon Sep 17 00:00:00 2001
From: Janne Mareike Koschinski <janne@kuschku.de>
Date: Sun, 12 Mar 2023 16:19:04 +0100
Subject: [PATCH] feat: add gc cronjob for seafile

---
 seafile/Chart.yaml             |  2 +-
 seafile/templates/cronjob.yaml | 88 ++++++++++++++++++++++++++++++++++
 seafile/values.yaml            |  2 +
 3 files changed, 91 insertions(+), 1 deletion(-)
 create mode 100644 seafile/templates/cronjob.yaml

diff --git a/seafile/Chart.yaml b/seafile/Chart.yaml
index b4df6a5..815dd4a 100644
--- a/seafile/Chart.yaml
+++ b/seafile/Chart.yaml
@@ -2,5 +2,5 @@ apiVersion: v2
 name: seafile
 description: Helm Chart for seafile
 type: application
-version: 0.1.5
+version: 0.1.6
 appVersion: "4d64355e"
diff --git a/seafile/templates/cronjob.yaml b/seafile/templates/cronjob.yaml
new file mode 100644
index 0000000..ca884f4
--- /dev/null
+++ b/seafile/templates/cronjob.yaml
@@ -0,0 +1,88 @@
+apiVersion: batch/v1
+kind: CronJob
+metadata:
+  name: {{ include "seafile-helm.fullname" . }}
+  labels:
+    {{- include "seafile-helm.labels" . | nindent 4 }}
+spec:
+  concurrencyPolicy: Forbid
+  jobTemplate:
+    metadata:
+      {{- with .Values.jobAnnotations }}
+      annotations:
+        {{- toYaml . | nindent 8 }}
+      {{- end }}
+      labels:
+        {{- include "seafile-helm.labels" . | nindent 8 }}
+    spec:
+      template:
+        metadata:
+          {{- with .Values.podAnnotations }}
+          annotations:
+            {{- toYaml . | nindent 12 }}
+          {{- end }}
+          labels:
+            {{- include "seafile-helm.labels" . | nindent 12 }}
+        spec:
+          restartPolicy: OnFailure
+          {{- with .Values.imagePullSecrets }}
+          imagePullSecrets:
+            {{- toYaml . | nindent 12 }}
+          {{- end }}
+          securityContext:
+            {{- toYaml .Values.podSecurityContext | nindent 12 }}
+          volumes:
+            - name: seafile
+              {{- .Values.seafile.volume | nindent 14 }}
+            - name: config
+              secret:
+                secretName: {{ include "seafile-helm.fullname" . }}
+            - name: tmp
+              emptyDir: {}
+          containers:
+            - name: seafile
+              command:
+                - "seafserv-gc"
+              args:
+                - "-c"
+                - "/conf"
+                - "-d"
+                - "/data"
+              securityContext:
+                {{- toYaml .Values.securityContext | nindent 16 }}
+              image: "{{ .Values.image.repository }}:server-{{ .Values.image.tag | default .Chart.AppVersion }}"
+              imagePullPolicy: {{ .Values.image.pullPolicy }}
+              ports:
+                - name: seafhttp
+                  containerPort: 8082
+                  protocol: TCP
+              startupProbe:
+                tcpSocket:
+                  port: seafhttp
+              livenessProbe:
+                tcpSocket:
+                  port: seafhttp
+              readinessProbe:
+                tcpSocket:
+                  port: seafhttp
+              resources:
+                {{- toYaml .Values.resources | nindent 16 }}
+              volumeMounts:
+                - mountPath: "/data"
+                  name: seafile
+                - mountPath: "/conf"
+                  name: config
+                - mountPath: "/tmp"
+                  name: tmp
+          {{- with .Values.nodeSelector }}
+          nodeSelector:
+            {{- toYaml . | nindent 12 }}
+          {{- end }}
+          {{- with .Values.affinity }}
+          affinity:
+            {{- toYaml . | nindent 12 }}
+          {{- end }}
+          {{- with .Values.tolerations }}
+          tolerations:
+            {{- toYaml . | nindent 12 }}
+          {{- end }}
diff --git a/seafile/values.yaml b/seafile/values.yaml
index 9720bdd..2c52966 100644
--- a/seafile/values.yaml
+++ b/seafile/values.yaml
@@ -89,6 +89,8 @@ resources:
     cpu: 200m
     memory: 500Mi
 
+jobAnnotations: { }
+
 podAnnotations: { }
 
 podSecurityContext:
-- 
GitLab