Skip to content

Commit 067a8a5

Browse files
authored
fix(helm): keep bundled Postgres upgradable, stop secret modes masking settings, and route realtime on the app host (#10768)
* fix(helm): keep bundled Postgres upgradable, stop secret modes masking settings, and route realtime on the app host - volumeClaimTemplates labels: reuse an existing StatefulSet's labels (lookup), stable selector labels otherwise; Kubernetes rejects any change there, so every version bump failed helm upgrade - CI: install the newest published chart and helm upgrade it to the checkout - External Secrets: skip an envDefaults key mapped in remoteRefs.app - existingSecret: inline envDefaults values changed from the chart's defaults - BETTER_AUTH_URL follows $(NEXT_PUBLIC_APP_URL) unless set - ingress.realtime defaults to the app host under /socket.io; a separate host derives NEXT_PUBLIC_SOCKET_URL; "/" on the app host fails - refuse multi-replica installs on local upload storage, warn otherwise - fail on empty existingSecret names and on both databases enabled - NOTES: realtime port-forward, OCI upgrade ref, upgrade pointer; chart 1.20.0 * fix(helm): exact uploads mount match, https socket URL from every source, legacy realtime host, and runnable example installs * improvement(helm): one env resolver, shared ingress and env templates, and concise upgrade notes * fix(helm): grant Marketplace S3 access to the named upload buckets only
1 parent 8adc2b5 commit 067a8a5

42 files changed

Lines changed: 1601 additions & 477 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/helm.yml‎

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ jobs:
165165
name: install
166166
needs: chart
167167
runs-on: ${{ (vars.CI_PROVIDER == '' || vars.CI_PROVIDER == 'blacksmith') && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-latest' }}
168-
timeout-minutes: 25
168+
timeout-minutes: 55
169169
steps:
170170
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
171171
with:
@@ -192,6 +192,43 @@ jobs:
192192
- name: Run helm test
193193
run: helm test sim --namespace sim --timeout 5m
194194

195+
# Kubernetes refuses any change to a StatefulSet's volumeClaimTemplates, so
196+
# a label that moves with the chart version there breaks every upgrade of
197+
# the bundled Postgres while fresh installs keep passing. Install the newest
198+
# published chart in its own namespace, then upgrade it to this checkout
199+
# with the same values, so ci/default-values.yaml and ci/kind-overlay.yaml
200+
# must stay valid for the previous published chart too.
201+
- name: Upgrade from the published chart
202+
run: |
203+
set -euo pipefail
204+
chart=oci://ghcr.io/simstudioai/charts/sim
205+
# The newest published version strictly below this checkout's, so a rerun after this
206+
# version is published still tests an upgrade rather than same to same. Helm cannot list
207+
# OCI tags, so read them from the registry API with an anonymous pull token.
208+
current=$(awk '/^version:/ {print $2}' helm/sim/Chart.yaml)
209+
token=$(curl -fsS "https://ghcr.io/token?scope=repository:simstudioai/charts/sim:pull" | jq -r .token)
210+
previous=$(curl -fsS -H "Authorization: Bearer ${token}" \
211+
"https://ghcr.io/v2/simstudioai/charts/sim/tags/list?n=1000" \
212+
| jq -r '.tags[]' \
213+
| grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' \
214+
| { cat; echo "$current"; } | sort -uV \
215+
| awk -v current="$current" '$0 == current {print prev; exit} {prev = $0}')
216+
if [ -z "$previous" ]; then
217+
echo "::error::No published chart version below ${current} to upgrade from."
218+
exit 1
219+
fi
220+
echo "Installing published chart ${previous}, then upgrading to this checkout (${current})"
221+
helm install sim-upgrade "$chart" --version "$previous" \
222+
--namespace sim-upgrade --create-namespace \
223+
--values helm/sim/ci/default-values.yaml \
224+
--values helm/sim/ci/kind-overlay.yaml \
225+
--wait --timeout 10m
226+
helm upgrade sim-upgrade helm/sim \
227+
--namespace sim-upgrade \
228+
--values helm/sim/ci/default-values.yaml \
229+
--values helm/sim/ci/kind-overlay.yaml \
230+
--wait --timeout 10m
231+
195232
# After the test, so it also explains a failed probe, not only a failed
196233
# install. A failed test pod is kept (the hook deletes it only on success),
197234
# so its log says which URL refused.
@@ -205,6 +242,8 @@ jobs:
205242
kubectl -n sim logs deploy/sim-app --tail=80 || true
206243
kubectl -n sim logs deploy/sim-realtime --tail=80 || true
207244
kubectl -n sim logs sim-test-connection || true
245+
kubectl -n sim-upgrade get pods -o wide || true
246+
kubectl -n sim-upgrade get events --sort-by=.lastTimestamp | tail -20 || true
208247
209248
# Resolved once and shared, so the two publish paths cannot package the same
210249
# immutable chart version with different appVersions -- they run in parallel,
@@ -296,7 +335,7 @@ jobs:
296335

297336
# Derives appVersion rather than checking it, so the published chart cannot
298337
# be pinned to an older Sim than the release it ships with. The committed
299-
# value is kept current too, but nothing depends on a human remembering.
338+
# value is not kept current; only this step sets the one that ships.
300339
- name: Sync chart appVersion to the release
301340
env:
302341
APP_VERSION: ${{ needs.release-version.outputs.version }}
@@ -491,7 +530,7 @@ jobs:
491530

492531
# Derives appVersion rather than checking it, so the published chart cannot
493532
# be pinned to an older Sim than the release it ships with. The committed
494-
# value is kept current too, but nothing depends on a human remembering.
533+
# value is not kept current; only this step sets the one that ships.
495534
- name: Sync chart appVersion to the release
496535
if: steps.pages.outputs.exists == 'true'
497536
env:

‎apps/docs/content/docs/platform/self-hosting/kubernetes.mdx‎

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -88,22 +88,18 @@ Open [http://localhost:3000](http://localhost:3000). For public access, complete
8888

8989
## Public access [#key-configuration]
9090

91-
Configure a public app origin, realtime routing, allowed origins, and TLS together. This same-host example belongs in `public-values.yaml`; replace the ingress class with your installed controller's class:
91+
Configure a public app origin and TLS together; realtime is served on the app host under `/socket.io` by default. This same-host example belongs in `public-values.yaml`; replace the ingress class with your installed controller's class:
9292

9393
```yaml
9494
app:
9595
image:
9696
tag: "v0.9.72"
9797
env:
9898
NEXT_PUBLIC_APP_URL: "https://sim.yourdomain.com"
99-
BETTER_AUTH_URL: "https://sim.yourdomain.com"
100-
NEXT_PUBLIC_SOCKET_URL: "https://sim.yourdomain.com"
10199

102100
realtime:
103101
image:
104102
tag: "v0.9.72"
105-
env:
106-
ALLOWED_ORIGINS: "https://sim.yourdomain.com"
107103

108104
migrations:
109105
image:
@@ -120,17 +116,12 @@ ingress:
120116
nginx.ingress.kubernetes.io/force-ssl-redirect: null
121117
app:
122118
host: sim.yourdomain.com
123-
realtime:
124-
host: sim.yourdomain.com
125-
paths:
126-
- path: /socket.io
127-
pathType: Prefix
128119
tls:
129120
enabled: true
130121
secretName: sim-tls
131122
```
132123
133-
The app and realtime consume shared app env values; `ALLOWED_ORIGINS` explicitly admits the public app origin. Matching ingress hosts lets the chart route `/socket.io` before the app's `/` path. Keep app, realtime, and migrations on the same image release.
124+
The app and realtime consume shared app env values: `BETTER_AUTH_URL` follows `NEXT_PUBLIC_APP_URL`, and realtime always admits that origin (`realtime.env.ALLOWED_ORIGINS` is only for extra origins). With `ingress.realtime.host` empty, the chart routes `/socket.io` on the app host before the app's `/` path. Keep app, realtime, and migrations on the same image release.
134125

135126
Create `sim-tls` in `simstudio` from your certificate and private key, or configure your certificate manager to populate that Secret:
136127

@@ -141,12 +132,9 @@ kubectl create secret tls sim-tls -n simstudio \
141132

142133
For a fresh public installation, create the namespace before creating the Secret. Configure DNS and the controller's own HTTPS redirect, upload-size, WebSocket, timeout, and streaming settings. The `null` above removes the chart's legacy nginx redirect annotation; it does not configure another controller.
143134

144-
For a separate realtime hostname, change all three fields together:
135+
A separate realtime hostname is optional. Set it, and the chart points the app at it through `NEXT_PUBLIC_SOCKET_URL` (unless you set that yourself, which you must in `app.secrets.existingSecret` mode):
145136

146137
```yaml
147-
app:
148-
env:
149-
NEXT_PUBLIC_SOCKET_URL: "https://sim-ws.yourdomain.com"
150138
ingress:
151139
realtime:
152140
host: sim-ws.yourdomain.com
@@ -155,7 +143,7 @@ ingress:
155143
pathType: Prefix
156144
```
157145

158-
Keep `ALLOWED_ORIGINS` set to the app origin, and use a TLS certificate covering both hosts. App/auth URLs remain on `sim.yourdomain.com`.
146+
Use a TLS certificate covering both hosts. App/auth URLs remain on `sim.yourdomain.com`.
159147

160148
Apply your complete values with `helm upgrade --install`, retaining the same secrets as installation. For inline mode, repeat the secret `--set` arguments from the install command and add `-f public-values.yaml`. For secret-store mode, use a complete values file defining that strategy.
161149

@@ -238,8 +226,7 @@ Configure model provider keys, such as `OPENAI_API_KEY`, through the same select
238226
Use a cloud example as a starting file, not a complete install configuration. Fetch it from the release corresponding to the pinned chart example:
239227

240228
```bash
241-
SIM_RELEASE=v0.9.72
242-
curl -fsSLO "https://raw.githubusercontent.com/simstudioai/sim/$SIM_RELEASE/helm/sim/examples/values-aws.yaml"
229+
curl -fsSLO "https://raw.githubusercontent.com/simstudioai/sim/helm-chart-${CHART_VERSION}/helm/sim/examples/values-aws.yaml"
243230
```
244231

245232
Choose `values-aws.yaml` for EKS, `values-azure.yaml` for AKS, or `values-gcp.yaml` for GKE. Review and replace provider-specific fields before installation:

‎apps/docs/content/docs/platform/self-hosting/networking.mdx‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,33 +22,28 @@ sim.yourdomain.com/ → app:3000
2222
sim.yourdomain.com/socket.io → realtime:3002
2323
```
2424

25-
`NEXT_PUBLIC_SOCKET_URL` can be left unset — the client defaults to the page origin.
25+
`NEXT_PUBLIC_SOCKET_URL` can be left unset — the client defaults to the page origin. This is the Helm chart's default: with `ingress.realtime.host` empty, it routes `/socket.io` on the app host.
2626

2727
</Tab>
2828
<Tab value="Two hostnames">
2929

30-
Use separate hostnames when your ingress setup cannot split paths across backends. GKE's example values use this layout.
30+
Optionally, use separate hostnames when your ingress setup cannot split paths across backends. GKE's example values use this layout.
3131

3232
```
3333
sim.yourdomain.com → app:3000
3434
sim-ws.yourdomain.com → realtime:3002
3535
```
3636

37-
Then tell the client where realtime lives, and tell realtime which origins to accept:
37+
Then tell the client where realtime lives:
3838

3939
```yaml
4040
app:
4141
env:
4242
NEXT_PUBLIC_APP_URL: "https://sim.yourdomain.com"
43-
BETTER_AUTH_URL: "https://sim.yourdomain.com"
4443
NEXT_PUBLIC_SOCKET_URL: "https://sim-ws.yourdomain.com"
45-
46-
realtime:
47-
env:
48-
ALLOWED_ORIGINS: "https://sim.yourdomain.com"
4944
```
5045
51-
`ALLOWED_ORIGINS` is the CORS allowlist realtime enforces on socket connections; it must contain the app's origin. The URL keys only need to be set once under `app.env` — the chart writes them into a Secret both Deployments consume.
46+
With the Helm chart, setting `ingress.realtime.host` is enough: the chart sets `NEXT_PUBLIC_SOCKET_URL` to that host unless you do (set it yourself in `app.secrets.existingSecret` mode). Realtime always accepts the `NEXT_PUBLIC_APP_URL` origin; `ALLOWED_ORIGINS` is only for extra origins. The URL keys only need to be set once under `app.env` — the chart writes them into a Secret both Deployments consume.
5247

5348
Both hostnames need DNS records and TLS certificates.
5449

‎apps/docs/content/docs/platform/self-hosting/scaling.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ app:
3939
cpu: 1000m
4040
```
4141
42-
The `resources` block above is the chart's default — it is shown so the numbers are visible, not because it changes anything. Only `replicaCount` needs setting unless you are raising the ceiling.
42+
The `resources` block above is the chart's default — it is shown so the numbers are visible, not because it changes anything. Only `replicaCount` needs setting unless you are raising the ceiling. More than one replica needs object storage (S3, Azure Blob, or GCS via `STORAGE_PROVIDER`), or the chart fails to render; `app.storage.allowLocalWithReplicas=true` opts out and keeps uploads on each pod, lost on restart.
4343

4444
The app orchestrates workflows, and local JavaScript runs in Node child workers inside its container. Those workers and in-memory file parsing share the pod's memory limit. OOMKills can terminate in-flight runs.
4545

‎apps/docs/content/docs/platform/self-hosting/verify.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ Expect `simstudio`, `realtime`, `db`, `redis`, and `cron` to be running, with `m
107107
| --- | --- |
108108
| App does not load | Database connectivity and migration logs. On Helm, failed migrations block the app init sequence. On Compose, the app waits for successful migrations. |
109109
| Sign-in loops or is rejected | Public app/auth origins, scheme, and trusted origins. Confirm the app and realtime use the same `BETTER_AUTH_SECRET`. |
110-
| Socket is unavailable | WebSocket upgrades and `/socket.io` routing. For a separate realtime host, set `NEXT_PUBLIC_SOCKET_URL` and include the app origin in realtime's `ALLOWED_ORIGINS`. |
110+
| Socket is unavailable | WebSocket upgrades and `/socket.io` routing. Realtime defaults to the app host; for a separate realtime host, `NEXT_PUBLIC_SOCKET_URL` must point at it (the Helm chart sets it from `ingress.realtime.host` unless you do). `ALLOWED_ORIGINS` is only for origins beyond `NEXT_PUBLIC_APP_URL`. |
111111
| Edits do not propagate | Realtime connectivity and Redis on every replica; verify which pods hold the connections. |
112112
| Workflow execution fails | Provider egress, saved credentials, and app logs. A decryption error can mean the current `ENCRYPTION_KEY` differs from the key that encrypted the credential. |
113113
| Cloud upload fails | Bucket CORS for the Sim origin and signed headers; server permissions to complete multipart uploads. S3 completion needs `s3:ListMultipartUploadParts`. |

‎apps/docs/scripts/fixtures/content-baseline.json‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173941,7 +173941,7 @@
173941173941
{
173942173942
"lang": "yaml",
173943173943
"meta": null,
173944-
"sha256": "795844d38101f8147ddbc9228260ac3079e0ab89a452246656ac336c74f131ce",
173944+
"sha256": "ca65367d373ed281d6a04c4677304bffbbc0c590d97d958f02404d65476790bd",
173945173945
"bytes": 701,
173946173946
"line": 85
173947173947
},
@@ -173955,7 +173955,7 @@
173955173955
{
173956173956
"lang": "yaml",
173957173957
"meta": null,
173958-
"sha256": "df68603f8a69b1564ae8792b1bf46bead93f1635ad2cf6aba1b0e53e250f2276",
173958+
"sha256": "b9ce9aab8d379f8e9173ab0d3fff2feaee5253bd26c6db477e96e984e9925970",
173959173959
"bytes": 176,
173960173960
"line": 138
173961173961
},
@@ -173983,7 +173983,7 @@
173983173983
{
173984173984
"lang": "bash",
173985173985
"meta": null,
173986-
"sha256": "d829002daa160ca953fad98f7df3af21515ccbd34feb96e5fa8f4d5d6c314278",
173986+
"sha256": "c970c43eea56151320bf4b5baa8118312be6dbfcf47eff7caf2210731151e359",
173987173987
"bytes": 130,
173988173988
"line": 232
173989173989
},
@@ -174240,7 +174240,7 @@
174240174240
{
174241174241
"lang": "yaml",
174242174242
"meta": null,
174243-
"sha256": "770a221e2ed89426cca37de3d61fce8a5d99e1f0cf5db0c5fe4586473de3ed0d",
174243+
"sha256": "ad130fab18b02e1e22b7229ed4d14696a5abb404e383e9738e0b2bcf4d004d47",
174244174244
"bytes": 243,
174245174245
"line": 35
174246174246
},

‎helm/sim/.claude/skills/sim-helm/references/install-paths.md‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ postgresql:
7979
existingSecret:
8080
enabled: true
8181
name: sim-postgres-secret
82-
passwordKey: POSTGRES_PASSWORD
8382
```
8483
8584
**The chart cannot introspect your Secret.** If you forget a required key, the pod will fail at runtime with `CreateContainerConfigError: secret key "X" not found`. The required keys are: `BETTER_AUTH_SECRET`, `ENCRYPTION_KEY`, `INTERNAL_API_SECRET`, plus `CRON_SECRET` when cronjobs are enabled.

‎helm/sim/.claude/skills/sim-helm/references/values-model.md‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ The Sim chart splits configuration across **four** layers. Understanding which l
1818
┌───────────────────────────────────────────────────────────────────────────┐
1919
│ Layer 2: app.envDefaults / realtime.envDefaults │
2020
│ → Rendered as inline env: on the Deployment │
21-
│ → SKIPPED for any key already set in app.env (or realtime.env) │
21+
│ → SKIPPED for any key already set in app.env (or realtime.env), or │
22+
│ mapped in externalSecrets.remoteRefs.app; none in existingSecret mode │
2223
│ → Use for: operational tunables and safe fallback defaults │
2324
│ → Examples: NODE_ENV=production, RATE_LIMIT_*, IVM_* │
2425
└───────────────────────────────────────────────────────────────────────────┘
@@ -27,7 +28,9 @@ The Sim chart splits configuration across **four** layers. Understanding which l
2728
▼
2829
┌───────────────────────────────────────────────────────────────────────────┐
2930
│ Layer 3: chart-computed (inline env: on the Deployment) │
30-
│ → DATABASE_URL, SOCKET_SERVER_URL, OLLAMA_URL, PII_URL │
31+
│ → DATABASE_URL, SOCKET_SERVER_URL, OLLAMA_URL, PII_URL │
32+
│ → BETTER_AUTH_URL=$(NEXT_PUBLIC_APP_URL) and NEXT_PUBLIC_SOCKET_URL │
33+
│ (separate realtime ingress host), only when you set them nowhere │
3134
│ → Derived from postgresql.* / externalDatabase.* / service.* values │
3235
│ → CANNOT be overridden via app.env — chart filters them out │
3336
└───────────────────────────────────────────────────────────────────────────┘
@@ -46,7 +49,7 @@ The Sim chart splits configuration across **four** layers. Understanding which l
4649

4750
**ESO compatibility.** When `externalSecrets.enabled=true`, the chart-managed Secret is **not rendered** — ESO renders one instead. Anything in Layer 1 must be mapped via `remoteRefs.app.<KEY>` or it's silently missing. Layers 2–4 are unaffected by ESO.
4851

49-
**Override precedence.** *Non-empty* values set in `app.env` (Layer 1 overrides) win over `envDefaults` (Layer 2) — so users who already had operational tunables in `app.env` continue to work. An *empty* `app.env` value does not override: it reads as "not specified" and the Layer 2 default still applies. To remove a key, override it with `null` (see "I want to REMOVE a key the chart sets" below).
52+
**Override precedence.** *Non-empty* values set in `app.env` (Layer 1 overrides) win over `envDefaults` (Layer 2) — so users who already had operational tunables in `app.env` continue to work. In `app.secrets.existingSecret` mode no `envDefaults` are inlined (the pre-created Secret is the source of truth) and `app.env` values are inlined instead, so overrides go in `app.env`. An *empty* `app.env` value does not override: it reads as "not specified" and the Layer 2 default still applies. To remove a key, override it with `null` (see "I want to REMOVE a key the chart sets" below).
5053

5154
## Where keys live — the canonical list
5255

@@ -56,7 +59,7 @@ The exhaustive list of keys per layer lives in `helm/sim/values.yaml`. Read the
5659
|---|---|---|
5760
| Auth secrets | 1 (app.env) | `BETTER_AUTH_SECRET`, `ENCRYPTION_KEY`, `INTERNAL_API_SECRET`, `CRON_SECRET`, `API_ENCRYPTION_KEY` |
5861
| Provider API keys | 1 (app.env) | `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, `GOOGLE_CLIENT_SECRET`, etc. |
59-
| Per-environment URLs | 1 (app.env) | `NEXT_PUBLIC_APP_URL`, `BETTER_AUTH_URL`, `NEXT_PUBLIC_SOCKET_URL` |
62+
| Per-environment URLs | 1 (app.env) | `NEXT_PUBLIC_APP_URL` (`BETTER_AUTH_URL` follows it unless set; set both in the Secret in existingSecret mode) |
6063
| Feature flags | 1 (app.env) | `ENTERPRISE_ENABLED`, `ACCESS_CONTROL_ENABLED`, `ORGANIZATIONS_ENABLED`, `SSO_ENABLED` (server only; enterprise features have no `NEXT_PUBLIC_` twins) |
6164
| Operational defaults | 2 (envDefaults) | `NODE_ENV=production`, `EMAIL_VERIFICATION_ENABLED=false`, `VERTEX_LOCATION=us-central1` |
6265
| Rate limits | 2 (envDefaults) | `RATE_LIMIT_WINDOW_MS`, `RATE_LIMIT_FREE_SYNC`, etc. |
@@ -124,10 +127,9 @@ Caveat worth passing to operators: `null` has no effect under `helm upgrade --re
124127
app:
125128
env:
126129
NEXT_PUBLIC_APP_URL: "https://sim.example.com"
127-
BETTER_AUTH_URL: "https://sim.example.com"
128130
```
129131

130-
This is the right answer for any clustered deploy. The chart's default is `http://localhost:3000` (Layer 2) — fine for kind/minikube, broken for production. The realtime Deployment also reads these via the shared Secret.
132+
This is the right answer for any clustered deploy. `BETTER_AUTH_URL` is set to `$(NEXT_PUBLIC_APP_URL)` unless you set it (in `app.secrets.existingSecret` mode the chart sets nothing, so the Secret must hold both). The chart's default is `http://localhost:3000` (Layer 2) — fine for kind/minikube, broken for production. The realtime Deployment also reads these via the shared Secret.
131133

132134
### "I want to inject a value from another ConfigMap"
133135

‎helm/sim/Chart.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: sim
33
description: A Helm chart for Sim - the open-source AI workspace where teams build, deploy, and manage AI agents
44
type: application
5-
version: 1.19.0
5+
version: 1.20.0
66
appVersion: "v0.8.26"
77
kubeVersion: ">=1.25.0-0"
88
home: https://sim.ai

0 commit comments

Comments
 (0)