feat(fireflyiii): add cron support (#1470)

* feat(fireflyiii): add cron support

* use curl for cron, add sercet for static cron token

* adjust dns name

* adjust schedule as per documentation

* simplify dns name

* make secret auto generated

* whoops

* actually load the secret

* remove whitespace

* use alpineImage

* autogen remembered sercret APP_KEY

* bump minor
This commit is contained in:
Stavros Kois 2021-12-07 12:45:24 +02:00 committed by GitHub
parent 5d761fb46f
commit 45619a6843
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 83 additions and 13 deletions

View File

@ -24,7 +24,7 @@ name: fireflyiii
sources:
- https://github.com/firefly-iii/firefly-iii/
type: application
version: 13.0.10
version: 13.1.0
annotations:
truecharts.org/catagories: |
- finacial

View File

@ -73,7 +73,6 @@ questions:
- value: "OnDelete"
description: "(Legacy) OnDelete: ignore .spec.template changes"
# Include{controllerExpert}
# Docker specific env
- variable: env
group: "Container Configuration"
label: "Image Environment"
@ -81,16 +80,7 @@ questions:
type: dict
attrs:
# Include{fixedEnv}
- variable: APP_KEY
label: "App Key"
description: "Your unique 32 application character key"
schema:
type: string
default: ""
min_length: 32
max_length: 32
valid_chars: '[a-zA-Z0-9!@#$%^&*?]{32}'
required: true
# Include{containerConfig}

View File

@ -0,0 +1,38 @@
{{/* Define the cronjob */}}
{{- define "fireflyiii.cronjob" -}}
{{- $jobName := include "common.names.fullname" . }}
---
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: {{ printf "%s-cronjob" $jobName }}
labels:
{{- include "common.labels" . | nindent 4 }}
spec:
schedule: "{{ .Values.cronjob.schedule }}"
concurrencyPolicy: Forbid
{{- with .Values.cronjob.failedJobsHistoryLimit }}
failedJobsHistoryLimit: {{ . }}
{{- end }}
{{- with .Values.cronjob.successfulJobsHistoryLimit }}
successfulJobsHistoryLimit: {{ . }}
{{- end }}
jobTemplate:
metadata:
spec:
template:
metadata:
spec:
restartPolicy: Never
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.alpineImage.repository }}:{{ .Values.alpineImage.tag }}"
imagePullPolicy: {{ default .Values.image.pullPolicy }}
args:
- curl
- "http://{{ $jobName }}.ix-{{ .Release.Name }}.svc.cluster.local:{{ .Values.service.main.ports.main.port }}/api/v1/cron/{{ .Values.env.STATIC_CRON_TOKEN }}"
resources:
{{ toYaml .Values.resources | indent 16 }}
{{- end -}}

View File

@ -0,0 +1,24 @@
{{/* Define the secrets */}}
{{- define "fireflyiii.secrets" -}}
---
apiVersion: v1
kind: Secret
type: Opaque
metadata:
name: fireflyiii-secrets
{{- $fireflyiiiprevious := lookup "v1" "Secret" .Release.Namespace "fireflyiii-secrets" }}
{{- $static_cron_token := "" }}
{{- $app_key := "" }}
data:
{{- if $fireflyiiiprevious}}
STATIC_CRON_TOKEN: {{ index $fireflyiiiprevious.data "STATIC_CRON_TOKEN" }}
APP_KEY: {{ index $fireflyiiiprevious.data "APP_KEY" }}
{{- else }}
{{- $static_cron_token := randAlphaNum 32 }}
{{- $app_key := randAlphaNum 32 }}
STATIC_CRON_TOKEN: {{ $static_cron_token | b64enc | quote }}
APP_KEY: {{ $static_cron_token | b64enc | quote }}
{{- end }}
{{- end -}}

View File

@ -1,5 +1,11 @@
{{/* Make sure all variables are set properly */}}
{{- include "common.setup" . }}
{{/* Render secrets for fireflyiii */}}
{{- include "fireflyiii.secrets" . }}
{{/* Render cronjob for fireflyiii */}}
{{- include "fireflyiii.cronjob" . }}
{{/* Render the templates */}}
{{ include "common.postSetup" . }}

View File

@ -33,7 +33,6 @@ env:
DB_DATABASE: firefly
DB_CONNECTION: pgsql
DB_PORT: 5432
APP_KEY: AGcfkCUS233ZWmBXztYbdyCs2u7kkz55
envValueFrom:
DB_HOST:
@ -44,12 +43,25 @@ envValueFrom:
secretKeyRef:
name: dbcreds
key: postgresql-password
STATIC_CRON_TOKEN:
secretKeyRef:
name: fireflyiii-secrets
key: STATIC_CRON_TOKEN
APP_KEY:
secretKeyRef:
name: fireflyiii-secrets
key: APP_KEY
persistence:
data:
enabled: true
mountPath: "/var/www/html/storage/upload"
cronjob:
schedule: "0 3 * * *"
annotations: {}
failedJobsHistoryLimit: 5
successfulJobsHistoryLimit: 2
# Enabled postgres
postgresql: