2026-09-13 06:04:49 +09:00
|
|
|
# Secret paperless-ai-config managed via SOPS (argocd/secrets/paperless-ai-secrets.enc.yaml)
|
|
|
|
|
---
|
|
|
|
|
apiVersion: apps/v1
|
|
|
|
|
kind: Deployment
|
|
|
|
|
metadata:
|
|
|
|
|
name: paperless-ai
|
|
|
|
|
namespace: paperless
|
|
|
|
|
labels:
|
|
|
|
|
app.kubernetes.io/name: paperless-ai
|
|
|
|
|
spec:
|
|
|
|
|
replicas: 1
|
|
|
|
|
selector:
|
|
|
|
|
matchLabels:
|
|
|
|
|
app.kubernetes.io/name: paperless-ai
|
|
|
|
|
template:
|
|
|
|
|
metadata:
|
|
|
|
|
labels:
|
|
|
|
|
app.kubernetes.io/name: paperless-ai
|
|
|
|
|
spec:
|
|
|
|
|
tolerations:
|
|
|
|
|
- key: node-role.kubernetes.io/control-plane
|
|
|
|
|
operator: Exists
|
|
|
|
|
effect: NoSchedule
|
2026-09-14 23:07:52 +09:00
|
|
|
volumes:
|
|
|
|
|
- name: paperless-ai-data
|
|
|
|
|
persistentVolumeClaim:
|
|
|
|
|
claimName: paperless-ai-data
|
|
|
|
|
initContainers:
|
|
|
|
|
- name: fetch-llm-token
|
|
|
|
|
image: curlimages/curl:8.12.0
|
|
|
|
|
command:
|
|
|
|
|
- sh
|
|
|
|
|
- -c
|
|
|
|
|
- |
|
|
|
|
|
set -e
|
|
|
|
|
echo "[init] Fetching JWT token from Authentik for paperless-ai-agent..."
|
|
|
|
|
|
|
|
|
|
# Get JWT token via client_credentials grant
|
|
|
|
|
# Client secret sourced from environment (injected from paperless-ai-config Secret)
|
|
|
|
|
TOKEN_RESPONSE=$(curl -s -X POST https://authentik.riotpiao.com/application/o/token/ \
|
|
|
|
|
-d "grant_type=client_credentials" \
|
|
|
|
|
-d "client_id=paperless-ai-agent" \
|
|
|
|
|
-d "client_secret=${LLM_AUTH_CLIENT_SECRET}" \
|
|
|
|
|
-d "scope=openid llm:inference" 2>/dev/null)
|
|
|
|
|
|
2026-09-14 23:55:53 +09:00
|
|
|
# Extract token from JSON response using sed
|
|
|
|
|
TOKEN=$(echo "$TOKEN_RESPONSE" | sed -n 's/.*"access_token":"\([^"]*\)".*/\1/p')
|
2026-09-14 23:07:52 +09:00
|
|
|
|
2026-09-14 23:55:53 +09:00
|
|
|
if [ -z "$TOKEN" ]; then
|
2026-09-14 23:07:52 +09:00
|
|
|
echo "[error] Failed to get token. Response: $TOKEN_RESPONSE"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Store token in file for main container to read
|
|
|
|
|
mkdir -p /data
|
|
|
|
|
echo "$TOKEN" > /data/llm_token.txt
|
|
|
|
|
echo "[init] Token fetched and stored successfully"
|
|
|
|
|
env:
|
|
|
|
|
- name: LLM_AUTH_CLIENT_SECRET
|
|
|
|
|
valueFrom:
|
|
|
|
|
secretKeyRef:
|
|
|
|
|
name: paperless-ai-config
|
|
|
|
|
key: LLM_AUTH_CLIENT_SECRET
|
|
|
|
|
volumeMounts:
|
|
|
|
|
- name: paperless-ai-data
|
|
|
|
|
mountPath: /data
|
2026-09-13 06:04:49 +09:00
|
|
|
containers:
|
|
|
|
|
- name: paperless-ai
|
|
|
|
|
image: clusterzx/paperless-ai:latest
|
|
|
|
|
env:
|
|
|
|
|
# Paperless-ngx connection
|
|
|
|
|
- name: PAPERLESS_API_URL
|
|
|
|
|
value: "http://paperless.paperless.svc.cluster.local:8000"
|
|
|
|
|
- name: PAPERLESS_API_TOKEN
|
|
|
|
|
valueFrom:
|
|
|
|
|
secretKeyRef:
|
|
|
|
|
name: paperless-ai-config
|
|
|
|
|
key: PAPERLESS_API_TOKEN
|
2026-09-13 04:58:44 +00:00
|
|
|
- name: PAPERLESS_USERNAME
|
|
|
|
|
value: "admin"
|
2026-09-14 23:07:52 +09:00
|
|
|
# LLM API — via public gateway with JWT auth
|
2026-09-13 06:04:49 +09:00
|
|
|
- name: AI_PROVIDER
|
|
|
|
|
value: "custom"
|
|
|
|
|
- name: CUSTOM_BASE_URL
|
2026-09-14 23:07:52 +09:00
|
|
|
value: "https://api.riotpiao.com/v1"
|
|
|
|
|
# Token will be read from file at runtime by the application
|
|
|
|
|
# The init container fetches it and stores in /app/data/llm_token.txt
|
|
|
|
|
- name: CUSTOM_API_KEY_FILE
|
|
|
|
|
value: "/app/data/llm_token.txt"
|
2026-09-13 06:04:49 +09:00
|
|
|
- name: CUSTOM_MODEL
|
2026-09-14 23:07:52 +09:00
|
|
|
value: "qwen2.5:3b-instruct"
|
|
|
|
|
# Behavior - scan for new documents and tag them
|
2026-09-13 06:04:49 +09:00
|
|
|
- name: SCAN_INTERVAL
|
2026-09-14 23:07:52 +09:00
|
|
|
value: "60"
|
2026-09-13 06:04:49 +09:00
|
|
|
- name: PROCESS_PREDEFINED_DOCUMENTS
|
|
|
|
|
value: "no"
|
|
|
|
|
- name: ADD_AI_TAG
|
|
|
|
|
value: "yes"
|
|
|
|
|
- name: AI_TAG_NAME
|
|
|
|
|
value: "ai-processed"
|
|
|
|
|
- name: USE_PROMPT_TAGS
|
|
|
|
|
value: "yes"
|
2026-09-14 23:07:52 +09:00
|
|
|
- name: ADD_AI_DESCRIPTIONS
|
|
|
|
|
value: "yes"
|
|
|
|
|
volumeMounts:
|
|
|
|
|
- name: paperless-ai-data
|
|
|
|
|
mountPath: /app/data
|
2026-09-13 06:04:49 +09:00
|
|
|
resources:
|
|
|
|
|
requests:
|
2026-09-13 08:35:55 +09:00
|
|
|
cpu: 100m
|
2026-09-13 06:04:49 +09:00
|
|
|
memory: 512Mi
|
2026-09-13 08:35:55 +09:00
|
|
|
limits:
|
|
|
|
|
cpu: "1"
|
|
|
|
|
memory: 2Gi
|