Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

fix(helm): upgrading from the old Helm chart keeps your encryption key and data (#15779)

Hazem Adel974da4c02125
diff --git a/.github/workflows/helm-chart.yml b/.github/workflows/helm-chart.yml
index e2a2ba7627a..c1f8a94f059 100644
--- a/.github/workflows/helm-chart.yml
+++ b/.github/workflows/helm-chart.yml
@@ -37,6 +37,10 @@ jobs:
grep -q '^kind: Rollout' "$RUNNER_TEMP/rollout.yaml"
grep -q 'name: ap-activepieces-preview' "$RUNNER_TEMP/rollout.yaml"
grep -A2 'scaleTargetRef:' "$RUNNER_TEMP/rollout.yaml" | grep -q 'kind: Rollout'
+ NOTES=$(helm install ap . --dry-run=client --set activepieces.frontendUrl=x)
+ grep -q 'ignores these values' <<< "$NOTES"
+ NOTES=$(helm install ap . --dry-run=client)
+ ! grep -q 'ignores these values' <<< "$NOTES"
- uses: helm/kind-action@v1
diff --git a/brain/knowledge/engineering/helm-chart.md b/brain/knowledge/engineering/helm-chart.md
index 451545e08bd..94e6f8295a0 100644
--- a/brain/knowledge/engineering/helm-chart.md
+++ b/brain/knowledge/engineering/helm-chart.md
@@ -9,7 +9,7 @@ The Kubernetes install we ship to self-hosters, at `deploy/activepieces-helm/`.
## Two paths for an AP_* variable
`templates/deployment.yaml` builds one `env:` list from two values keys, in this fixed order:
-- **`activepiecesConfig`** — a flat map rendered as plain `value:` entries. Rendered **first**. The shipped default holds only `AP_CONTAINER_TYPE`.
+- **`activepiecesConfig`** — a flat map rendered as plain `value:` entries. Rendered **first**. Empty (`{}`) by default.
- **`activepiecesEnvVariables`** — a map of *secret name* → *list of var names*, rendered as `secretKeyRef` with `optional: true`. Rendered **second**. The shipped default routes `AP_EDITION`, `AP_EXECUTION_MODE`, `AP_ENCRYPTION_KEY`, `AP_JWT_SECRET` and the queue/auth vars through secrets the chart does not create.
- **`envFrom` the generated secrets**: lowest precedence. Supplies `AP_ENCRYPTION_KEY` / `AP_JWT_SECRET` when no user secret sets them, because `env` beats `envFrom`.
@@ -23,6 +23,10 @@ Only two secrets, both `data: {}` with mittwald `secret-generator` annotations t
- **Setting the same `AP_*` var in both values keys puts two entries with one name in the pod spec, and the secret wins.** `activepiecesConfig` renders before `activepiecesEnvVariables`, and for duplicate env names the later entry is what the container process sees. Since the shipped `values.yaml` already lists `AP_EDITION` and `AP_EXECUTION_MODE` under `activepieces-config-secrets`, a user who follows the docs *and* has created that secret silently gets the secret's edition, not the one they set. `optional: true` saves the common case — with no such secret the ref is skipped and the plain value survives — so this reads as "works on my cluster" right up until someone populates the secret. Set each variable in exactly one place.
- **The DB and Redis secrets do not exist until you make them.** Every ref is `optional: true`, so a missing secret is silently skipped and the app falls back to its own defaults (e.g. `localhost` Postgres), even with the subcharts enabled.
- **Offline renders can't see the cluster.** Helm's default `.Capabilities.APIVersions` has group/version entries only; a connected install adds kind-level ones such as `apps/v1/StatefulSet`. That is the only live-cluster signal that works with `--create-namespace` and restricted RBAC (a `lookup` sees no namespace yet and errors on Forbidden).
+- **Releases born on chart 0.3.x keep their key under legacy field names.** Their `<fullname>-secrets` holds `encryption-key` (and `<fullname>-jwt-secret` holds `jwt-secret`), while the generator now writes `AP_ENCRYPTION_KEY`. When no user secret pins the key, the chart looks up the legacy field and pins it, so the upgrade keeps decrypting old data. Offline renders cannot look it up; the migration guide copies it into `activepieces-auth-secrets` instead.
+- **Never render an empty `AP_CONTAINER_TYPE`.** Current images treat empty and unset alike (`${AP_CONTAINER_TYPE:-WORKER_AND_APP}`), but pre-worker-v2 images start as a worker when it is set to `""`, so every API route returns 404.
+- **A StatefulSet's volume template is frozen once created.** A 0.3.x user who upgrades with old values gets a StatefulSet on `local-path`; fixing `persistence.storageClassName` afterwards is rejected until the StatefulSet and its cache PVC are deleted (safe while the pod never started).
+- **Chart 0.3.x only ran bundled Postgres when the release name contained `activepieces`.** It referenced `<fullname>-postgresql` while Bitnami names the secret `<release>-postgresql`.
- **A user-owned key is pinned once it exists.** If `AP_ENCRYPTION_KEY` / `AP_JWT_SECRET` are in the user's secret when the chart renders, their `secretKeyRef` becomes `optional: false`, so a deleted secret stops the pod instead of letting the generated fallback key silently take over.
- **Never render one env name twice to get precedence.** Helm 4 installs with server-side apply, which rejects duplicate `env` keys ("duplicate entries for key"). A lower-precedence default has to come through `envFrom`.
- **Removing a duplicate env name on a Helm 3 upgrade deletes both entries.** The strategic merge patch matches `env` items by name ("hides previous definition ... may be dropped when using apply"), so a var set in both values keys vanishes from the live pod spec. Never change how an already-duplicated name renders; fix duplicates in the user's values instead.
diff --git a/deploy/activepieces-helm/templates/NOTES.txt b/deploy/activepieces-helm/templates/NOTES.txt
index 93bc41757b4..190c16f0c37 100644
--- a/deploy/activepieces-helm/templates/NOTES.txt
+++ b/deploy/activepieces-helm/templates/NOTES.txt
@@ -1 +1,23 @@
-Activepieces has been deployed successfully!
\ No newline at end of file
+Activepieces has been deployed successfully!
+{{- $ignored := list }}
+{{- range $key := list "activepieces" "smtp" "s3" "queueUi" }}
+{{- if hasKey $.Values $key }}{{ $ignored = append $ignored $key }}{{ end }}
+{{- end }}
+{{- range $key := list "host" "port" "useSSL" "url" "sslCa" }}
+{{- if hasKey $.Values.postgresql $key }}{{ $ignored = append $ignored (printf "postgresql.%s" $key) }}{{ end }}
+{{- end }}
+{{- range $key := list "host" "port" "useSSL" "sslCaFile" "db" "url" "type" "user" "failedJob" }}
+{{- if hasKey $.Values.redis $key }}{{ $ignored = append $ignored (printf "redis.%s" $key) }}{{ end }}
+{{- end }}
+{{- if dig "auth" "externalSecret" "" .Values.postgresql }}{{ $ignored = append $ignored "postgresql.auth.externalSecret" }}{{ end }}
+{{- if dig "auth" "externalSecret" "" .Values.redis }}{{ $ignored = append $ignored "redis.auth.externalSecret" }}{{ end }}
+{{- if hasKey .Values.persistence "storageClass" }}{{ $ignored = append $ignored "persistence.storageClass" }}{{ end }}
+{{- with $ignored }}
+
+WARNING: this chart ignores these values from the chart 0.3.x format:
+{{- range . }}
+ - {{ . }}
+{{- end }}
+Move them to the secrets listed under activepiecesEnvVariables, or persistence.storageClassName:
+https://www.activepieces.com/docs/install/options/helm#migrating-from-chart-0-3-x
+{{- end }}
diff --git a/deploy/activepieces-helm/templates/deployment.yaml b/deploy/activepieces-helm/templates/deployment.yaml
index ecbcb4074ad..c7e29e5eb5d 100644
--- a/deploy/activepieces-helm/templates/deployment.yaml
+++ b/deploy/activepieces-helm/templates/deployment.yaml
@@ -65,18 +65,24 @@ spec:
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
+ {{- $fullname := include "activepieces.fullname" . }}
+ {{- $legacyKeys := dict "AP_ENCRYPTION_KEY" (list (printf "%s-secrets" $fullname) "encryption-key") "AP_JWT_SECRET" (list (printf "%s-jwt-secret" $fullname) "jwt-secret") }}
{{- range $secretName, $vars := .Values.activepiecesEnvVariables }}
{{- range $vars }}
- {{- $userOwnedKey := false }}
- {{- if has . (list "AP_ENCRYPTION_KEY" "AP_JWT_SECRET") }}
- {{- $userOwnedKey = hasKey ((lookup "v1" "Secret" $.Release.Namespace $secretName).data | default dict) . }}
+ {{- $ref := list $secretName . true }}
+ {{- with get $legacyKeys . }}
+ {{- if hasKey ((lookup "v1" "Secret" $.Release.Namespace $secretName).data | default dict) (index $ref 1) }}
+ {{- $ref = list $secretName (index $ref 1) false }}
+ {{- else if hasKey ((lookup "v1" "Secret" $.Release.Namespace (index . 0)).data | default dict) (index . 1) }}
+ {{- $ref = list (index . 0) (index . 1) false }}
+ {{- end }}
{{- end }}
- name: {{ . }}
valueFrom:
secretKeyRef:
- name: {{ $secretName | quote }}
- key: {{ . }}
- optional: {{ not $userOwnedKey }}
+ name: {{ index $ref 0 | quote }}
+ key: {{ index $ref 1 }}
+ optional: {{ index $ref 2 }}
{{- end }}
{{- end }}
{{- end }}
diff --git a/deploy/activepieces-helm/values.yaml b/deploy/activepieces-helm/values.yaml
index b574d7965c5..46efb289222 100644
--- a/deploy/activepieces-helm/values.yaml
+++ b/deploy/activepieces-helm/values.yaml
@@ -179,8 +179,7 @@ redis:
# Deployment-specific, non-sensitive env vars set as plain values.
# Use this for vars that differ per release (e.g. APP vs WORKER) and don't belong in the shared secret.
-activepiecesConfig:
- AP_CONTAINER_TYPE: ""
+activepiecesConfig: {}
# Map of Kubernetes secret name → list of AP_* (and OTEL_*) env var names to inject.
# Each var name must exist as a key in the corresponding secret.
diff --git a/docs/install/options/helm.mdx b/docs/install/options/helm.mdx
index 88e349bce38..a0102bbd55a 100644
--- a/docs/install/options/helm.mdx
+++ b/docs/install/options/helm.mdx
@@ -134,6 +134,68 @@ With Helm 4 and `workloadType: rollout`, add `--force-conflicts` to `helm upgrad
The bundled secret generator creates cluster-wide RBAC named after the release, so give each release in a cluster its own name. A second release can also set `kubernetes-secret-generator.enabled: false`, because the first release's generator already serves every namespace.
+## Migrating from chart 0.3.x
+
+Chart 0.4.0 replaced the `activepieces:` block and keys such as `postgresql.host` and `redis.host` with the secrets listed under `activepiecesEnvVariables`. `helm install` and `helm upgrade` print a warning that names every old key they ignore. Run these steps before upgrading, with `RELEASE` set to your release name.
+
+**1. Keep your database.** Chart 0.3.x ran PostgreSQL and Redis inside the cluster by default. If you used them, keep them enabled in your values:
+
+```yaml
+postgresql:
+ enabled: true
+ image:
+ repository: bitnamilegacy/postgresql
+redis:
+ enabled: true
+ image:
+ repository: bitnamilegacy/redis
+```
+
+Then copy the database and Redis settings your running app uses today, so custom names, users and hosts carry over. This works the same for bundled and external databases:
+
+```bash
+umask 077
+FULLNAME=$(kubectl get secret -l app.kubernetes.io/instance="$RELEASE" -o name | sed -n 's|^secret/\(.*\)-jwt-secret$|\1|p')
+kubectl exec "deploy/$FULLNAME" -- printenv > app.env
+grep '^AP_POSTGRES_' app.env | grep -v '^AP_POSTGRES_SSL_CA=' > db.env
+grep '^AP_REDIS_' app.env | grep -v '^AP_REDIS_TYPE=DEFAULT$' > redis.env
+kubectl create secret generic activepieces-db-secrets --from-env-file=db.env
+kubectl create secret generic activepieces-redis-secrets --from-env-file=redis.env
+if kubectl exec "deploy/$FULLNAME" -- printenv AP_POSTGRES_SSL_CA > ca.pem; then
+ kubectl patch secret activepieces-db-secrets -p "{\"data\":{\"AP_POSTGRES_SSL_CA\":\"$(base64 < ca.pem | tr -d '\n')\"}}"
+fi
+rm app.env db.env redis.env ca.pem
+```
+
+If a variable in those files is not listed under `activepiecesEnvVariables` (for example `AP_POSTGRES_URL` or `AP_REDIS_SENTINEL_HOSTS`), add it to that list in your values.
+
+**2. Move your settings.** Each `activepieces.<name>` value becomes an `AP_*` variable in the `activepieces-config-secrets` secret, for example `frontendUrl` → `AP_FRONTEND_URL`, `edition` → `AP_EDITION` and `executionMode` → `AP_EXECUTION_MODE`. Set `persistence.storageClassName` to a StorageClass your cluster has (`kubectl get storageclass`); chart 0.3.x used the cluster default, and `persistence.storageClass` is no longer read.
+
+```bash
+kubectl create secret generic activepieces-config-secrets \
+ --from-literal=AP_FRONTEND_URL=https://activepieces.yourdomain.com
+```
+
+**3. Keep your keys.** Your encryption key and JWT secret are carried over automatically. If you deploy with `helm template`, Argo CD or Kustomize, the chart cannot see them, so copy the ones your running app uses into `activepieces-auth-secrets` first:
+
+```bash
+umask 077
+FULLNAME=$(kubectl get secret -l app.kubernetes.io/instance="$RELEASE" -o name | sed -n 's|^secret/\(.*\)-jwt-secret$|\1|p')
+kubectl exec "deploy/$FULLNAME" -- printenv | grep -E '^AP_(ENCRYPTION_KEY|JWT_SECRET)=' > auth.env
+kubectl create secret generic activepieces-auth-secrets --from-env-file=auth.env
+rm auth.env
+```
+
+**4. Upgrade.** Pin `image.tag` to the version you run today, upgrade the chart, then move to a newer image in a separate step. The app now runs as a StatefulSet (or an Argo `Rollout`) instead of a Deployment, and its piece cache volume is recreated.
+
+If you already upgraded with the old values and the new pod is stuck in `Pending` (for example `storageclass "local-path" not found`), Kubernetes will not let the chart change the volume. Delete the StatefulSet and its empty cache volume, then upgrade again. The pod never started, so nothing is lost:
+
+```bash
+FULLNAME=$(kubectl get secret -l app.kubernetes.io/instance="$RELEASE" -o name | sed -n 's|^secret/\(.*\)-jwt-secret$|\1|p')
+kubectl delete statefulset "$FULLNAME"
+kubectl delete pvc "cache-$FULLNAME-0"
+```
+
## Troubleshooting
### Common Issues