From f9df49ddd1fd68325ef98baba0a2c1cdaf3b4726 Mon Sep 17 00:00:00 2001 From: Marko Oldenburg Date: Sun, 6 Jul 2025 19:39:58 +0200 Subject: [PATCH] Add support for Paperless AI API token and environment variables This commit introduces several significant changes to the Paperless AI Helm chart: - Updated the version from 0.5.0 to 0.6.0 in `Chart.yaml` to reflect the new additions. - Added a new template `paperlessApiSecret.yaml` to define a Kubernetes Secret for the Paperless API token. This allows secure storage of the API token, which is now a required value for communication with the Paperless application. - Introduced a new function in `_helpers.tpl` called `generateEnv` that dynamically generates a `.env` file from various configuration values in `values.yaml`. This includes settings for the Paperless API URL, AI provider, tagging options, scanning intervals, and more. - Updated `values.yaml` to include necessary configurations for the Paperless API, OpenAI, and other related settings, making it easier for users to configure the chart per their requirements. - Adjusted resource limits and initial probe delays for improved performance and quicker health checks. These enhancements provide better configurability and facilitate secure management of sensitive credentials, thereby improving user experience and application reliability. --- charts/paperless-ai/Chart.yaml | 2 +- charts/paperless-ai/templates/_helpers.tpl | 19 +++++++- .../templates/paperlessApiSecret.yaml | 11 +++++ charts/paperless-ai/values.yaml | 47 +++++++++++++++++-- 4 files changed, 72 insertions(+), 7 deletions(-) create mode 100644 charts/paperless-ai/templates/paperlessApiSecret.yaml diff --git a/charts/paperless-ai/Chart.yaml b/charts/paperless-ai/Chart.yaml index 2fc50e9..642ebc7 100644 --- a/charts/paperless-ai/Chart.yaml +++ b/charts/paperless-ai/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v2 name: paperless-ai description: Ein Helm Chart für Paperless AI, basierend auf der Docker Compose Konfiguration. -version: 0.5.0 +version: 0.6.0 appVersion: 3.0.7 keywords: - paperless-ai diff --git a/charts/paperless-ai/templates/_helpers.tpl b/charts/paperless-ai/templates/_helpers.tpl index 498ee38..d1eee50 100644 --- a/charts/paperless-ai/templates/_helpers.tpl +++ b/charts/paperless-ai/templates/_helpers.tpl @@ -64,4 +64,21 @@ Erstellt den Namen des zu verwendenden Service Accounts. {{- else -}} {{ default "default" .Values.serviceAccount.name }} {{- end -}} -{{- end -}} \ No newline at end of file +{{- end -}} + +{{/* +Generiert den Inhalt der .env-Datei aus den Werten in .Values.secretEnv +*/}} +{{- define "generateEnv" -}} +{{- if .Values.paperless.apiUrl }}PAPERLESS_API_URL={{ .Values.paperless.apiUrl }}{{ "\n" }}{{- end }} +{{- if .Values.ai.provider }}AI_PROVIDER={{ .Values.ai.provider }}{{ "\n" }}{{- end }} +{{- if .Values.ai.addProcessedTag }}ADD_AI_PROCESSED_TAG={{ .Values.ai.addProcessedTag }}{{ "\n" }}{{- end }} +{{- if .Values.ai.processedTagName }}AI_PROCESSED_TAG_NAME={{ .Values.ai.processedTagName }}{{ "\n" }}{{- end }} +{{- if .Values.prompt.useTags }}USE_PROMPT_TAGS={{ .Values.prompt.useTags }}{{ "\n" }}{{- end }} +{{- if .Values.prompt.tags }}PROMPT_TAGS={{ .Values.prompt.tags }}{{ "\n" }}{{- end }} +{{- if .Values.scanInterval }}SCAN_INTERVAL={{ .Values.scanInterval }}{{ "\n" }}{{- end }} +{{- if .Values.systemPrompt }}SYSTEM_PROMPT=`{{ .Values.systemPrompt }}`{{ "\n" }}{{- end }} +{{- if .Values.processPredefinedDocuments }}PROCESS_PREDEFINED_DOCUMENTS={{ .Values.processPredefinedDocuments }}{{ "\n" }}{{- end }} +TAGS={{ .Values.tags }}{{ "\n" }} +{{- if .Values.openAi.model }}OPENAI_MODEL={{ .Values.openAi.model }}{{ "\n" }}{{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/paperless-ai/templates/paperlessApiSecret.yaml b/charts/paperless-ai/templates/paperlessApiSecret.yaml new file mode 100644 index 0000000..c4f92f7 --- /dev/null +++ b/charts/paperless-ai/templates/paperlessApiSecret.yaml @@ -0,0 +1,11 @@ +{{- if .Values.paperless.apiToken }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "paperless-ai.fullname" . }} + labels: + {{- include "paperless-ai.labels" . | nindent 4 }} +type: Opaque +data: + PAPERLESS_API_TOKEN: {{ .Values.paperless.apiToken | b64enc | quote }} +{{- end }} \ No newline at end of file diff --git a/charts/paperless-ai/values.yaml b/charts/paperless-ai/values.yaml index 411c0c7..237e848 100644 --- a/charts/paperless-ai/values.yaml +++ b/charts/paperless-ai/values.yaml @@ -1,3 +1,40 @@ +# paperless-ai config +paperless: + apiUrl: "http://paperless-ngx:8000" + apiToken: + +ai: + provider: "openai" + addProcessedTag: yes + processedTagName: ai-processed + +prompt: + useTags: yes + tags: Rechnung,Kontoauszug,Vertrag,Arbeitgeber + +openAi: + apiKey: + model: "gpt-4o-mini" + +ollama: + apiUrl: "" + model: "" + +scanInterval: "*/30 * * * *" + +systemPrompt: |- + Return the result EXCLUSIVELY as a JSON object. The Tags and Title MUST be in the language that is used in the document.: + + { + "title": "xxxxx", + "correspondent": "xxxxxxxx", + "tags": ["Tag1", "Tag2", "Tag3", "Tag4"], + "document_date": "YYYY-MM-DD", + "language": "en/de/es/..." + } +processPredefinedDocuments: "no" +tags: "indexed,indexed2" + replicaCount: 1 image: @@ -28,13 +65,13 @@ persistence: size: 1Gi livenessProbe: - initialDelaySeconds: 60 + initialDelaySeconds: 30 httpGet: path: / # path: /health port: http readinessProbe: - initialDelaySeconds: 60 + initialDelaySeconds: 30 httpGet: path: / # path: /health @@ -63,11 +100,11 @@ autoscaling: # Ressourcenanforderungen und -limits für den Container. resources: limits: - cpu: 100m - memory: 128Mi + cpu: 300m + memory: 640Mi requests: cpu: 100m - memory: 128Mi + memory: 256Mi # Node-Selector für die Pod-Platzierung. nodeSelector: {}