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:
@@ -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 -}}
|
||||
@@ -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 -}}
|
||||
@@ -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" . }}
|
||||
|
||||
Reference in New Issue
Block a user