Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.
Go agentagenticaichatbotdsh-pluginembeddingsevaluationgenerative-aigolangknowledge-basellmmulti-tenantollamaopenaiquestion-answeringragrerankingsemantic-searchvector-searchwiki
fix(helm): preserve SYSTEM_AES_KEY/TENANT_AES_KEY across upgrades
wizardchenb3898eb10193
diff --git a/helm/templates/secrets.yaml b/helm/templates/secrets.yamlindex 531d729f1..e09e9de51 100644--- a/helm/templates/secrets.yaml+++ b/helm/templates/secrets.yaml@@ -11,10 +11,30 @@ IMPORTANT: For production deployments, use one of these approaches:4. Provide an existing secret via secrets.existingSecret*/}}{{- if not .Values.secrets.existingSecret }}+{{/*+Reuse the previously generated random keys on upgrade. Without this lookup,+randAlphaNum would re-roll on every `helm upgrade` and rotate SYSTEM_AES_KEY /+TENANT_AES_KEY, making any data encrypted with the old key unreadable+(e.g. tenants.api_key would surface as enc:v1:... in the UI).+*/}}+{{- $secretName := include "weknora.secretName" . }}+{{- $existing := lookup "v1" "Secret" .Release.Namespace $secretName }}+{{- $existingTenantKey := "" }}+{{- $existingSystemKey := "" }}+{{- if and $existing $existing.data }}+ {{- if index $existing.data "TENANT_AES_KEY" }}+ {{- $existingTenantKey = index $existing.data "TENANT_AES_KEY" | b64dec }}+ {{- end }}+ {{- if index $existing.data "SYSTEM_AES_KEY" }}+ {{- $existingSystemKey = index $existing.data "SYSTEM_AES_KEY" | b64dec }}+ {{- end }}+{{- end }}+{{- $tenantAesKey := .Values.secrets.tenantAesKey | default $existingTenantKey | default (randAlphaNum 32) }}+{{- $systemAesKey := .Values.secrets.systemAesKey | default $existingSystemKey | default (randAlphaNum 32) }}apiVersion: v1kind: Secretmetadata:- name: {{ include "weknora.secretName" . }}+ name: {{ $secretName }}namespace: {{ .Release.Namespace }}labels:{{- include "weknora.labels" . | nindent 4 }}@@ -29,8 +49,8 @@ stringData:REDIS_PASSWORD: {{ required "secrets.redisPassword is required" .Values.secrets.redisPassword | quote }}# Application secretsJWT_SECRET: {{ required "secrets.jwtSecret is required" .Values.secrets.jwtSecret | quote }}- TENANT_AES_KEY: {{ .Values.secrets.tenantAesKey | default (randAlphaNum 32) | quote }}- SYSTEM_AES_KEY: {{ .Values.secrets.systemAesKey | default (randAlphaNum 32) | quote }}+ TENANT_AES_KEY: {{ $tenantAesKey | quote }}+ SYSTEM_AES_KEY: {{ $systemAesKey | quote }}{{- if .Values.neo4j.enabled }}# Neo4j credentials (for GraphRAG)NEO4J_USERNAME: {{ .Values.neo4j.username | quote }}diff --git a/helm/values.yaml b/helm/values.yamlindex 70aea7b84..f0504a486 100644--- a/helm/values.yaml+++ b/helm/values.yaml@@ -392,9 +392,20 @@ secrets:redisPassword: ""# -- JWT signing secret (REQUIRED: change in production)jwtSecret: ""- # -- Tenant AES encryption key+ # -- Tenant AES encryption key (32 bytes).+ # STRONGLY RECOMMENDED to set this explicitly in production.+ # If left empty, a random 32-char value is generated on first install and+ # reused on subsequent `helm upgrade` via Secret lookup. However, if the+ # Secret is ever deleted/recreated (e.g. namespace recreated, GitOps prune,+ # cluster rebuilt) a new random value will be generated and any data+ # encrypted with the old key becomes UNRECOVERABLE.tenantAesKey: ""- # -- System AES-256 key for database API key encryption (32 bytes)+ # -- System AES-256 key for database field encryption (must be exactly 32 bytes).+ # Encrypts: tenants.api_key, model API keys, vector store credentials,+ # web search provider keys, WeKnoraCloud.AppSecret.+ # STRONGLY RECOMMENDED to set this explicitly in production. Same caveat as+ # tenantAesKey: losing this key makes all encrypted fields unreadable+ # (the UI will display ciphertext like "enc:v1:..." instead of plaintext).systemAesKey: ""# -- Use existing secret instead of creating one