From 95ad16cac4ea577d48f04b716ea2fc3225b59905 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Fri, 4 Dec 2026 10:18:55 -0600 Subject: [PATCH 1/4] 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 --- .github/workflows/helm.yml | 30 +- .../sim-helm/references/install-paths.md | 1 - helm/sim/Chart.yaml | 2 +- helm/sim/README.md | 27 +- helm/sim/ci/full-values.yaml | 3 + helm/sim/examples/values-aws-marketplace.yaml | 6 + helm/sim/examples/values-aws.yaml | 4 +- helm/sim/examples/values-azure.yaml | 4 +- helm/sim/examples/values-copilot.yaml | 6 +- helm/sim/examples/values-development.yaml | 4 +- helm/sim/examples/values-existing-secret.yaml | 14 +- helm/sim/examples/values-external-db.yaml | 27 +- .../sim/examples/values-external-secrets.yaml | 14 +- helm/sim/examples/values-gcp.yaml | 4 +- helm/sim/examples/values-production.yaml | 25 +- helm/sim/templates/NOTES.txt | 22 +- helm/sim/templates/_helpers.tpl | 351 ++++++++++++++++-- helm/sim/templates/deployment-app.yaml | 1 + helm/sim/templates/deployment-realtime.yaml | 33 +- helm/sim/templates/ingress-internal.yaml | 18 +- helm/sim/templates/ingress.yaml | 18 +- .../statefulset-copilot-postgres.yaml | 3 +- .../sim/templates/statefulset-postgresql.yaml | 3 +- helm/sim/tests/env-defaults_test.yaml | 257 ++++++++++++- helm/sim/tests/env-null-deletion_test.yaml | 2 +- helm/sim/tests/ingress-realtime_test.yaml | 171 +++++++++ helm/sim/tests/notes_test.yaml | 28 ++ helm/sim/tests/pdb-hpa_test.yaml | 3 + .../postgres-volume-claim-labels_test.yaml | 131 +++++++ helm/sim/tests/sandbox-kubernetes_test.yaml | 2 + helm/sim/tests/storage_test.yaml | 184 +++++++++ helm/sim/tests/validators_test.yaml | 48 +++ .../tests/values/historical-env-defaults.yaml | 62 ++++ helm/sim/values.schema.json | 13 +- helm/sim/values.yaml | 42 ++- 35 files changed, 1424 insertions(+), 139 deletions(-) create mode 100644 helm/sim/tests/ingress-realtime_test.yaml create mode 100644 helm/sim/tests/notes_test.yaml create mode 100644 helm/sim/tests/postgres-volume-claim-labels_test.yaml create mode 100644 helm/sim/tests/storage_test.yaml create mode 100644 helm/sim/tests/values/historical-env-defaults.yaml diff --git a/.github/workflows/helm.yml b/.github/workflows/helm.yml index d5192c37c17..a968765134f 100644 --- a/.github/workflows/helm.yml +++ b/.github/workflows/helm.yml @@ -165,7 +165,7 @@ jobs: name: install needs: chart runs-on: ${{ (vars.CI_PROVIDER == '' || vars.CI_PROVIDER == 'blacksmith') && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-latest' }} - timeout-minutes: 25 + timeout-minutes: 55 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6 with: @@ -192,6 +192,28 @@ jobs: - name: Run helm test run: helm test sim --namespace sim --timeout 5m + # Kubernetes refuses any change to a StatefulSet's volumeClaimTemplates, so + # a label that moves with the chart version there breaks every upgrade of + # the bundled Postgres while fresh installs keep passing. Install the newest + # published chart in its own namespace, then upgrade it to this checkout + # with the same values. + - name: Upgrade from the published chart + run: | + set -euo pipefail + chart=oci://ghcr.io/simstudioai/charts/sim + previous=$(helm show chart "$chart" | awk '/^version:/ {print $2}') + echo "Installing published chart ${previous}, then upgrading to this checkout" + helm install sim-upgrade "$chart" --version "$previous" \ + --namespace sim-upgrade --create-namespace \ + --values helm/sim/ci/default-values.yaml \ + --values helm/sim/ci/kind-overlay.yaml \ + --wait --timeout 10m + helm upgrade sim-upgrade helm/sim \ + --namespace sim-upgrade \ + --values helm/sim/ci/default-values.yaml \ + --values helm/sim/ci/kind-overlay.yaml \ + --wait --timeout 10m + # After the test, so it also explains a failed probe, not only a failed # install. A failed test pod is kept (the hook deletes it only on success), # so its log says which URL refused. @@ -205,6 +227,8 @@ jobs: kubectl -n sim logs deploy/sim-app --tail=80 || true kubectl -n sim logs deploy/sim-realtime --tail=80 || true kubectl -n sim logs sim-test-connection || true + kubectl -n sim-upgrade get pods -o wide || true + kubectl -n sim-upgrade get events --sort-by=.lastTimestamp | tail -20 || true # Resolved once and shared, so the two publish paths cannot package the same # immutable chart version with different appVersions -- they run in parallel, @@ -296,7 +320,7 @@ jobs: # Derives appVersion rather than checking it, so the published chart cannot # be pinned to an older Sim than the release it ships with. The committed - # value is kept current too, but nothing depends on a human remembering. + # value is not kept current; only this step sets the one that ships. - name: Sync chart appVersion to the release env: APP_VERSION: ${{ needs.release-version.outputs.version }} @@ -491,7 +515,7 @@ jobs: # Derives appVersion rather than checking it, so the published chart cannot # be pinned to an older Sim than the release it ships with. The committed - # value is kept current too, but nothing depends on a human remembering. + # value is not kept current; only this step sets the one that ships. - name: Sync chart appVersion to the release if: steps.pages.outputs.exists == 'true' env: diff --git a/helm/sim/.claude/skills/sim-helm/references/install-paths.md b/helm/sim/.claude/skills/sim-helm/references/install-paths.md index c83783d2dd7..296cf5e745c 100644 --- a/helm/sim/.claude/skills/sim-helm/references/install-paths.md +++ b/helm/sim/.claude/skills/sim-helm/references/install-paths.md @@ -79,7 +79,6 @@ postgresql: existingSecret: enabled: true name: sim-postgres-secret - passwordKey: POSTGRES_PASSWORD ``` **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. diff --git a/helm/sim/Chart.yaml b/helm/sim/Chart.yaml index 1401e875ab1..6a46f7c2b7b 100644 --- a/helm/sim/Chart.yaml +++ b/helm/sim/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: sim description: A Helm chart for Sim - the open-source AI workspace where teams build, deploy, and manage AI agents type: application -version: 1.19.0 +version: 1.20.0 appVersion: "v0.8.26" kubeVersion: ">=1.25.0-0" home: https://sim.ai diff --git a/helm/sim/README.md b/helm/sim/README.md index b55ecd76a19..0b3ed2bd319 100644 --- a/helm/sim/README.md +++ b/helm/sim/README.md @@ -500,7 +500,7 @@ User-supplied `securityContext` values are merged with the defaults — your val Other security features: * `automountServiceAccountToken: false` on the ServiceAccount **and** every pod. -* Every value in `app.env` and `realtime.env` is written to a chart-managed Secret and mounted via `envFrom: secretRef` — no values are inlined on the container spec. This eliminates a sensitivity classifier (no static list of "secret" keys to maintain) and ensures new provider keys can never accidentally leak into pod manifests. Two categories are inlined on the container instead: chart-computed values (`DATABASE_URL`, `SOCKET_SERVER_URL`, `OLLAMA_URL`, `PII_URL`) and operational defaults under `app.envDefaults` / `realtime.envDefaults` (rate limits, timeouts, IVM tunables, feature-flag defaults, `http://localhost:3000` URL fallbacks). Operational defaults are non-sensitive by design — moving them out of `app.env` keeps the Secret small and means External Secrets Operator users only have to map the keys they actually set, not every chart default. A **non-empty** value placed in `app.env` wins over the same key in `app.envDefaults` (the template skips the inline default when an override exists). An **empty** value does not — to remove a key rather than change it, see [Removing an inherited env key](#removing-an-inherited-env-key). +* Every value in `app.env` and `realtime.env` is written to a chart-managed Secret and mounted via `envFrom: secretRef` — no values are inlined on the container spec. This eliminates a sensitivity classifier (no static list of "secret" keys to maintain) and ensures new provider keys can never accidentally leak into pod manifests. Two categories are inlined on the container instead: chart-computed values (`DATABASE_URL`, `SOCKET_SERVER_URL`, `OLLAMA_URL`, `PII_URL`) and operational defaults under `app.envDefaults` / `realtime.envDefaults` (rate limits, timeouts, IVM tunables, feature-flag defaults, the `http://localhost:3000` `NEXT_PUBLIC_APP_URL` fallback). Operational defaults are non-sensitive by design — moving them out of `app.env` keeps the Secret small and means External Secrets Operator users only have to map the keys they actually set, not every chart default. A **non-empty** value placed in `app.env` wins over the same key in `app.envDefaults` (the template skips the inline default when an override exists). An **empty** value does not — to remove a key rather than change it, see [Removing an inherited env key](#removing-an-inherited-env-key). Likewise, under External Secrets a key mapped in `externalSecrets.remoteRefs.app` wins, and in `app.secrets.existingSecret` mode only the `envDefaults` values you changed from the chart's defaults are inlined. * Optional `networkPolicy.enabled=true` enforces east-west isolation and blocks cloud metadata endpoints in egress. --- @@ -644,6 +644,31 @@ kubectl --namespace sim logs deploy/sim-app -c migrations --- +## Upgrading to 1.20.0 + +* **Bundled Postgres upgrades work again.** Kubernetes forbids any change to a StatefulSet's `volumeClaimTemplates`, and the chart used to put its version labels on them, so every chart or appVersion bump failed `helm upgrade` with `spec: Forbidden: updates to statefulset spec for fields other than ...`. The `postgresql` and `copilot-postgresql` StatefulSets now keep the claim template labels they already have (read with `lookup`) and give new installs only labels that never change. `helm upgrade` needs no action, including a release stuck on that error, and neither does Flux (its helm-controller runs a real install or upgrade, so `lookup` works). **Argo CD and `helm template | kubectl apply` users**, where `lookup` returns nothing, get the new labels on a StatefulSet that has the old ones, so once, before upgrading, delete the StatefulSets without touching their pods or volumes: + + ```bash + kubectl --namespace sim delete statefulset -postgresql --cascade=orphan + kubectl --namespace sim delete statefulset -copilot-postgresql --cascade=orphan # only with copilot.postgresql.enabled + ``` + + The upgrade recreates them, and they adopt the running pods and existing PVCs. +* **Realtime is routed on the app host by default.** `ingress.realtime.host` now defaults to `""`, meaning `ingress.app.host`, and `ingress.realtime.paths` to `/socket.io`, which is where browsers connect when `NEXT_PUBLIC_SOCKET_URL` is empty. The old default (`sim-ws.local` with `/`) left realtime unreachable unless you also set `NEXT_PUBLIC_SOCKET_URL`. If you set a separate `ingress.realtime.host`, it keeps working, and when `NEXT_PUBLIC_SOCKET_URL` is set nowhere (`app.env`, `app.envDefaults`, `extraEnvVars`, `externalSecrets.remoteRefs.app`) the app now gets `http(s)://` (https when `ingress.tls.enabled` or `NEXT_PUBLIC_APP_URL` is https, as behind a TLS-terminating load balancer). If you relied on the old default paths while setting only the host, realtime on that host is now served under `/socket.io`, the only path the Socket.IO client uses. Sharing the app host with a realtime path of `/` now fails the render, because that rule sends every app request to realtime. +* **`BETTER_AUTH_URL` follows `NEXT_PUBLIC_APP_URL`.** It is no longer an `envDefaults` key fixed at `http://localhost:3000`; unless you set it (`app.env`, `realtime.env`, `envDefaults`, `extraEnvVars`, or `externalSecrets.remoteRefs.app`), the app and realtime pods get `$(NEXT_PUBLIC_APP_URL)`. In `app.secrets.existingSecret` mode the chart cannot see your Secret, so it sets nothing: keep `BETTER_AUTH_URL` in the Secret or in `app.env`. +* **External Secrets: a synced key is no longer masked by an `envDefaults` value.** A key mapped in `externalSecrets.remoteRefs.app` (for example `NEXT_PUBLIC_APP_URL`) used to be overridden by the inline `envDefaults` value; the chart now skips that default. +* **existingSecret mode applies the `envDefaults` you change.** Previously every `envDefaults` value was dropped in this mode, including ones you set. Now a value that differs from the chart's default is inlined; one still at the chart's default is not, so it never masks a key your Secret holds. +* **Object storage is required for more than one app replica.** With no object store configured (S3: `AWS_REGION` + `S3_BUCKET_NAME`; Azure Blob: `AZURE_STORAGE_CONTAINER_NAME` + `AZURE_CONNECTION_STRING` or `AZURE_ACCOUNT_NAME` + `AZURE_ACCOUNT_KEY`; GCS: `GCS_BUCKET_NAME`; in `app.env`, `app.envDefaults`, `extraEnvVars`, or `externalSecrets.remoteRefs.app`), uploads go to each pod's own filesystem. With `app.replicaCount > 1` or `autoscaling.enabled`, the render now fails, on install and upgrade alike (Argo CD renders with `helm template`, which cannot tell them apart). Fix it by configuring object storage, by mounting a shared (ReadWriteMany) volume at `/app/apps/sim/uploads` (`app.extraVolumes` / `app.extraVolumeMounts`), or by setting `app.storage.allowLocalWithReplicas=true` to accept that uploads stay on the pod that received them and are lost when it restarts. A single replica on local storage only prints a warning. `app.secrets.existingSecret` mode is trusted, since the chart cannot read the Secret. +* **New render-time checks.** An enabled `existingSecret` with an empty `name` (`app.secrets`, `postgresql.auth`, `externalDatabase`) now fails, as does enabling both `postgresql` and `externalDatabase`: the chart used the bundled database in that case, so set `externalDatabase.enabled=false` to keep it, or migrate your data and set `postgresql.enabled=false`. + +## Upgrading to 1.19.0 + +* **New default-on CronJob `cronjobs.jobs.cleanupCredentialGroupLinks`** (hourly, `/api/cron/cleanup-credential-group-links`). Its route ships with the next app release, so with an older Sim image it fails until you upgrade the app; set `cronjobs.jobs.cleanupCredentialGroupLinks.enabled=false` until then if you want quiet job history. + +## Upgrading to 1.17.0 and 1.18.0 + +* **Opt-in Kubernetes sandbox provider.** 1.17 adds `sandbox.kubernetes` (Function and workflow sandboxes as pods in a dedicated namespace, no third-party service) and 1.18 adds `sandbox.kubernetes.warmCapacity`. Both are off by default; installs that do not enable them need no action. + ## Upgrading to 1.16.0 * **The `copilot` service runs the TypeScript Mothership image.** Its settings follow that image, and the chart fails to render with an old name, naming the new one: diff --git a/helm/sim/ci/full-values.yaml b/helm/sim/ci/full-values.yaml index a8d8fd3f519..6c0fbe49463 100644 --- a/helm/sim/ci/full-values.yaml +++ b/helm/sim/ci/full-values.yaml @@ -7,6 +7,9 @@ app: INTERNAL_API_SECRET: "cicicicicicicicicicicicicicicicicicicicicicicicicicicicicicicici" CRON_SECRET: "cicicicicicicicicicicicicicicicicicicicicicicicicicicicicicicici" API_ENCRYPTION_KEY: "cicicicicicicicicicicicicicicicicicicicicicicicicicicicicicicici" + # Object storage: autoscaling below runs several app replicas, which local storage refuses. + AWS_REGION: "us-east-1" + S3_BUCKET_NAME: "ci-sim-workspace-files" postgresql: auth: diff --git a/helm/sim/examples/values-aws-marketplace.yaml b/helm/sim/examples/values-aws-marketplace.yaml index 07f1a452a65..39d031f3700 100644 --- a/helm/sim/examples/values-aws-marketplace.yaml +++ b/helm/sim/examples/values-aws-marketplace.yaml @@ -56,6 +56,12 @@ app: # The listing's product ID, which the Marketplace chart sets; rendered from this repository, # set it to the product ID shown on the listing. Its presence turns on the License Manager check. AWS_MARKETPLACE_LICENSE_PRODUCT_SKU: "prod-xxxxxxxxxxxxx" # EDIT + # Object storage for uploads (REQUIRED with more than one app replica: local storage is per + # pod). The IRSA role below also needs s3:GetObject, s3:PutObject, s3:DeleteObject and + # s3:ListBucket on the bucket, or add AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY to sim-app-secrets. + STORAGE_PROVIDER: "s3" + AWS_REGION: "us-east-1" # EDIT: the bucket's region + S3_BUCKET_NAME: "sim-workspace-files" # EDIT realtime: replicaCount: 2 diff --git a/helm/sim/examples/values-aws.yaml b/helm/sim/examples/values-aws.yaml index aed865f7e4e..3e5a97a1763 100644 --- a/helm/sim/examples/values-aws.yaml +++ b/helm/sim/examples/values-aws.yaml @@ -13,9 +13,9 @@ # does not work with ALB — ALB cannot serve Kubernetes TLS Secrets # # Install: -# helm install sim ./helm/sim \ +# helm install sim oci://ghcr.io/simstudioai/charts/sim --version "$CHART_VERSION" \ # --namespace sim --create-namespace \ -# --values ./helm/sim/examples/values-aws.yaml \ +# --values values-aws.yaml \ # --set app.env.BETTER_AUTH_SECRET="$BETTER_AUTH_SECRET" \ # --set app.env.ENCRYPTION_KEY="$ENCRYPTION_KEY" \ # --set app.env.INTERNAL_API_SECRET="$INTERNAL_API_SECRET" \ diff --git a/helm/sim/examples/values-azure.yaml b/helm/sim/examples/values-azure.yaml index ec2c6b4c941..b447510d081 100644 --- a/helm/sim/examples/values-azure.yaml +++ b/helm/sim/examples/values-azure.yaml @@ -11,9 +11,9 @@ # - (optional) GPU node pool tainted with sku=gpu:NoSchedule for Ollama # # Install: -# helm install sim ./helm/sim \ +# helm install sim oci://ghcr.io/simstudioai/charts/sim --version "$CHART_VERSION" \ # --namespace sim --create-namespace \ -# --values ./helm/sim/examples/values-azure.yaml \ +# --values values-azure.yaml \ # --set app.env.BETTER_AUTH_SECRET="$BETTER_AUTH_SECRET" \ # --set app.env.ENCRYPTION_KEY="$ENCRYPTION_KEY" \ # --set app.env.INTERNAL_API_SECRET="$INTERNAL_API_SECRET" \ diff --git a/helm/sim/examples/values-copilot.yaml b/helm/sim/examples/values-copilot.yaml index 4aa8ce7ac93..b93d365c89b 100644 --- a/helm/sim/examples/values-copilot.yaml +++ b/helm/sim/examples/values-copilot.yaml @@ -16,10 +16,10 @@ # --docker-password="$COPILOT_REGISTRY_TOKEN" # # Install (merge with your main values file using multiple --values flags): -# helm install sim ./helm/sim \ +# helm install sim oci://ghcr.io/simstudioai/charts/sim --version "$CHART_VERSION" \ # --namespace sim --create-namespace \ -# --values ./helm/sim/examples/values-production.yaml \ -# --values ./helm/sim/examples/values-copilot.yaml \ +# --values values-production.yaml \ +# --values values-copilot.yaml \ # --set app.env.BETTER_AUTH_SECRET="$BETTER_AUTH_SECRET" \ # --set app.env.ENCRYPTION_KEY="$ENCRYPTION_KEY" \ # --set app.env.INTERNAL_API_SECRET="$INTERNAL_API_SECRET" \ diff --git a/helm/sim/examples/values-development.yaml b/helm/sim/examples/values-development.yaml index b6d544d37be..c3c86525352 100644 --- a/helm/sim/examples/values-development.yaml +++ b/helm/sim/examples/values-development.yaml @@ -7,9 +7,9 @@ # Prerequisites: a working kubectl context. # # Install: -# helm install sim-dev ./helm/sim \ +# helm install sim-dev oci://ghcr.io/simstudioai/charts/sim --version "$CHART_VERSION" \ # --namespace sim-dev --create-namespace \ -# --values ./helm/sim/examples/values-development.yaml \ +# --values values-development.yaml \ # --set app.env.BETTER_AUTH_SECRET=$(openssl rand -hex 32) \ # --set app.env.ENCRYPTION_KEY=$(openssl rand -hex 32) \ # --set app.env.INTERNAL_API_SECRET=$(openssl rand -hex 32) \ diff --git a/helm/sim/examples/values-existing-secret.yaml b/helm/sim/examples/values-existing-secret.yaml index 1b440e661a6..e21680b3e16 100644 --- a/helm/sim/examples/values-existing-secret.yaml +++ b/helm/sim/examples/values-existing-secret.yaml @@ -15,9 +15,9 @@ # Full Secret manifests are at the bottom of this file. # # Install: -# helm install sim ./helm/sim \ +# helm install sim oci://ghcr.io/simstudioai/charts/sim --version "$CHART_VERSION" \ # --namespace sim --create-namespace \ -# --values ./helm/sim/examples/values-existing-secret.yaml +# --values values-existing-secret.yaml app: enabled: true @@ -29,8 +29,15 @@ app: env: NEXT_PUBLIC_APP_URL: "https://sim.example.com" BETTER_AUTH_URL: "https://sim.example.com" - NEXT_PUBLIC_SOCKET_URL: "wss://sim-ws.example.com" NODE_ENV: "production" + # Object storage (REQUIRED with more than one app replica: local storage is + # per pod). S3 shown; Azure Blob and GCS keys are listed in values.yaml. The + # chart cannot read your Secret, so it does not check these: put them here + # or in the Secret, with AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY in the + # Secret unless the pod has a cloud identity (IRSA, Workload Identity). + STORAGE_PROVIDER: "s3" + AWS_REGION: "us-east-1" # EDIT + S3_BUCKET_NAME: "example-sim-workspace-files" # EDIT realtime: enabled: true @@ -52,7 +59,6 @@ postgresql: existingSecret: enabled: true name: "sim-postgresql-secret" - passwordKey: "POSTGRES_PASSWORD" # --- # Create secrets before installing: diff --git a/helm/sim/examples/values-external-db.yaml b/helm/sim/examples/values-external-db.yaml index 0d7250ac1cc..b83c75f90b0 100644 --- a/helm/sim/examples/values-external-db.yaml +++ b/helm/sim/examples/values-external-db.yaml @@ -18,9 +18,9 @@ # export CRON_SECRET=$(openssl rand -hex 32) # export DB_PASSWORD=$(openssl rand -hex 24) # -# helm install sim ./helm/sim \ +# helm install sim oci://ghcr.io/simstudioai/charts/sim --version "$CHART_VERSION" \ # --namespace sim --create-namespace \ -# --values ./helm/sim/examples/values-external-db.yaml \ +# --values values-external-db.yaml \ # --set externalDatabase.host=your-db.example.com \ # --set externalDatabase.username=simstudio_user \ # --set externalDatabase.password="$DB_PASSWORD" \ @@ -51,8 +51,16 @@ app: env: NEXT_PUBLIC_APP_URL: "https://simstudio.acme.com" BETTER_AUTH_URL: "https://simstudio.acme.com" - SOCKET_SERVER_URL: "https://simstudio-ws.acme.com" - NEXT_PUBLIC_SOCKET_URL: "https://simstudio-ws.acme.com" + # Realtime is served on the app host under /socket.io (ingress below), so + # NEXT_PUBLIC_SOCKET_URL stays unset and browsers use the page origin. + + # Object storage (REQUIRED with more than one app replica: local storage is + # per pod). S3 shown; Azure Blob and GCS keys are listed in values.yaml. + # Credentials: AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY here, or a pod + # identity (IRSA / EKS Pod Identity) via serviceAccount.annotations. + STORAGE_PROVIDER: "s3" + AWS_REGION: "us-east-1" # EDIT + S3_BUCKET_NAME: "acme-sim-workspace-files" # EDIT # Security settings (REQUIRED - replace with your own secure secrets) # Generate using: openssl rand -hex 32 @@ -134,18 +142,13 @@ ingress: nginx.ingress.kubernetes.io/force-ssl-redirect: "true" cert-manager.io/cluster-issuer: "letsencrypt-prod" + # Realtime is routed on this host under /socket.io (ingress.realtime defaults). app: host: simstudio.acme.com paths: - path: / pathType: Prefix - realtime: - host: simstudio-ws.acme.com - paths: - - path: / - pathType: Prefix - tls: enabled: true secretName: simstudio-tls-secret @@ -186,8 +189,8 @@ networkPolicy: port: 5432 # Example deployment command with secure secret generation: -# helm install sim ./helm/sim \ -# --values ./helm/sim/examples/values-external-db.yaml \ +# helm install sim oci://ghcr.io/simstudioai/charts/sim --version "$CHART_VERSION" \ +# --values values-external-db.yaml \ # --set externalDatabase.host="your-db-host.com" \ # --set externalDatabase.username="your-db-user" \ # --set externalDatabase.password="your-db-password" \ diff --git a/helm/sim/examples/values-external-secrets.yaml b/helm/sim/examples/values-external-secrets.yaml index 04593826c2e..81916200cf8 100644 --- a/helm/sim/examples/values-external-secrets.yaml +++ b/helm/sim/examples/values-external-secrets.yaml @@ -16,9 +16,9 @@ # externalSecrets.remoteRefs below. # # Install: -# helm install sim ./helm/sim \ +# helm install sim oci://ghcr.io/simstudioai/charts/sim --version "$CHART_VERSION" \ # --namespace sim --create-namespace \ -# --values ./helm/sim/examples/values-external-secrets.yaml +# --values values-external-secrets.yaml externalSecrets: enabled: true @@ -34,6 +34,10 @@ externalSecrets: INTERNAL_API_SECRET: "sim/app/internal-api-secret" CRON_SECRET: "sim/app/cron-secret" API_ENCRYPTION_KEY: "sim/app/api-encryption-key" + # Object storage credentials, unless the pod has a cloud identity (IRSA, + # Workload Identity) granting bucket access: + # AWS_ACCESS_KEY_ID: "sim/app/aws-access-key-id" + # AWS_SECRET_ACCESS_KEY: "sim/app/aws-secret-access-key" # MSHIP_SYSPROMPT_OVERRIDE: "sim/app/mship-system-prompt-override" postgresql: password: "sim/postgresql/password" @@ -58,8 +62,12 @@ app: envDefaults: NEXT_PUBLIC_APP_URL: "https://sim.example.com" BETTER_AUTH_URL: "https://sim.example.com" - NEXT_PUBLIC_SOCKET_URL: "wss://sim-ws.example.com" NODE_ENV: "production" + # Object storage (REQUIRED with more than one app replica: local storage is + # per pod). S3 shown; Azure Blob and GCS keys are listed in values.yaml. + STORAGE_PROVIDER: "s3" + AWS_REGION: "us-east-1" # EDIT + S3_BUCKET_NAME: "example-sim-workspace-files" # EDIT realtime: enabled: true diff --git a/helm/sim/examples/values-gcp.yaml b/helm/sim/examples/values-gcp.yaml index df51dd6001a..6435ccf6aee 100644 --- a/helm/sim/examples/values-gcp.yaml +++ b/helm/sim/examples/values-gcp.yaml @@ -11,9 +11,9 @@ # - (optional) GPU node pool with accelerator labels for Ollama # # Install: -# helm install sim ./helm/sim \ +# helm install sim oci://ghcr.io/simstudioai/charts/sim --version "$CHART_VERSION" \ # --namespace sim --create-namespace \ -# --values ./helm/sim/examples/values-gcp.yaml \ +# --values values-gcp.yaml \ # --set app.env.BETTER_AUTH_SECRET="$BETTER_AUTH_SECRET" \ # --set app.env.ENCRYPTION_KEY="$ENCRYPTION_KEY" \ # --set app.env.INTERNAL_API_SECRET="$INTERNAL_API_SECRET" \ diff --git a/helm/sim/examples/values-production.yaml b/helm/sim/examples/values-production.yaml index f98a73ecdaa..d10f962f549 100644 --- a/helm/sim/examples/values-production.yaml +++ b/helm/sim/examples/values-production.yaml @@ -12,9 +12,9 @@ # - (recommended) External Secrets Operator — see values-external-secrets.yaml # # Install: -# helm install sim ./helm/sim \ +# helm install sim oci://ghcr.io/simstudioai/charts/sim --version "$CHART_VERSION" \ # --namespace sim --create-namespace \ -# --values ./helm/sim/examples/values-production.yaml \ +# --values values-production.yaml \ # --set app.env.BETTER_AUTH_SECRET="$BETTER_AUTH_SECRET" \ # --set app.env.ENCRYPTION_KEY="$ENCRYPTION_KEY" \ # --set app.env.INTERNAL_API_SECRET="$INTERNAL_API_SECRET" \ @@ -46,7 +46,16 @@ app: env: NEXT_PUBLIC_APP_URL: "https://sim.acme.ai" BETTER_AUTH_URL: "https://sim.acme.ai" - NEXT_PUBLIC_SOCKET_URL: "https://sim-ws.acme.ai" + # Realtime is served on the app host under /socket.io (ingress below), so + # NEXT_PUBLIC_SOCKET_URL stays unset and browsers use the page origin. + + # Object storage (REQUIRED with more than one app replica: local storage is + # per pod). S3 shown; Azure Blob and GCS keys are listed in values.yaml. + # Credentials: AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY here, or a pod + # identity (IRSA / EKS Pod Identity) via serviceAccount.annotations. + STORAGE_PROVIDER: "s3" + AWS_REGION: "us-east-1" # EDIT + S3_BUCKET_NAME: "acme-sim-workspace-files" # EDIT # Security settings (REQUIRED - pass with --set or an external secret manager; # the install fails while any is empty). Generate using: openssl rand -hex 32 @@ -154,20 +163,14 @@ ingress: nginx.ingress.kubernetes.io/force-ssl-redirect: "true" cert-manager.io/cluster-issuer: "letsencrypt-prod" - # Main application + # Main application. Realtime is routed on this host under /socket.io + # (ingress.realtime defaults). app: host: sim.acme.ai paths: - path: / pathType: Prefix - # Realtime service - realtime: - host: sim-ws.acme.ai - paths: - - path: / - pathType: Prefix - # TLS configuration tls: enabled: true diff --git a/helm/sim/templates/NOTES.txt b/helm/sim/templates/NOTES.txt index c3f3e211f8a..34a2d401d45 100644 --- a/helm/sim/templates/NOTES.txt +++ b/helm/sim/templates/NOTES.txt @@ -6,6 +6,13 @@ Keep this short and action-oriented. Users land here and decide what to do next. Thank you for installing {{ .Chart.Name }} ({{ .Chart.Name }}-{{ .Chart.Version }}, app {{ .Chart.AppVersion }}). Your release is named {{ .Release.Name }} in namespace {{ .Release.Namespace }}. +{{- if include "sim.localStorageInUse" . }} + +WARNING: no object storage is configured, so uploads are written to each app +pod's own filesystem: they are lost when the pod restarts and are not shared +between replicas. Configure S3 (AWS_REGION + S3_BUCKET_NAME), Azure Blob, or +GCS (GCS_BUCKET_NAME) in app.env; see STORAGE_PROVIDER in values.yaml. +{{- end }} 1. Watch the rollout finish: @@ -37,6 +44,9 @@ Your release is named {{ .Release.Name }} in namespace {{ .Release.Namespace }}. Ingress is disabled. Use port-forward to reach the app locally: kubectl --namespace {{ .Release.Namespace }} port-forward svc/{{ include "sim.fullname" . }}-app {{ .Values.app.service.port | default 3000 }}:{{ .Values.app.service.port | default 3000 }} +{{- if .Values.realtime.enabled }} + kubectl --namespace {{ .Release.Namespace }} port-forward svc/{{ include "sim.fullname" . }}-realtime {{ .Values.realtime.service.port | default 3002 }}:{{ .Values.realtime.service.port | default 3002 }} +{{- end }} Then open http://localhost:{{ .Values.app.service.port | default 3000 }} @@ -82,16 +92,10 @@ Your release is named {{ .Release.Name }} in namespace {{ .Release.Namespace }}. helm get values {{ .Release.Name }} --namespace {{ .Release.Namespace }} # Upgrade after changing values - helm upgrade {{ .Release.Name }} ./helm/sim --namespace {{ .Release.Namespace }} -f your-values.yaml - -5. Upgrade notes (read before upgrading from a chart version released before this one): + helm upgrade {{ .Release.Name }} oci://ghcr.io/simstudioai/charts/sim --version --namespace {{ .Release.Namespace }} -f your-values.yaml - * externalSecrets.apiVersion defaults to "v1". Current ESO releases no - longer serve v1beta1 (the compatibility path was removed in 2026) — set - externalSecrets.apiVersion: "v1beta1" only if you still run ESO < 0.17. - * networkPolicy.egress remains a list of custom egress rules (unchanged). - Cloud-metadata CIDR blocking is now configured via networkPolicy.egressExceptCidrs - (defaults to AWS/GCP/Azure IMDS + ECS task metadata). +5. Upgrading: read the "Upgrading" section of helm/sim/README.md before moving + to a newer chart version. 6. Where to go next: diff --git a/helm/sim/templates/_helpers.tpl b/helm/sim/templates/_helpers.tpl index 144ce18b129..d613889ade3 100644 --- a/helm/sim/templates/_helpers.tpl +++ b/helm/sim/templates/_helpers.tpl @@ -281,6 +281,18 @@ Skip validation when using existing secrets or External Secrets Operator {{- $useExternalSecrets := and .Values.externalSecrets .Values.externalSecrets.enabled }} {{- $useExistingPostgresSecret := and .Values.postgresql.auth.existingSecret .Values.postgresql.auth.existingSecret.enabled }} {{- $useExistingExternalDbSecret := and .Values.externalDatabase.existingSecret .Values.externalDatabase.existingSecret.enabled }} +{{- if and .Values.postgresql.enabled .Values.externalDatabase.enabled }} +{{- fail "Both postgresql.enabled and externalDatabase.enabled are true. The chart currently uses the bundled database; set externalDatabase.enabled=false to keep it, or migrate your data and set postgresql.enabled=false." }} +{{- end }} +{{- if and $useExistingAppSecret (not .Values.app.secrets.existingSecret.name) }} +{{- fail "app.secrets.existingSecret.enabled=true but app.secrets.existingSecret.name is empty. Set it to the name of your pre-created app Secret." }} +{{- end }} +{{- if and .Values.postgresql.enabled $useExistingPostgresSecret (not .Values.postgresql.auth.existingSecret.name) }} +{{- fail "postgresql.auth.existingSecret.enabled=true but postgresql.auth.existingSecret.name is empty. Set it to the name of your pre-created Secret holding POSTGRES_PASSWORD." }} +{{- end }} +{{- if and .Values.externalDatabase.enabled $useExistingExternalDbSecret (not .Values.externalDatabase.existingSecret.name) }} +{{- fail "externalDatabase.existingSecret.enabled=true but externalDatabase.existingSecret.name is empty. Set it to the name of your pre-created Secret holding EXTERNAL_DB_PASSWORD." }} +{{- end }} {{- /* App secrets validation - skip if using existing secret or ESO */ -}} {{- if not (or $useExistingAppSecret $useExternalSecrets) }} {{- if and .Values.app.enabled (not .Values.app.env.BETTER_AUTH_SECRET) }} @@ -821,30 +833,13 @@ Validate Copilot configuration {{/* Inline env entries the app container applies over its Secret, in precedence order (a later entry -for the same name wins): envDefaults the operator did not override, existingSecret-mode app.env -values, then extraEnvVars. Shared with the migrations init container so both resolve a key alike. +for the same name wins): envDefaults (see sim.envDefaultsEntries), existingSecret-mode app.env +values, then extraEnvVars. The derived NEXT_PUBLIC_SOCKET_URL and BETTER_AUTH_URL are emitted only +when no other source sets them; BETTER_AUTH_URL comes last, so its $(NEXT_PUBLIC_APP_URL) expands +whichever entry defines that. Shared with the migrations init container so both resolve a key alike. */}} {{- define "sim.appEnvOverrides" -}} -{{- /* - Skip envDefaults keys that the user has explicitly overridden in app.env - with a non-empty value. K8s `env` takes precedence over `envFrom`, so an - inline default would otherwise mask the user's Secret-bound value. - Also skip envDefaults entirely in existingSecret mode: the pre-existing - Secret is the source of truth, and inlining localhost URL defaults would - silently shadow keys (NEXT_PUBLIC_APP_URL, BETTER_AUTH_URL, etc.) the - user stored in their Secret but left empty in app.env. -*/}} -{{- $appEnv := .Values.app.env | default dict }} -{{- $useExistingSecret := and .Values.app.secrets.existingSecret.enabled (not .Values.externalSecrets.enabled) }} -{{- if not $useExistingSecret }} -{{- range $key, $value := .Values.app.envDefaults | default dict }} -{{- $override := index $appEnv $key }} -{{- if and (ne (toString $value) "") (ne (toString $value) "") (or (not $override) (eq (toString $override) "") (eq (toString $override) "")) }} -- name: {{ $key }} - value: {{ $value | quote }} -{{- end }} -{{- end }} -{{- end }} +{{- include "sim.envDefaultsEntries" (dict "root" . "component" "app") }} {{- /* In existingSecret mode the chart-managed Secret is not rendered, so non-empty values in app.env would otherwise go nowhere — inline them @@ -854,16 +849,326 @@ values, then extraEnvVars. Shared with the migrations init container so both res */}} {{- if and .Values.app.secrets.existingSecret.enabled (not .Values.externalSecrets.enabled) }} {{- $chartComputed := list "DATABASE_URL" "SOCKET_SERVER_URL" "OLLAMA_URL" "PII_URL" }} -{{- range $key, $value := $appEnv }} +{{- range $key, $value := .Values.app.env | default dict }} {{- if and (ne (toString $value) "") (ne (toString $value) "") (not (has $key $chartComputed)) }} - name: {{ $key }} value: {{ $value | quote }} {{- end }} {{- end }} {{- end }} +{{- include "sim.socketUrlEntry" . }} {{- with .Values.extraEnvVars }} {{ toYaml . }} {{- end }} +{{- include "sim.betterAuthUrlEntry" (dict "root" . "component" "app") }} +{{- end }} + +{{/* +Every envDefaults value a released chart has shipped, per component ("app" or "realtime"), as YAML +mapping each key to a list of values. In existingSecret mode a value on this list is not the +operator's choice, even from a values file copied from an older chart (NEXT_PUBLIC_BRAND_NAME, +BETTER_AUTH_URL, the free-tier limits), so it is never inlined over the Secret. Helm does not +expose a chart's own values.yaml to templates (.Files leaves it out), so the values are listed +here. Only ever add to a list: tests/env-defaults_test.yaml fails when today's values.yaml holds a +value missing here, or when one from tests/values/historical-env-defaults.yaml is dropped. +*/}} +{{- define "sim.shippedEnvDefaults" -}} +{{- if eq . "realtime" }} +ALLOWED_ORIGINS: ["http://localhost:3000"] +BETTER_AUTH_URL: ["http://localhost:3000"] +NEXT_PUBLIC_APP_URL: ["http://localhost:3000"] +NODE_ENV: ["production"] +{{- else }} +ACCESS_CONTROL_ENABLED: ["false"] +ADMISSION_GATE_MAX_INFLIGHT: ["500"] +BETTER_AUTH_URL: ["http://localhost:3000"] +BILLING_CONCURRENCY_LIMIT_ENTERPRISE: ["1000"] +BILLING_CONCURRENCY_LIMIT_FREE: ["10"] +BILLING_CONCURRENCY_LIMIT_PRO: ["50"] +BILLING_CONCURRENCY_LIMIT_TEAM: ["200"] +EMAIL_VERIFICATION_ENABLED: ["false"] +ENTERPRISE_TABLE_ROWS_LIMIT: ["1000000"] +ENTERPRISE_TABLES_LIMIT: ["10000"] +EXECUTION_TIMEOUT_ASYNC_ENTERPRISE: ["5400"] +EXECUTION_TIMEOUT_ASYNC_FREE: ["5400"] +EXECUTION_TIMEOUT_ASYNC_PRO: ["5400"] +EXECUTION_TIMEOUT_ASYNC_TEAM: ["5400"] +EXECUTION_TIMEOUT_ENTERPRISE: ["3000"] +EXECUTION_TIMEOUT_FREE: ["300"] +EXECUTION_TIMEOUT_PRO: ["3000"] +EXECUTION_TIMEOUT_TEAM: ["3000"] +FREE_TABLE_ROWS_LIMIT: ["1000"] +FREE_TABLES_LIMIT: ["3"] +IVM_DISTRIBUTED_LEASE_MIN_TTL_MS: ["120000"] +IVM_DISTRIBUTED_MAX_INFLIGHT_PER_OWNER: ["2200"] +IVM_MAX_ACTIVE_PER_OWNER: ["200"] +IVM_MAX_CONCURRENT: ["10000"] +IVM_MAX_FETCH_OPTIONS_JSON_CHARS: ["262144"] +IVM_MAX_FETCH_RESPONSE_BYTES: ["8388608"] +IVM_MAX_FETCH_RESPONSE_CHARS: ["4000000"] +IVM_MAX_FETCH_URL_LENGTH: ["8192"] +IVM_MAX_OWNER_WEIGHT: ["5"] +IVM_MAX_PER_WORKER: ["2500"] +IVM_MAX_QUEUE_SIZE: ["10000"] +IVM_MAX_QUEUED_PER_OWNER: ["2000"] +IVM_MAX_STDOUT_CHARS: ["200000"] +IVM_POOL_SIZE: ["4"] +IVM_QUEUE_TIMEOUT_MS: ["300000"] +IVM_WORKER_IDLE_TIMEOUT_MS: ["60000"] +NEXT_PUBLIC_ACCESS_CONTROL_ENABLED: ["false"] +NEXT_PUBLIC_APP_URL: ["http://localhost:3000"] +NEXT_PUBLIC_BRAND_NAME: ["Sim"] +NEXT_PUBLIC_ORGANIZATIONS_ENABLED: ["false"] +NEXT_PUBLIC_SUPPORT_EMAIL: ["help@sim.ai"] +NEXT_TELEMETRY_DISABLED: ["1"] +NODE_ENV: ["production"] +ORGANIZATIONS_ENABLED: ["false"] +PRO_TABLE_ROWS_LIMIT: ["5000"] +PRO_TABLES_LIMIT: ["25"] +RATE_LIMIT_FREE_ASYNC: ["200"] +RATE_LIMIT_FREE_SYNC: ["50"] +RATE_LIMIT_WINDOW_MS: ["60000"] +TEAM_TABLE_ROWS_LIMIT: ["10000"] +TEAM_TABLES_LIMIT: ["100"] +VERTEX_LOCATION: ["us-central1"] +{{- end }} +{{- end }} + +{{/* +"true" when an extraEnvVars entry (first arg: the list) supplies the key (second arg), by a +non-empty value or a valueFrom. +*/}} +{{- define "sim.extraEnvSets" -}} +{{- $key := index . 1 -}} +{{- range index . 0 | default list -}} +{{- if and (eq (toString .name) $key) (or .valueFrom (and .value (ne (toString .value) ""))) -}} +true +{{- end -}} +{{- end -}} +{{- end }} + +{{/* +"true" when the key (dict "root" $ "key" "") is mapped in externalSecrets.remoteRefs.app and +External Secrets is on, so the synced app Secret carries it. +*/}} +{{- define "sim.remoteRefMapsApp" -}} +{{- $values := .root.Values -}} +{{- if $values.externalSecrets.enabled -}} +{{- $remoteRefs := default (dict) (default (dict) $values.externalSecrets.remoteRefs).app -}} +{{- if index $remoteRefs .key -}} +true +{{- end -}} +{{- end -}} +{{- end }} + +{{/* +"true" when the operator supplies the key (dict "root" $ "key" "" "component" "app"|"realtime") +anywhere the chart can see on that component's pod: app.env (the shared Secret), the component's +env and envDefaults, extraEnvVars, or remoteRefs.app under External Secrets. +*/}} +{{- define "sim.keySupplied" -}} +{{- $values := .root.Values -}} +{{- $component := index $values .component -}} +{{- if or (include "sim.nonEmptyEnv" (list $values.app.env .key)) (include "sim.nonEmptyEnv" (list $component.env .key)) (include "sim.nonEmptyEnv" (list $component.envDefaults .key)) (include "sim.extraEnvSets" (list $values.extraEnvVars .key)) (include "sim.remoteRefMapsApp" (dict "root" .root "key" .key)) -}} +true +{{- end -}} +{{- end }} + +{{/* +Inline env entries for a component's envDefaults (dict "root" $ "component" "app"|"realtime"). +Kubernetes `env` beats `envFrom`, so a default is skipped wherever it would mask a value the +operator supplied through the Secret: + - app.env (and, for realtime, realtime.env) sets the key: it reaches the pod via the Secret, or + inline in existingSecret mode + - External Secrets maps the key in remoteRefs.app: the synced Secret carries it + - existingSecret mode and the value is still the chart's shipped default: the pre-created Secret + is the source of truth, so only a value the operator changed in envDefaults is inlined +*/}} +{{- define "sim.envDefaultsEntries" -}} +{{- $root := .root -}} +{{- $values := $root.Values -}} +{{- $useExistingSecret := and $values.app.secrets.existingSecret.enabled (not $values.externalSecrets.enabled) -}} +{{- $maskingEnvs := list $values.app.env -}} +{{- if eq .component "realtime" -}} +{{- $maskingEnvs = append $maskingEnvs $values.realtime.env -}} +{{- end -}} +{{- $shipped := include "sim.shippedEnvDefaults" .component | fromYaml -}} +{{- range $key, $value := (index $values .component).envDefaults | default dict -}} +{{- $masked := include "sim.remoteRefMapsApp" (dict "root" $root "key" $key) -}} +{{- range $env := $maskingEnvs -}} +{{- if include "sim.nonEmptyEnv" (list $env $key) -}} +{{- $masked = "true" -}} +{{- end -}} +{{- end -}} +{{- if and $useExistingSecret (has (toString $value) (index $shipped $key | default list)) -}} +{{- $masked = "true" -}} +{{- end -}} +{{- if and (not $masked) (ne (toString $value) "") (ne (toString $value) "") }} +- name: {{ $key }} + value: {{ $value | quote }} +{{- end -}} +{{- end -}} +{{- end }} + +{{/* +BETTER_AUTH_URL for a component (dict "root" $ "component" "app"|"realtime") when the operator set +it nowhere the chart can see: it follows NEXT_PUBLIC_APP_URL through dependent env expansion, which +resolves against envFrom and every earlier env entry, so it is emitted last. +Never in existingSecret mode, where the pre-created Secret may hold it and an inline entry would +mask it. +*/}} +{{- define "sim.betterAuthUrlEntry" -}} +{{- $values := .root.Values -}} +{{- $useExistingSecret := and $values.app.secrets.existingSecret.enabled (not $values.externalSecrets.enabled) -}} +{{- $explicit := include "sim.keySupplied" (dict "root" .root "key" "BETTER_AUTH_URL" "component" .component) -}} +{{- if not (or $useExistingSecret $explicit) }} +- name: BETTER_AUTH_URL + value: "$(NEXT_PUBLIC_APP_URL)" +{{- end -}} +{{- end }} + +{{/* +The host the public ingress serves realtime on: ingress.realtime.host, or the app host when empty. +Takes the ingress values (.Values.ingress or .Values.ingressInternal). +*/}} +{{- define "sim.ingressRealtimeHost" -}} +{{- default .app.host .realtime.host -}} +{{- end }} + +{{/* +Fail when realtime shares the app's ingress host with a "/" path: that rule is listed first and +would route every app request to realtime. Takes (list ""). +*/}} +{{- define "sim.validateIngressRealtimePaths" -}} +{{- $ingress := index . 0 -}} +{{- if eq (include "sim.ingressRealtimeHost" $ingress) (toString $ingress.app.host) -}} +{{- range $ingress.realtime.paths -}} +{{- if eq (toString .path) "/" -}} +{{- fail (printf "%s.realtime.paths contains \"/\" while realtime shares the app host %q: that rule would send every app request to the realtime service. Use the path /socket.io (the default), or set %s.realtime.host to a separate hostname." (index $ 1) (toString $ingress.app.host) (index $ 1)) -}} +{{- end -}} +{{- end -}} +{{- end -}} +{{- end }} + +{{/* +NEXT_PUBLIC_SOCKET_URL for the app when the public ingress serves realtime on its own host and the +operator set the URL nowhere the chart can see. Browsers otherwise connect to the page's origin, +which that ingress does not route to realtime. The scheme is https when ingress.tls.enabled or +NEXT_PUBLIC_APP_URL (app.env, else app.envDefaults) is https. Never in existingSecret mode (the pre-created +Secret may hold it), and never for sim-ws.local, the placeholder host charts before 1.20.0 shipped: +a values file copied from one still names it, and the page origin is what those installs use. +*/}} +{{- define "sim.socketUrlEntry" -}} +{{- $values := .Values -}} +{{- $useExistingSecret := and $values.app.secrets.existingSecret.enabled (not $values.externalSecrets.enabled) -}} +{{- if and $values.ingress.enabled $values.realtime.enabled (not $useExistingSecret) -}} +{{- $realtimeHost := include "sim.ingressRealtimeHost" $values.ingress -}} +{{- $explicit := include "sim.keySupplied" (dict "root" . "key" "NEXT_PUBLIC_SOCKET_URL" "component" "app") -}} +{{- /* https when the ingress terminates TLS, or when the public app URL says a load balancer in front does. */ -}} +{{- $appUrl := toString (index ($values.app.envDefaults | default dict) "NEXT_PUBLIC_APP_URL") -}} +{{- if include "sim.nonEmptyEnv" (list $values.app.env "NEXT_PUBLIC_APP_URL") -}} +{{- $appUrl = toString (index $values.app.env "NEXT_PUBLIC_APP_URL") -}} +{{- end -}} +{{- $scheme := "http" -}} +{{- if or (and $values.ingress.tls $values.ingress.tls.enabled) (hasPrefix "https://" $appUrl) -}} +{{- $scheme = "https" -}} +{{- end -}} +{{- if and (ne $realtimeHost (toString $values.ingress.app.host)) (ne $realtimeHost "sim-ws.local") (not $explicit) }} +- name: NEXT_PUBLIC_SOCKET_URL + value: {{ printf "%s://%s" $scheme $realtimeHost | quote }} +{{- end -}} +{{- end -}} +{{- end }} + +{{/* +"true" when the app stores uploads on its container filesystem: STORAGE_PROVIDER is "local", or it +is unset and no object store has the keys the app needs to select it (packages/deployment-config +STORAGE_CAPABILITY: azure = AZURE_STORAGE_CONTAINER_NAME + AZURE_CONNECTION_STRING or +AZURE_ACCOUNT_NAME + AZURE_ACCOUNT_KEY, s3 = AWS_REGION + S3_BUCKET_NAME, gcs = GCS_BUCKET_NAME). +A key counts when app.env, app.envDefaults, extraEnvVars, or (under External Secrets) +remoteRefs.app supplies it. A pre-created app Secret cannot be read, so it is trusted, and a volume +mounted at the uploads directory keeps the files. +*/}} +{{- define "sim.localStorageInUse" -}} +{{- $root := . -}} +{{- $values := .Values -}} +{{- $useExistingSecret := and $values.app.secrets.existingSecret.enabled (not $values.externalSecrets.enabled) -}} +{{- $uploadsMounted := false -}} +{{- range concat ($values.extraVolumeMounts | default list) ($values.app.extraVolumeMounts | default list) -}} +{{- if hasPrefix "/app/apps/sim/uploads" (toString .mountPath) -}} +{{- $uploadsMounted = true -}} +{{- end -}} +{{- end -}} +{{- if and $values.app.enabled (not $useExistingSecret) (not $uploadsMounted) -}} +{{- $present := dict -}} +{{- range $key := list "AWS_REGION" "S3_BUCKET_NAME" "AZURE_STORAGE_CONTAINER_NAME" "AZURE_CONNECTION_STRING" "AZURE_ACCOUNT_NAME" "AZURE_ACCOUNT_KEY" "GCS_BUCKET_NAME" -}} +{{- if include "sim.keySupplied" (dict "root" $root "key" $key "component" "app") -}} +{{- $_ := set $present $key true -}} +{{- end -}} +{{- end -}} +{{- /* The provider the pod resolves, in env precedence order; "?" when a secret reference supplies it. */ -}} +{{- $provider := "" -}} +{{- if include "sim.nonEmptyEnv" (list $values.app.envDefaults "STORAGE_PROVIDER") -}} +{{- $provider = toString (index $values.app.envDefaults "STORAGE_PROVIDER") -}} +{{- end -}} +{{- if include "sim.nonEmptyEnv" (list $values.app.env "STORAGE_PROVIDER") -}} +{{- $provider = toString (index $values.app.env "STORAGE_PROVIDER") -}} +{{- end -}} +{{- if include "sim.remoteRefMapsApp" (dict "root" $root "key" "STORAGE_PROVIDER") -}} +{{- $provider = "?" -}} +{{- end -}} +{{- range $values.extraEnvVars | default list -}} +{{- if eq (toString .name) "STORAGE_PROVIDER" -}} +{{- if .valueFrom -}} +{{- $provider = "?" -}} +{{- else if and .value (ne (toString .value) "") -}} +{{- $provider = toString .value -}} +{{- end -}} +{{- end -}} +{{- end -}} +{{- $azureReady := and (hasKey $present "AZURE_STORAGE_CONTAINER_NAME") (or (hasKey $present "AZURE_CONNECTION_STRING") (and (hasKey $present "AZURE_ACCOUNT_NAME") (hasKey $present "AZURE_ACCOUNT_KEY"))) -}} +{{- $s3Ready := and (hasKey $present "AWS_REGION") (hasKey $present "S3_BUCKET_NAME") -}} +{{- $gcsReady := hasKey $present "GCS_BUCKET_NAME" -}} +{{- if or (eq (lower $provider) "local") (and (eq $provider "") (not (or $azureReady $s3Ready $gcsReady))) -}} +true +{{- end -}} +{{- end -}} +{{- end }} + +{{/* +Local upload storage is per pod, so more than one app replica splits uploads between pods and loses +each pod's on restart. Refused on install and upgrade alike (helm template, which Argo CD renders +with, always reports an install), unless app.storage.allowLocalWithReplicas accepts it. +*/}} +{{- define "sim.validateStorage" -}} +{{- $allowLocal := and .Values.app.storage .Values.app.storage.allowLocalWithReplicas -}} +{{- if and (not $allowLocal) (or (gt (int .Values.app.replicaCount) 1) .Values.autoscaling.enabled) (include "sim.localStorageInUse" .) -}} +{{- fail "More than one app replica (app.replicaCount > 1 or autoscaling.enabled) with uploads stored on each pod's own filesystem: no object storage is configured. Fix it one of three ways: (1) configure object storage in app.env, e.g. STORAGE_PROVIDER=s3 with AWS_REGION + S3_BUCKET_NAME, STORAGE_PROVIDER=azure with AZURE_STORAGE_CONTAINER_NAME + AZURE_CONNECTION_STRING (or AZURE_ACCOUNT_NAME + AZURE_ACCOUNT_KEY), or STORAGE_PROVIDER=gcs with GCS_BUCKET_NAME; (2) mount a shared (ReadWriteMany) volume at /app/apps/sim/uploads via app.extraVolumes and app.extraVolumeMounts; or (3) set app.storage.allowLocalWithReplicas=true to accept that uploads stay on the pod that received them and are lost when it restarts." -}} +{{- end -}} +{{- end }} + +{{/* +Volume claim template labels for a bundled database StatefulSet +(dict "root" $ "name" "" "claim" "" "selectorLabels" ""). +Kubernetes rejects any change to volumeClaimTemplates, so these must never change across upgrades: +an existing StatefulSet's labels are reused verbatim (releases made before 1.20.0 carry the chart +version in them), and a new one gets only labels that never change. +*/}} +{{- define "sim.volumeClaimTemplateLabels" -}} +{{- $root := .root -}} +{{- $existing := lookup "apps/v1" "StatefulSet" $root.Release.Namespace .name -}} +{{- $labels := .selectorLabels | fromYaml -}} +{{- if $existing -}} +{{- range ($existing.spec | default dict).volumeClaimTemplates | default list -}} +{{- if eq (toString .metadata.name) $.claim -}} +{{- $labels = .metadata.labels | default dict -}} +{{- end -}} +{{- end -}} +{{- end -}} +{{- with $labels -}} +labels: + {{- toYaml . | nindent 2 }} +{{- end -}} {{- end }} {{/* diff --git a/helm/sim/templates/deployment-app.yaml b/helm/sim/templates/deployment-app.yaml index 2d46d8e38f0..d5cf8fbdb81 100644 --- a/helm/sim/templates/deployment-app.yaml +++ b/helm/sim/templates/deployment-app.yaml @@ -1,6 +1,7 @@ {{- if .Values.app.enabled }} {{- include "sim.validateSecrets" . }} {{- include "sim.sandbox.validate" . }} +{{- include "sim.validateStorage" . }} apiVersion: apps/v1 kind: Deployment metadata: diff --git a/helm/sim/templates/deployment-realtime.yaml b/helm/sim/templates/deployment-realtime.yaml index e7c6aa58e93..2d67e3f4e7a 100644 --- a/helm/sim/templates/deployment-realtime.yaml +++ b/helm/sim/templates/deployment-realtime.yaml @@ -75,33 +75,14 @@ spec: value: "service.name=sim-realtime,service.version={{ .Chart.AppVersion }},deployment.environment={{ $nodeEnv }}" {{- end }} {{- /* - Inline realtime.envDefaults, skipping keys explicitly set in realtime.env - OR app.env (K8s `env` overrides `envFrom`, so an inline default would - otherwise mask a Secret-bound value). The chart-managed Secret is shared - between app and realtime via envFrom, so a key set in app.env (e.g. - NEXT_PUBLIC_APP_URL=https://prod.example.com) lands on the realtime pod - too — inlining the localhost envDefault here would mask it. + realtime.envDefaults, skipping any key a Secret-bound source supplies (see + sim.envDefaultsEntries). The app Secret is shared with the app pod, so a key set + in app.env masks the default here too. */}} {{- $rtEnv := .Values.realtime.env | default dict }} {{- $appEnv := .Values.app.env | default dict }} - {{- $useExistingSecret := and .Values.app.secrets.existingSecret.enabled (not .Values.externalSecrets.enabled) }} - {{- /* - Skip envDefaults entirely in existingSecret mode — same rationale as - deployment-app.yaml: the pre-existing Secret is the source of truth, - and inlining localhost defaults would shadow URL keys (BETTER_AUTH_URL, - ALLOWED_ORIGINS, NEXT_PUBLIC_APP_URL, etc.) stored in the Secret. - */}} - {{- if not $useExistingSecret }} - {{- range $key, $value := .Values.realtime.envDefaults | default dict }} - {{- $rtOverride := index $rtEnv $key }} - {{- $appOverride := index $appEnv $key }} - {{- $hasRt := and $rtOverride (ne (toString $rtOverride) "") (ne (toString $rtOverride) "") }} - {{- $hasApp := and $appOverride (ne (toString $appOverride) "") (ne (toString $appOverride) "") }} - {{- if and (ne (toString $value) "") (ne (toString $value) "") (not $hasRt) (not $hasApp) }} - - name: {{ $key }} - value: {{ $value | quote }} - {{- end }} - {{- end }} + {{- with include "sim.envDefaultsEntries" (dict "root" . "component" "realtime") | trim }} + {{- . | nindent 12 }} {{- end }} {{- /* In existingSecret mode the chart-managed Secret is not rendered, so @@ -136,6 +117,10 @@ spec: {{- with .Values.extraEnvVars }} {{- toYaml . | nindent 12 }} {{- end }} + {{- /* Last, so $(NEXT_PUBLIC_APP_URL) expands whichever entry above defines it. */}} + {{- with include "sim.betterAuthUrlEntry" (dict "root" . "component" "realtime") | trim }} + {{- . | nindent 12 }} + {{- end }} envFrom: # Bundled Redis URL. Listed FIRST so any operator-supplied REDIS_URL # in a later source overrides it — see templates/configmap-redis.yaml. diff --git a/helm/sim/templates/ingress-internal.yaml b/helm/sim/templates/ingress-internal.yaml index 54a8e5766a5..eb3e31e5c4e 100644 --- a/helm/sim/templates/ingress-internal.yaml +++ b/helm/sim/templates/ingress-internal.yaml @@ -2,7 +2,11 @@ {{- $appActive := .Values.app.enabled -}} {{- $realtimeActive := .Values.realtime.enabled -}} {{- $hasCopilotIngress := and .Values.copilot.enabled .Values.ingressInternal.copilot -}} -{{- $realtimeHasOwnRule := and $realtimeActive (or (not $appActive) (ne .Values.ingressInternal.realtime.host .Values.ingressInternal.app.host)) -}} +{{- $realtimeHost := include "sim.ingressRealtimeHost" .Values.ingressInternal -}} +{{- if and $appActive $realtimeActive }} +{{- include "sim.validateIngressRealtimePaths" (list .Values.ingressInternal "ingressInternal") }} +{{- end }} +{{- $realtimeHasOwnRule := and $realtimeActive (or (not $appActive) (ne $realtimeHost (toString .Values.ingressInternal.app.host))) -}} apiVersion: networking.k8s.io/v1 kind: Ingress metadata: @@ -25,14 +29,14 @@ spec: - {{ .Values.ingressInternal.app.host | quote }} {{- end }} {{- if $realtimeHasOwnRule }} - - {{ .Values.ingressInternal.realtime.host | quote }} + - {{ $realtimeHost | quote }} {{- end }} {{- if $hasCopilotIngress }} {{- $copilotHostCovered := false }} {{- if and $appActive (eq .Values.ingressInternal.copilot.host .Values.ingressInternal.app.host) }} {{- $copilotHostCovered = true }} {{- end }} - {{- if and $realtimeHasOwnRule (eq .Values.ingressInternal.copilot.host .Values.ingressInternal.realtime.host) }} + {{- if and $realtimeHasOwnRule (eq .Values.ingressInternal.copilot.host $realtimeHost) }} {{- $copilotHostCovered = true }} {{- end }} {{- if not $copilotHostCovered }} @@ -46,7 +50,7 @@ spec: - host: {{ .Values.ingressInternal.app.host | quote }} http: paths: - {{- if and $realtimeActive (eq .Values.ingressInternal.realtime.host .Values.ingressInternal.app.host) }} + {{- if and $realtimeActive (eq $realtimeHost (toString .Values.ingressInternal.app.host)) }} {{- range .Values.ingressInternal.realtime.paths }} - path: {{ .path }} pathType: {{ .pathType }} @@ -79,7 +83,7 @@ spec: {{- end }} {{- end }} {{- if $realtimeHasOwnRule }} - - host: {{ .Values.ingressInternal.realtime.host | quote }} + - host: {{ $realtimeHost | quote }} http: paths: {{- range .Values.ingressInternal.realtime.paths }} @@ -91,7 +95,7 @@ spec: port: number: {{ $.Values.realtime.service.port }} {{- end }} - {{- if and $hasCopilotIngress (eq .Values.ingressInternal.copilot.host .Values.ingressInternal.realtime.host) }} + {{- if and $hasCopilotIngress (eq .Values.ingressInternal.copilot.host $realtimeHost) }} {{- range .Values.ingressInternal.copilot.paths }} - path: {{ .path }} pathType: {{ .pathType }} @@ -108,7 +112,7 @@ spec: {{- if and $appActive (eq .Values.ingressInternal.copilot.host .Values.ingressInternal.app.host) }} {{- $copilotServed = true }} {{- end }} - {{- if and $realtimeHasOwnRule (eq .Values.ingressInternal.copilot.host .Values.ingressInternal.realtime.host) }} + {{- if and $realtimeHasOwnRule (eq .Values.ingressInternal.copilot.host $realtimeHost) }} {{- $copilotServed = true }} {{- end }} {{- if not $copilotServed }} diff --git a/helm/sim/templates/ingress.yaml b/helm/sim/templates/ingress.yaml index 8014705b3d1..abcdd99766b 100644 --- a/helm/sim/templates/ingress.yaml +++ b/helm/sim/templates/ingress.yaml @@ -2,7 +2,11 @@ {{- $appActive := .Values.app.enabled -}} {{- $realtimeActive := .Values.realtime.enabled -}} {{- $hasCopilotIngress := and .Values.copilot.enabled .Values.ingress.copilot -}} -{{- $realtimeHasOwnRule := and $realtimeActive (or (not $appActive) (ne .Values.ingress.realtime.host .Values.ingress.app.host)) -}} +{{- $realtimeHost := include "sim.ingressRealtimeHost" .Values.ingress -}} +{{- if and $appActive $realtimeActive }} +{{- include "sim.validateIngressRealtimePaths" (list .Values.ingress "ingress") }} +{{- end }} +{{- $realtimeHasOwnRule := and $realtimeActive (or (not $appActive) (ne $realtimeHost (toString .Values.ingress.app.host))) -}} apiVersion: networking.k8s.io/v1 kind: Ingress metadata: @@ -25,14 +29,14 @@ spec: - {{ .Values.ingress.app.host | quote }} {{- end }} {{- if $realtimeHasOwnRule }} - - {{ .Values.ingress.realtime.host | quote }} + - {{ $realtimeHost | quote }} {{- end }} {{- if $hasCopilotIngress }} {{- $copilotHostCovered := false }} {{- if and $appActive (eq .Values.ingress.copilot.host .Values.ingress.app.host) }} {{- $copilotHostCovered = true }} {{- end }} - {{- if and $realtimeHasOwnRule (eq .Values.ingress.copilot.host .Values.ingress.realtime.host) }} + {{- if and $realtimeHasOwnRule (eq .Values.ingress.copilot.host $realtimeHost) }} {{- $copilotHostCovered = true }} {{- end }} {{- if not $copilotHostCovered }} @@ -46,7 +50,7 @@ spec: - host: {{ .Values.ingress.app.host | quote }} http: paths: - {{- if and $realtimeActive (eq .Values.ingress.realtime.host .Values.ingress.app.host) }} + {{- if and $realtimeActive (eq $realtimeHost (toString .Values.ingress.app.host)) }} {{- range .Values.ingress.realtime.paths }} - path: {{ .path }} pathType: {{ .pathType }} @@ -79,7 +83,7 @@ spec: {{- end }} {{- end }} {{- if $realtimeHasOwnRule }} - - host: {{ .Values.ingress.realtime.host | quote }} + - host: {{ $realtimeHost | quote }} http: paths: {{- range .Values.ingress.realtime.paths }} @@ -91,7 +95,7 @@ spec: port: number: {{ $.Values.realtime.service.port }} {{- end }} - {{- if and $hasCopilotIngress (eq .Values.ingress.copilot.host .Values.ingress.realtime.host) }} + {{- if and $hasCopilotIngress (eq .Values.ingress.copilot.host $realtimeHost) }} {{- range .Values.ingress.copilot.paths }} - path: {{ .path }} pathType: {{ .pathType }} @@ -108,7 +112,7 @@ spec: {{- if and $appActive (eq .Values.ingress.copilot.host .Values.ingress.app.host) }} {{- $copilotServed = true }} {{- end }} - {{- if and $realtimeHasOwnRule (eq .Values.ingress.copilot.host .Values.ingress.realtime.host) }} + {{- if and $realtimeHasOwnRule (eq .Values.ingress.copilot.host $realtimeHost) }} {{- $copilotServed = true }} {{- end }} {{- if not $copilotServed }} diff --git a/helm/sim/templates/statefulset-copilot-postgres.yaml b/helm/sim/templates/statefulset-copilot-postgres.yaml index fcb2e797774..c3872a35f63 100644 --- a/helm/sim/templates/statefulset-copilot-postgres.yaml +++ b/helm/sim/templates/statefulset-copilot-postgres.yaml @@ -130,8 +130,7 @@ spec: volumeClaimTemplates: - metadata: name: data - labels: - {{- include "sim.copilotPostgresql.labels" . | nindent 10 }} + {{- include "sim.volumeClaimTemplateLabels" (dict "root" . "name" (printf "%s-copilot-postgresql" (include "sim.fullname" .)) "claim" "data" "selectorLabels" (include "sim.copilotPostgresql.selectorLabels" .)) | nindent 8 }} spec: accessModes: {{- range .Values.copilot.postgresql.persistence.accessModes }} diff --git a/helm/sim/templates/statefulset-postgresql.yaml b/helm/sim/templates/statefulset-postgresql.yaml index 50c78b8a03d..9b07138ec95 100644 --- a/helm/sim/templates/statefulset-postgresql.yaml +++ b/helm/sim/templates/statefulset-postgresql.yaml @@ -187,8 +187,7 @@ spec: volumeClaimTemplates: - metadata: name: postgresql-data - labels: - {{- include "sim.postgresql.labels" . | nindent 10 }} + {{- include "sim.volumeClaimTemplateLabels" (dict "root" . "name" (printf "%s-postgresql" (include "sim.fullname" .)) "claim" "postgresql-data" "selectorLabels" (include "sim.postgresql.selectorLabels" .)) | nindent 8 }} spec: {{- if .Values.postgresql.persistence.storageClass }} {{- if (eq "-" .Values.postgresql.persistence.storageClass) }} diff --git a/helm/sim/tests/env-defaults_test.yaml b/helm/sim/tests/env-defaults_test.yaml index 144f45254f7..2abca4dff40 100644 --- a/helm/sim/tests/env-defaults_test.yaml +++ b/helm/sim/tests/env-defaults_test.yaml @@ -17,7 +17,7 @@ tests: - contains: path: spec.template.spec.containers[0].env content: - name: BETTER_AUTH_URL + name: NEXT_PUBLIC_APP_URL value: http://localhost:3000 - contains: path: spec.template.spec.containers[0].env @@ -48,7 +48,7 @@ tests: - contains: path: spec.template.spec.containers[0].env content: - name: BETTER_AUTH_URL + name: NEXT_PUBLIC_APP_URL value: http://localhost:3000 - it: existingSecret mode skips envDefaults on the app pod @@ -61,7 +61,7 @@ tests: - notContains: path: spec.template.spec.containers[0].env content: - name: BETTER_AUTH_URL + name: NEXT_PUBLIC_APP_URL value: http://localhost:3000 - it: existingSecret mode skips envDefaults on the realtime pod @@ -74,7 +74,7 @@ tests: - notContains: path: spec.template.spec.containers[0].env content: - name: BETTER_AUTH_URL + name: NEXT_PUBLIC_APP_URL value: http://localhost:3000 - it: existingSecret mode inlines user-set app.env values on the app pod @@ -119,3 +119,252 @@ tests: content: name: NEXT_PUBLIC_APP_URL value: "https://realtime.example.com" + + # External Secrets: a key synced into the app Secret must not be masked by an inline envDefault. + - it: ESO mode skips an app envDefault whose key remoteRefs.app maps + template: deployment-app.yaml + set: &esoMapsAppUrl + externalSecrets.enabled: true + externalSecrets.secretStoreRef.name: store + externalSecrets.remoteRefs.app.BETTER_AUTH_SECRET: sim/app/better-auth-secret + externalSecrets.remoteRefs.app.ENCRYPTION_KEY: sim/app/encryption-key + externalSecrets.remoteRefs.app.INTERNAL_API_SECRET: sim/app/internal-api-secret + externalSecrets.remoteRefs.app.CRON_SECRET: sim/app/cron-secret + externalSecrets.remoteRefs.app.NEXT_PUBLIC_APP_URL: sim/app/public-url + externalSecrets.remoteRefs.postgresql.password: sim/postgresql/password + asserts: + - notContains: + path: spec.template.spec.containers[0].env + content: + name: NEXT_PUBLIC_APP_URL + value: http://localhost:3000 + - contains: + path: spec.template.spec.containers[0].env + content: + name: IVM_POOL_SIZE + value: "4" + + - it: ESO mode skips a realtime envDefault whose key remoteRefs.app maps + template: deployment-realtime.yaml + set: + <<: *esoMapsAppUrl + asserts: + - notContains: + path: spec.template.spec.containers[0].env + content: + name: NEXT_PUBLIC_APP_URL + value: http://localhost:3000 + - contains: + path: spec.template.spec.containers[0].env + content: + name: ALLOWED_ORIGINS + value: http://localhost:3000 + + # existingSecret mode: an envDefaults value the operator changed reaches the pod; one still at the + # chart's default does not, so it cannot mask a key kept in the pre-created Secret. + - it: existingSecret mode inlines an app envDefault the operator changed + template: deployment-app.yaml + set: + app.secrets.existingSecret.enabled: true + app.secrets.existingSecret.name: my-secret + postgresql.auth.password: xxxxxxxx + app.envDefaults.IVM_POOL_SIZE: "8" + app.envDefaults.SOME_OPERATOR_KEY: "on" + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: + name: IVM_POOL_SIZE + value: "8" + - contains: + path: spec.template.spec.containers[0].env + content: + name: SOME_OPERATOR_KEY + value: "on" + - notContains: + path: spec.template.spec.containers[0].env + content: + name: IVM_MAX_CONCURRENT + value: "10000" + + - it: existingSecret mode inlines a realtime envDefault the operator changed + template: deployment-realtime.yaml + set: + app.secrets.existingSecret.enabled: true + app.secrets.existingSecret.name: my-secret + postgresql.auth.password: xxxxxxxx + realtime.envDefaults.ALLOWED_ORIGINS: https://sim.example.com + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: + name: ALLOWED_ORIGINS + value: https://sim.example.com + - notContains: + path: spec.template.spec.containers[0].env + content: + name: NODE_ENV + value: production + + # Guards sim.shippedEnvDefaults against drift from values.yaml: a default missing from that list + # (or holding another value) would be inlined here, past the chart-computed entries. + - it: existingSecret mode with untouched defaults inlines only chart-computed app env + template: deployment-app.yaml + set: + app.secrets.existingSecret.enabled: true + app.secrets.existingSecret.name: my-secret + postgresql.auth.password: xxxxxxxx + asserts: + - lengthEqual: + path: spec.template.spec.containers[0].env + count: 4 + + - it: existingSecret mode with untouched defaults inlines only chart-computed realtime env + template: deployment-realtime.yaml + set: + app.secrets.existingSecret.enabled: true + app.secrets.existingSecret.name: my-secret + postgresql.auth.password: xxxxxxxx + asserts: + - lengthEqual: + path: spec.template.spec.containers[0].env + count: 1 + + # A values file copied from any released chart carries that chart's defaults (1.11 shipped + # NEXT_PUBLIC_BRAND_NAME "Sim"); none of them may mask the white-label values in the Secret. + - it: existingSecret mode inlines no default any released chart shipped, on the app pod + template: deployment-app.yaml + values: + - values/historical-env-defaults.yaml + set: + app.secrets.existingSecret.enabled: true + app.secrets.existingSecret.name: my-secret + postgresql.auth.password: xxxxxxxx + asserts: + - lengthEqual: + path: spec.template.spec.containers[0].env + count: 4 + + - it: existingSecret mode inlines no default any released chart shipped, on the realtime pod + template: deployment-realtime.yaml + values: + - values/historical-env-defaults.yaml + set: + app.secrets.existingSecret.enabled: true + app.secrets.existingSecret.name: my-secret + postgresql.auth.password: xxxxxxxx + asserts: + - lengthEqual: + path: spec.template.spec.containers[0].env + count: 1 + + - it: existingSecret mode keeps the old NEXT_PUBLIC_BRAND_NAME default off the pod but inlines a changed one + template: deployment-app.yaml + set: + app.secrets.existingSecret.enabled: true + app.secrets.existingSecret.name: my-secret + postgresql.auth.password: xxxxxxxx + app.envDefaults.NEXT_PUBLIC_BRAND_NAME: Sim + app.envDefaults.NEXT_PUBLIC_SUPPORT_EMAIL: support@acme.example + asserts: + - notContains: + path: spec.template.spec.containers[0].env + content: + name: NEXT_PUBLIC_BRAND_NAME + any: true + - contains: + path: spec.template.spec.containers[0].env + content: + name: NEXT_PUBLIC_SUPPORT_EMAIL + value: support@acme.example + + # BETTER_AUTH_URL follows NEXT_PUBLIC_APP_URL unless the operator sets it somewhere. + - it: app BETTER_AUTH_URL defaults to NEXT_PUBLIC_APP_URL, after it + template: deployment-app.yaml + set: + <<: *defaults + asserts: + - equal: + path: spec.template.spec.containers[0].env[-1] + value: { name: BETTER_AUTH_URL, value: $(NEXT_PUBLIC_APP_URL) } + + - it: realtime BETTER_AUTH_URL defaults to NEXT_PUBLIC_APP_URL, after it + template: deployment-realtime.yaml + set: + <<: *defaults + asserts: + - equal: + path: spec.template.spec.containers[0].env[-1] + value: { name: BETTER_AUTH_URL, value: $(NEXT_PUBLIC_APP_URL) } + + - it: BETTER_AUTH_URL follows an extraEnvVars NEXT_PUBLIC_APP_URL, so the reference expands + template: deployment-app.yaml + set: + <<: *defaults + extraEnvVars: + - name: NEXT_PUBLIC_APP_URL + value: https://sim.example.com + asserts: + - equal: + path: spec.template.spec.containers[0].env[-1] + value: { name: BETTER_AUTH_URL, value: $(NEXT_PUBLIC_APP_URL) } + + - it: an app.env BETTER_AUTH_URL wins on both pods + templates: + - deployment-app.yaml + - deployment-realtime.yaml + set: + <<: *defaults + app.env.BETTER_AUTH_URL: https://auth.example.com + asserts: + - notContains: + path: spec.template.spec.containers[0].env + content: { name: BETTER_AUTH_URL, value: $(NEXT_PUBLIC_APP_URL) } + + - it: a realtime.env BETTER_AUTH_URL wins on the realtime pod + template: deployment-realtime.yaml + set: + <<: *defaults + realtime.env.BETTER_AUTH_URL: https://auth.example.com + asserts: + - notContains: + path: spec.template.spec.containers[0].env + content: { name: BETTER_AUTH_URL, value: $(NEXT_PUBLIC_APP_URL) } + + - it: an envDefaults BETTER_AUTH_URL is inlined instead of the reference + template: deployment-app.yaml + set: + <<: *defaults + app.envDefaults.BETTER_AUTH_URL: https://auth.example.com + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: { name: BETTER_AUTH_URL, value: https://auth.example.com } + - notContains: + path: spec.template.spec.containers[0].env + content: { name: BETTER_AUTH_URL, value: $(NEXT_PUBLIC_APP_URL) } + + - it: a remoteRefs.app BETTER_AUTH_URL wins on both pods + templates: + - deployment-app.yaml + - deployment-realtime.yaml + set: + <<: *esoMapsAppUrl + externalSecrets.remoteRefs.app.BETTER_AUTH_URL: sim/app/auth-url + asserts: + - notContains: + path: spec.template.spec.containers[0].env + content: { name: BETTER_AUTH_URL, value: $(NEXT_PUBLIC_APP_URL) } + + - it: existingSecret mode leaves BETTER_AUTH_URL to the pre-created Secret + templates: + - deployment-app.yaml + - deployment-realtime.yaml + set: + app.secrets.existingSecret.enabled: true + app.secrets.existingSecret.name: my-secret + postgresql.auth.password: xxxxxxxx + asserts: + - notContains: + path: spec.template.spec.containers[0].env + content: { name: BETTER_AUTH_URL, value: $(NEXT_PUBLIC_APP_URL) } diff --git a/helm/sim/tests/env-null-deletion_test.yaml b/helm/sim/tests/env-null-deletion_test.yaml index 8a50ff957b6..9a3bd6ee1a1 100644 --- a/helm/sim/tests/env-null-deletion_test.yaml +++ b/helm/sim/tests/env-null-deletion_test.yaml @@ -93,7 +93,7 @@ tests: - contains: path: spec.template.spec.containers[0].env content: - name: BETTER_AUTH_URL + name: NEXT_PUBLIC_APP_URL value: http://localhost:3000 - contains: path: spec.template.spec.containers[0].env diff --git a/helm/sim/tests/ingress-realtime_test.yaml b/helm/sim/tests/ingress-realtime_test.yaml new file mode 100644 index 00000000000..ac37093d205 --- /dev/null +++ b/helm/sim/tests/ingress-realtime_test.yaml @@ -0,0 +1,171 @@ +suite: ingress — realtime reachable where browsers connect +release: + name: t + namespace: sim +defaults: &defaults + app.env.BETTER_AUTH_SECRET: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + app.env.ENCRYPTION_KEY: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + app.env.INTERNAL_API_SECRET: x + app.env.CRON_SECRET: x + postgresql.auth.password: xxxxxxxx + ingress.enabled: true + ingress.app.host: sim.example.com +tests: + # With NEXT_PUBLIC_SOCKET_URL empty, browsers open Socket.IO on the page origin, so the app host + # itself must route /socket.io to realtime. + - it: by default serves realtime on the app host under /socket.io, ahead of the app + template: ingress.yaml + set: + <<: *defaults + asserts: + - lengthEqual: + path: spec.rules + count: 1 + - equal: + path: spec.rules[0].host + value: sim.example.com + - equal: + path: spec.rules[0].http.paths[0] + value: + path: /socket.io + pathType: Prefix + backend: + service: + name: t-sim-realtime + port: + number: 3002 + - equal: + path: spec.rules[0].http.paths[1].backend.service.name + value: t-sim-app + + - it: sets no socket URL on the app when realtime shares the app host + template: deployment-app.yaml + set: + <<: *defaults + asserts: + - notContains: + path: spec.template.spec.containers[0].env + content: + name: NEXT_PUBLIC_SOCKET_URL + any: true + + - it: points the app at a separate realtime host over https when TLS is on + template: deployment-app.yaml + set: + <<: *defaults + ingress.realtime.host: ws.example.com + ingress.tls.enabled: true + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: + name: NEXT_PUBLIC_SOCKET_URL + value: https://ws.example.com + + - it: points the app at a separate realtime host over http without TLS + template: deployment-app.yaml + set: + <<: *defaults + ingress.realtime.host: ws.example.com + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: + name: NEXT_PUBLIC_SOCKET_URL + value: http://ws.example.com + + # TLS terminated at a load balancer in front of the ingress (ALB, cloud LB) leaves ingress.tls off. + - it: uses https for a separate realtime host when NEXT_PUBLIC_APP_URL is https + template: deployment-app.yaml + set: + <<: *defaults + ingress.realtime.host: ws.example.com + app.env.NEXT_PUBLIC_APP_URL: https://sim.example.com + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: + name: NEXT_PUBLIC_SOCKET_URL + value: https://ws.example.com + + - it: uses https when an envDefaults NEXT_PUBLIC_APP_URL is https + template: deployment-app.yaml + set: + <<: *defaults + ingress.realtime.host: ws.example.com + app.envDefaults.NEXT_PUBLIC_APP_URL: https://sim.example.com + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: + name: NEXT_PUBLIC_SOCKET_URL + value: https://ws.example.com + + - it: keeps an operator-set NEXT_PUBLIC_SOCKET_URL for a separate realtime host + template: deployment-app.yaml + set: + <<: *defaults + ingress.realtime.host: ws.example.com + app.env.NEXT_PUBLIC_SOCKET_URL: wss://ws.example.com + asserts: + - notContains: + path: spec.template.spec.containers[0].env + content: + name: NEXT_PUBLIC_SOCKET_URL + any: true + + # A values file copied from a chart before 1.20.0 still names its placeholder realtime host. + - it: sets no socket URL for the former placeholder realtime host + template: deployment-app.yaml + set: + <<: *defaults + ingress.realtime.host: sim-ws.local + asserts: + - notContains: + path: spec.template.spec.containers[0].env + content: + name: NEXT_PUBLIC_SOCKET_URL + any: true + + - it: gives a separate realtime host its own rule with the operator's paths + template: ingress.yaml + set: + <<: *defaults + ingress.realtime.host: ws.example.com + ingress.realtime.paths: + - path: / + pathType: Prefix + asserts: + - equal: + path: spec.rules[1].host + value: ws.example.com + - equal: + path: spec.rules[1].http.paths[0].path + value: / + - equal: + path: spec.rules[0].http.paths[0].backend.service.name + value: t-sim-app + + - it: refuses a "/" realtime path on the app host + template: ingress.yaml + set: + <<: *defaults + ingress.realtime.host: sim.example.com + ingress.realtime.paths: + - path: / + pathType: Prefix + asserts: + - failedTemplate: + errorMessage: 'ingress.realtime.paths contains "/" while realtime shares the app host "sim.example.com": that rule would send every app request to the realtime service. Use the path /socket.io (the default), or set ingress.realtime.host to a separate hostname.' + + - it: refuses a "/" realtime path on the internal ingress app host + template: ingress-internal.yaml + set: + <<: *defaults + ingressInternal.enabled: true + ingressInternal.realtime.paths: + - path: / + pathType: Prefix + asserts: + - failedTemplate: + errorMessage: 'ingressInternal.realtime.paths contains "/" while realtime shares the app host "sim-internal.local": that rule would send every app request to the realtime service. Use the path /socket.io (the default), or set ingressInternal.realtime.host to a separate hostname.' diff --git a/helm/sim/tests/notes_test.yaml b/helm/sim/tests/notes_test.yaml new file mode 100644 index 00000000000..7a124ab263a --- /dev/null +++ b/helm/sim/tests/notes_test.yaml @@ -0,0 +1,28 @@ +suite: NOTES.txt — post-install guidance +templates: + - NOTES.txt +release: + name: t + namespace: sim +defaults: &defaults + app.env.BETTER_AUTH_SECRET: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + app.env.ENCRYPTION_KEY: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + app.env.INTERNAL_API_SECRET: x + app.env.CRON_SECRET: x + postgresql.auth.password: xxxxxxxx +tests: + - it: port-forwards realtime next to the app, so a local browser can open Socket.IO + set: + <<: *defaults + asserts: + - matchRegexRaw: + pattern: "port-forward svc/t-sim-realtime 3002:3002" + + - it: upgrades from the published chart, not a checkout path + set: + <<: *defaults + asserts: + - matchRegexRaw: + pattern: "helm upgrade t oci://ghcr.io/simstudioai/charts/sim --version" + - notMatchRegexRaw: + pattern: "\\./helm/sim" diff --git a/helm/sim/tests/pdb-hpa_test.yaml b/helm/sim/tests/pdb-hpa_test.yaml index 3960f2e4006..a5c0d86b89e 100644 --- a/helm/sim/tests/pdb-hpa_test.yaml +++ b/helm/sim/tests/pdb-hpa_test.yaml @@ -8,6 +8,9 @@ defaults: &defaults app.env.INTERNAL_API_SECRET: x app.env.CRON_SECRET: x postgresql.auth.password: xxxxxxxx + # Several app replicas need object storage (local uploads are per pod). + app.env.AWS_REGION: us-east-1 + app.env.S3_BUCKET_NAME: sim-files tests: - it: PDB does not render when replicaCount=1 and HPA is off (tri-state null) template: poddisruptionbudget.yaml diff --git a/helm/sim/tests/postgres-volume-claim-labels_test.yaml b/helm/sim/tests/postgres-volume-claim-labels_test.yaml new file mode 100644 index 00000000000..ff2a8d793c6 --- /dev/null +++ b/helm/sim/tests/postgres-volume-claim-labels_test.yaml @@ -0,0 +1,131 @@ +suite: bundled Postgres — volume claim template labels never change across upgrades +release: + name: t + namespace: sim +defaults: &defaults + app.env.BETTER_AUTH_SECRET: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + app.env.ENCRYPTION_KEY: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + app.env.INTERNAL_API_SECRET: x + app.env.CRON_SECRET: x + postgresql.auth.password: xxxxxxxx +copilot: &copilot + copilot.enabled: true + copilot.postgresql.auth.password: xxxxxxxx + copilot.server.image.tag: main-test + copilot.server.env.INTERNAL_API_SECRET: x + copilot.server.env.LICENSE_KEY: x + copilot.server.env.COPILOT_INBOUND_API_KEY: x + copilot.server.env.SIM_ENDPOINT: https://sim.example.com + copilot.server.env.REDIS_URL: redis://redis:6379 +tests: + # Kubernetes rejects any change to volumeClaimTemplates, so a label that moves with the chart + # version, the app version, or commonLabels there fails every `helm upgrade`. + - it: a new postgresql StatefulSet gets only stable claim labels + template: statefulset-postgresql.yaml + documentSelector: + path: kind + value: StatefulSet + set: + <<: *defaults + global.commonLabels.team: platform + asserts: + - equal: + path: spec.volumeClaimTemplates[0].metadata.labels + value: + app.kubernetes.io/name: sim + app.kubernetes.io/instance: t + app.kubernetes.io/component: postgresql + + - it: a new copilot-postgresql StatefulSet gets only stable claim labels + template: statefulset-copilot-postgres.yaml + documentSelector: + path: kind + value: StatefulSet + set: + <<: [*defaults, *copilot] + global.commonLabels.team: platform + asserts: + - equal: + path: spec.volumeClaimTemplates[0].metadata.labels + value: + app.kubernetes.io/name: sim + app.kubernetes.io/instance: t + app.kubernetes.io/component: copilot-postgresql + + - it: an existing postgresql StatefulSet keeps its claim labels, chart version included + template: statefulset-postgresql.yaml + documentSelector: + path: kind + value: StatefulSet + set: + <<: *defaults + kubernetesProvider: + scheme: + "apps/v1/StatefulSet": + gvr: + group: apps + version: v1 + resource: statefulsets + namespaced: true + objects: + - apiVersion: apps/v1 + kind: StatefulSet + metadata: + name: t-sim-postgresql + namespace: sim + spec: + volumeClaimTemplates: + - metadata: + name: postgresql-data + labels: + helm.sh/chart: sim-1.18.0 + app.kubernetes.io/version: v0.9.73 + app.kubernetes.io/name: sim + app.kubernetes.io/instance: t + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/component: postgresql + asserts: + - equal: + path: spec.volumeClaimTemplates[0].metadata.labels + value: + helm.sh/chart: sim-1.18.0 + app.kubernetes.io/version: v0.9.73 + app.kubernetes.io/name: sim + app.kubernetes.io/instance: t + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/component: postgresql + + - it: an existing copilot-postgresql StatefulSet keeps its claim labels + template: statefulset-copilot-postgres.yaml + documentSelector: + path: kind + value: StatefulSet + set: + <<: [*defaults, *copilot] + kubernetesProvider: + scheme: + "apps/v1/StatefulSet": + gvr: + group: apps + version: v1 + resource: statefulsets + namespaced: true + objects: + - apiVersion: apps/v1 + kind: StatefulSet + metadata: + name: t-sim-copilot-postgresql + namespace: sim + spec: + volumeClaimTemplates: + - metadata: + name: data + labels: + helm.sh/chart: sim-1.18.0 + app.kubernetes.io/component: copilot-postgresql + asserts: + - equal: + path: spec.volumeClaimTemplates[0].metadata.labels + value: + helm.sh/chart: sim-1.18.0 + app.kubernetes.io/component: copilot-postgresql diff --git a/helm/sim/tests/sandbox-kubernetes_test.yaml b/helm/sim/tests/sandbox-kubernetes_test.yaml index 560a58320f4..f3a6d135499 100644 --- a/helm/sim/tests/sandbox-kubernetes_test.yaml +++ b/helm/sim/tests/sandbox-kubernetes_test.yaml @@ -467,6 +467,8 @@ tests: template: deployment-app.yaml set: <<: *enabled + # Set, so the chart derives no BETTER_AUTH_URL after extraEnvVars and env[-1] is the operator's. + app.env.BETTER_AUTH_URL: https://sim.example.com extraEnvVars: - name: SANDBOX_K8S_CPU value: "2" diff --git a/helm/sim/tests/storage_test.yaml b/helm/sim/tests/storage_test.yaml new file mode 100644 index 00000000000..ad646ddad1a --- /dev/null +++ b/helm/sim/tests/storage_test.yaml @@ -0,0 +1,184 @@ +suite: upload storage — several app replicas need object storage +release: + name: t + namespace: sim +defaults: &defaults + app.env.BETTER_AUTH_SECRET: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + app.env.ENCRYPTION_KEY: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + app.env.INTERNAL_API_SECRET: x + app.env.CRON_SECRET: x + postgresql.auth.password: xxxxxxxx +tests: + - it: refuses a multi-replica install that stores uploads on the pod + template: deployment-app.yaml + set: + <<: *defaults + app.replicaCount: 2 + asserts: + - failedTemplate: + errorMessage: "More than one app replica (app.replicaCount > 1 or autoscaling.enabled) with uploads stored on each pod's own filesystem: no object storage is configured. Fix it one of three ways: (1) configure object storage in app.env, e.g. STORAGE_PROVIDER=s3 with AWS_REGION + S3_BUCKET_NAME, STORAGE_PROVIDER=azure with AZURE_STORAGE_CONTAINER_NAME + AZURE_CONNECTION_STRING (or AZURE_ACCOUNT_NAME + AZURE_ACCOUNT_KEY), or STORAGE_PROVIDER=gcs with GCS_BUCKET_NAME; (2) mount a shared (ReadWriteMany) volume at /app/apps/sim/uploads via app.extraVolumes and app.extraVolumeMounts; or (3) set app.storage.allowLocalWithReplicas=true to accept that uploads stay on the pod that received them and are lost when it restarts." + + - it: refuses an autoscaled install that stores uploads on the pod + template: deployment-app.yaml + set: + <<: *defaults + autoscaling.enabled: true + asserts: + - failedTemplate: {} + + # Argo CD renders with helm template, which always reports an install, so an upgrade-only pass + # would fail every sync anyway: install and upgrade behave the same. + - it: refuses an upgrade the same way + template: deployment-app.yaml + release: + upgrade: true + set: + <<: *defaults + app.replicaCount: 2 + asserts: + - failedTemplate: {} + + - it: accepts local storage with several replicas when the operator opts in + template: deployment-app.yaml + set: + <<: *defaults + app.replicaCount: 2 + app.storage.allowLocalWithReplicas: true + asserts: + - notFailedTemplate: {} + + - it: accepts a single replica on local storage + template: deployment-app.yaml + set: + <<: *defaults + asserts: + - notFailedTemplate: {} + + - it: accepts S3 configured in app.env + template: deployment-app.yaml + set: + <<: *defaults + app.replicaCount: 2 + app.env.AWS_REGION: us-east-1 + app.env.S3_BUCKET_NAME: sim-files + asserts: + - notFailedTemplate: {} + + - it: refuses S3 without the region it needs + template: deployment-app.yaml + set: + <<: *defaults + app.replicaCount: 2 + app.env.S3_BUCKET_NAME: sim-files + asserts: + - failedTemplate: {} + + - it: accepts Azure Blob configured in app.envDefaults + template: deployment-app.yaml + set: + <<: *defaults + app.replicaCount: 2 + app.envDefaults.AZURE_STORAGE_CONTAINER_NAME: files + app.envDefaults.AZURE_ACCOUNT_NAME: simfiles + app.env.AZURE_ACCOUNT_KEY: key + asserts: + - notFailedTemplate: {} + + - it: refuses Azure Blob with an account name but no key or connection string + template: deployment-app.yaml + set: + <<: *defaults + app.replicaCount: 2 + app.env.AZURE_STORAGE_CONTAINER_NAME: files + app.env.AZURE_ACCOUNT_NAME: simfiles + asserts: + - failedTemplate: {} + + - it: accepts GCS configured through extraEnvVars + template: deployment-app.yaml + set: + <<: *defaults + app.replicaCount: 2 + extraEnvVars: + - name: GCS_BUCKET_NAME + valueFrom: + configMapKeyRef: { name: storage, key: bucket } + asserts: + - notFailedTemplate: {} + + - it: accepts storage keys mapped under External Secrets + template: deployment-app.yaml + set: + app.replicaCount: 2 + externalSecrets.enabled: true + externalSecrets.secretStoreRef.name: store + externalSecrets.remoteRefs.app.BETTER_AUTH_SECRET: a + externalSecrets.remoteRefs.app.ENCRYPTION_KEY: b + externalSecrets.remoteRefs.app.INTERNAL_API_SECRET: c + externalSecrets.remoteRefs.app.CRON_SECRET: d + externalSecrets.remoteRefs.app.GCS_BUCKET_NAME: e + externalSecrets.remoteRefs.postgresql.password: f + asserts: + - notFailedTemplate: {} + + - it: accepts an explicit non-local STORAGE_PROVIDER + template: deployment-app.yaml + set: + <<: *defaults + app.replicaCount: 2 + app.env.STORAGE_PROVIDER: s3 + asserts: + - notFailedTemplate: {} + + - it: refuses STORAGE_PROVIDER=local even with an object store configured + template: deployment-app.yaml + set: + <<: *defaults + app.replicaCount: 2 + app.env.STORAGE_PROVIDER: local + app.env.AWS_REGION: us-east-1 + app.env.S3_BUCKET_NAME: sim-files + asserts: + - failedTemplate: {} + + - it: trusts a pre-created app Secret it cannot read + template: deployment-app.yaml + set: + app.replicaCount: 2 + app.secrets.existingSecret.enabled: true + app.secrets.existingSecret.name: my-secret + postgresql.auth.password: xxxxxxxx + asserts: + - notFailedTemplate: {} + + - it: accepts a volume mounted at the uploads directory + template: deployment-app.yaml + set: + <<: *defaults + app.replicaCount: 2 + app.extraVolumes: + - name: uploads + persistentVolumeClaim: { claimName: sim-uploads } + app.extraVolumeMounts: + - name: uploads + mountPath: /app/apps/sim/uploads + asserts: + - notFailedTemplate: {} + + - it: warns in NOTES when uploads stay on the pod + template: NOTES.txt + set: + <<: *defaults + asserts: + - matchRegexRaw: + pattern: "WARNING: no object storage is configured" + + - it: does not warn in NOTES once object storage is configured + template: NOTES.txt + set: + <<: *defaults + app.env.AWS_REGION: us-east-1 + app.env.S3_BUCKET_NAME: sim-files + asserts: + - notMatchRegexRaw: + pattern: "no object storage" diff --git a/helm/sim/tests/validators_test.yaml b/helm/sim/tests/validators_test.yaml index 2346929076d..9f5ce89c542 100644 --- a/helm/sim/tests/validators_test.yaml +++ b/helm/sim/tests/validators_test.yaml @@ -124,3 +124,51 @@ tests: asserts: - failedTemplate: errorMessage: "app.env.BETTER_AUTH_SECRET is required for production deployment" + + - it: fails when app.secrets.existingSecret is enabled without a name + set: + app.secrets.existingSecret.enabled: true + app.secrets.existingSecret.name: "" + postgresql.auth.password: xxxxxxxx + asserts: + - failedTemplate: + errorMessage: "app.secrets.existingSecret.enabled=true but app.secrets.existingSecret.name is empty. Set it to the name of your pre-created app Secret." + + - it: fails when postgresql.auth.existingSecret is enabled without a name + set: + app.env.BETTER_AUTH_SECRET: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + app.env.ENCRYPTION_KEY: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + app.env.INTERNAL_API_SECRET: x + app.env.CRON_SECRET: x + postgresql.auth.existingSecret.enabled: true + postgresql.auth.existingSecret.name: "" + asserts: + - failedTemplate: + errorMessage: "postgresql.auth.existingSecret.enabled=true but postgresql.auth.existingSecret.name is empty. Set it to the name of your pre-created Secret holding POSTGRES_PASSWORD." + + - it: fails when externalDatabase.existingSecret is enabled without a name + set: + app.env.BETTER_AUTH_SECRET: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + app.env.ENCRYPTION_KEY: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + app.env.INTERNAL_API_SECRET: x + app.env.CRON_SECRET: x + postgresql.enabled: false + externalDatabase.enabled: true + externalDatabase.existingSecret.enabled: true + externalDatabase.existingSecret.name: "" + asserts: + - failedTemplate: + errorMessage: "externalDatabase.existingSecret.enabled=true but externalDatabase.existingSecret.name is empty. Set it to the name of your pre-created Secret holding EXTERNAL_DB_PASSWORD." + + - it: fails when both the bundled and an external database are enabled + set: + app.env.BETTER_AUTH_SECRET: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + app.env.ENCRYPTION_KEY: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + app.env.INTERNAL_API_SECRET: x + app.env.CRON_SECRET: x + postgresql.auth.password: xxxxxxxx + externalDatabase.enabled: true + externalDatabase.password: xxxxxxxx + asserts: + - failedTemplate: + errorMessage: "Both postgresql.enabled and externalDatabase.enabled are true. The chart currently uses the bundled database; set externalDatabase.enabled=false to keep it, or migrate your data and set postgresql.enabled=false." diff --git a/helm/sim/tests/values/historical-env-defaults.yaml b/helm/sim/tests/values/historical-env-defaults.yaml new file mode 100644 index 00000000000..cbb05fde099 --- /dev/null +++ b/helm/sim/tests/values/historical-env-defaults.yaml @@ -0,0 +1,62 @@ +# Every envDefaults value a released chart has shipped (from helm/sim/values.yaml history). +# A values file copied from any of those charts must read as untouched in existingSecret mode. +app: + envDefaults: + ACCESS_CONTROL_ENABLED: "false" + ADMISSION_GATE_MAX_INFLIGHT: "500" + BETTER_AUTH_URL: "http://localhost:3000" + BILLING_CONCURRENCY_LIMIT_ENTERPRISE: "1000" + BILLING_CONCURRENCY_LIMIT_FREE: "10" + BILLING_CONCURRENCY_LIMIT_PRO: "50" + BILLING_CONCURRENCY_LIMIT_TEAM: "200" + EMAIL_VERIFICATION_ENABLED: "false" + ENTERPRISE_TABLE_ROWS_LIMIT: "1000000" + ENTERPRISE_TABLES_LIMIT: "10000" + EXECUTION_TIMEOUT_ASYNC_ENTERPRISE: "5400" + EXECUTION_TIMEOUT_ASYNC_FREE: "5400" + EXECUTION_TIMEOUT_ASYNC_PRO: "5400" + EXECUTION_TIMEOUT_ASYNC_TEAM: "5400" + EXECUTION_TIMEOUT_ENTERPRISE: "3000" + EXECUTION_TIMEOUT_FREE: "300" + EXECUTION_TIMEOUT_PRO: "3000" + EXECUTION_TIMEOUT_TEAM: "3000" + FREE_TABLE_ROWS_LIMIT: "1000" + FREE_TABLES_LIMIT: "3" + IVM_DISTRIBUTED_LEASE_MIN_TTL_MS: "120000" + IVM_DISTRIBUTED_MAX_INFLIGHT_PER_OWNER: "2200" + IVM_MAX_ACTIVE_PER_OWNER: "200" + IVM_MAX_CONCURRENT: "10000" + IVM_MAX_FETCH_OPTIONS_JSON_CHARS: "262144" + IVM_MAX_FETCH_RESPONSE_BYTES: "8388608" + IVM_MAX_FETCH_RESPONSE_CHARS: "4000000" + IVM_MAX_FETCH_URL_LENGTH: "8192" + IVM_MAX_OWNER_WEIGHT: "5" + IVM_MAX_PER_WORKER: "2500" + IVM_MAX_QUEUE_SIZE: "10000" + IVM_MAX_QUEUED_PER_OWNER: "2000" + IVM_MAX_STDOUT_CHARS: "200000" + IVM_POOL_SIZE: "4" + IVM_QUEUE_TIMEOUT_MS: "300000" + IVM_WORKER_IDLE_TIMEOUT_MS: "60000" + NEXT_PUBLIC_ACCESS_CONTROL_ENABLED: "false" + NEXT_PUBLIC_APP_URL: "http://localhost:3000" + NEXT_PUBLIC_BRAND_NAME: "Sim" + NEXT_PUBLIC_ORGANIZATIONS_ENABLED: "false" + NEXT_PUBLIC_SUPPORT_EMAIL: "help@sim.ai" + NEXT_TELEMETRY_DISABLED: "1" + NODE_ENV: "production" + ORGANIZATIONS_ENABLED: "false" + PRO_TABLE_ROWS_LIMIT: "5000" + PRO_TABLES_LIMIT: "25" + RATE_LIMIT_FREE_ASYNC: "200" + RATE_LIMIT_FREE_SYNC: "50" + RATE_LIMIT_WINDOW_MS: "60000" + TEAM_TABLE_ROWS_LIMIT: "10000" + TEAM_TABLES_LIMIT: "100" + VERTEX_LOCATION: "us-central1" +realtime: + envDefaults: + ALLOWED_ORIGINS: "http://localhost:3000" + BETTER_AUTH_URL: "http://localhost:3000" + NEXT_PUBLIC_APP_URL: "http://localhost:3000" + NODE_ENV: "production" diff --git a/helm/sim/values.schema.json b/helm/sim/values.schema.json index 1a819f635aa..c9a39856efe 100644 --- a/helm/sim/values.schema.json +++ b/helm/sim/values.schema.json @@ -40,6 +40,15 @@ "minimum": 1, "description": "Number of app replicas" }, + "storage": { + "type": "object", + "properties": { + "allowLocalWithReplicas": { + "type": "boolean", + "description": "Allow more than one app replica (or autoscaling) with uploads on each pod's filesystem; they are not shared and are lost on restart" + } + } + }, "resources": { "type": "object", "properties": { @@ -1183,8 +1192,8 @@ "properties": { "host": { "type": "string", - "format": "hostname", - "description": "Realtime service hostname" + "anyOf": [{ "format": "hostname" }, { "const": "" }], + "description": "Realtime service hostname; empty serves realtime on ingress.app.host" } } }, diff --git a/helm/sim/values.yaml b/helm/sim/values.yaml index d78f5c66eb8..167797aedc8 100644 --- a/helm/sim/values.yaml +++ b/helm/sim/values.yaml @@ -29,6 +29,12 @@ app: # Number of replicas replicaCount: 1 + # Upload storage. With more than one replica (or autoscaling) and no object storage configured + # (see STORAGE_PROVIDER under app.env), the render fails, because each pod would keep its own + # uploads and lose them on restart. Set allowLocalWithReplicas=true only to accept exactly that. + storage: + allowLocalWithReplicas: false + # Resource limits and requests resources: limits: @@ -69,10 +75,11 @@ app: # Environment variables env: - # Application URLs — set NEXT_PUBLIC_APP_URL / BETTER_AUTH_URL to your public origin - # (e.g. https://sim.example.com). Defaults to http://localhost:3000 via app.envDefaults - # for local installs; override here (or via --set) for production. Set values here go - # into the chart-managed Secret and take precedence over envDefaults at runtime. + # Application URLs — set NEXT_PUBLIC_APP_URL to your public origin (e.g. https://sim.example.com). + # It defaults to http://localhost:3000 via app.envDefaults for local installs; override here + # (or via --set) for production. BETTER_AUTH_URL follows NEXT_PUBLIC_APP_URL when left empty + # (set it in your Secret in app.secrets.existingSecret mode). Set values here go into the + # chart-managed Secret and take precedence over envDefaults at runtime. NEXT_PUBLIC_APP_URL: "" BETTER_AUTH_URL: "" INTERNAL_API_BASE_URL: "" # Optional server-side internal base URL for /api self-calls (include http:// or https://); falls back to NEXT_PUBLIC_APP_URL when empty @@ -285,6 +292,11 @@ app: # Optional file storage override. One of: local, s3, azure, gcs. # Empty preserves legacy Azure → S3 → GCS → local precedence. + # Local storage writes uploads to the pod's own filesystem (lost on restart, not shared), so + # app.replicaCount > 1 or autoscaling.enabled fails to render without an object store: S3 + # (AWS_REGION + S3_BUCKET_NAME), Azure Blob (AZURE_STORAGE_CONTAINER_NAME + + # AZURE_CONNECTION_STRING, or AZURE_ACCOUNT_NAME + AZURE_ACCOUNT_KEY), or GCS (GCS_BUCKET_NAME), + # unless a shared volume is mounted at /app/apps/sim/uploads or app.storage.allowLocalWithReplicas. STORAGE_PROVIDER: "" # AWS S3 Cloud Storage Configuration (optional - for file storage) @@ -337,9 +349,11 @@ app: # does NOT remove it: every key under `app.env` ships as a "" placeholder, so the templates # must read "" as "unspecified". See "Removing an inherited env key" in README.md. envDefaults: - # Application URLs (override in app.env or app.envDefaults for production) + # Application URL (override in app.env or app.envDefaults for production). BETTER_AUTH_URL is + # not preset: unless app.env, envDefaults, extraEnvVars, or externalSecrets.remoteRefs.app sets + # it, the chart sets it to $(NEXT_PUBLIC_APP_URL) (not in app.secrets.existingSecret mode, + # where the pre-created Secret must hold it). NEXT_PUBLIC_APP_URL: "http://localhost:3000" - BETTER_AUTH_URL: "http://localhost:3000" # Node environment NODE_ENV: "production" @@ -498,7 +512,8 @@ realtime: # Environment variables — Secret-bound. See `envDefaults` below for chart-shipped defaults. env: # Application URLs — must mirror the public origin used by the main app. - # Defaults to http://localhost:3000 via envDefaults; override here for production. + # NEXT_PUBLIC_APP_URL defaults to http://localhost:3000 via envDefaults (override here or in + # app.env for production); BETTER_AUTH_URL follows NEXT_PUBLIC_APP_URL when left empty. NEXT_PUBLIC_APP_URL: "" BETTER_AUTH_URL: "" @@ -515,9 +530,9 @@ realtime: # Operational defaults shipped with the chart. Rendered as inline `env:` on the realtime # container (NOT written into the Secret, NOT required in externalSecrets.remoteRefs). # User-set values in `realtime.env` above take precedence. + # BETTER_AUTH_URL follows NEXT_PUBLIC_APP_URL unless set (same rule as app.envDefaults). envDefaults: NEXT_PUBLIC_APP_URL: "http://localhost:3000" - BETTER_AUTH_URL: "http://localhost:3000" ALLOWED_ORIGINS: "http://localhost:3000" NODE_ENV: "production" @@ -1034,11 +1049,16 @@ ingress: - path: / pathType: Prefix - # Realtime service (use /socket.io when sharing host with app) + # Realtime service. An empty host serves it on ingress.app.host under /socket.io, which is where + # browsers connect when app.env.NEXT_PUBLIC_SOCKET_URL is empty. To use a separate hostname, set + # host (paths may then be /); unless NEXT_PUBLIC_SOCKET_URL is set (app.env, app.envDefaults, + # extraEnvVars, or externalSecrets.remoteRefs.app), the chart points the app at + # http(s)://, https when ingress.tls.enabled or NEXT_PUBLIC_APP_URL is https. On the app + # host a "/" path fails the render: it would route every app request to realtime. realtime: - host: sim-ws.local + host: "" paths: - - path: / + - path: /socket.io pathType: Prefix # Copilot service (optional, use /copilot when sharing host) From a5337e313ced7241a45bfbe78eb04c1a2f999144 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Fri, 4 Dec 2026 10:50:12 -0600 Subject: [PATCH 2/4] fix(helm): exact uploads mount match, https socket URL from every source, legacy realtime host, and runnable example installs --- .github/workflows/helm.yml | 18 +++++- helm/sim/README.md | 2 +- helm/sim/examples/values-aws-marketplace.yaml | 12 +++- helm/sim/examples/values-aws.yaml | 2 + helm/sim/examples/values-azure.yaml | 2 + helm/sim/examples/values-copilot.yaml | 3 + helm/sim/examples/values-development.yaml | 2 + helm/sim/examples/values-existing-secret.yaml | 9 +++ helm/sim/examples/values-external-db.yaml | 11 ++++ .../sim/examples/values-external-secrets.yaml | 9 +++ helm/sim/examples/values-gcp.yaml | 2 + helm/sim/examples/values-production.yaml | 9 +++ helm/sim/templates/_helpers.tpl | 47 +++++++++++--- helm/sim/templates/ingress-internal.yaml | 4 +- helm/sim/templates/ingress.yaml | 4 +- helm/sim/tests/ingress-realtime_test.yaml | 61 +++++++++++++++++++ helm/sim/tests/storage_test.yaml | 24 ++++++++ helm/sim/values.yaml | 8 ++- 18 files changed, 208 insertions(+), 21 deletions(-) diff --git a/.github/workflows/helm.yml b/.github/workflows/helm.yml index a968765134f..4e49d960635 100644 --- a/.github/workflows/helm.yml +++ b/.github/workflows/helm.yml @@ -201,8 +201,22 @@ jobs: run: | set -euo pipefail chart=oci://ghcr.io/simstudioai/charts/sim - previous=$(helm show chart "$chart" | awk '/^version:/ {print $2}') - echo "Installing published chart ${previous}, then upgrading to this checkout" + # The newest published version strictly below this checkout's, so a rerun after this + # version is published still tests an upgrade rather than same to same. Helm cannot list + # OCI tags, so read them from the registry API with an anonymous pull token. + current=$(awk '/^version:/ {print $2}' helm/sim/Chart.yaml) + token=$(curl -fsS "https://ghcr.io/token?scope=repository:simstudioai/charts/sim:pull" | jq -r .token) + previous=$(curl -fsS -H "Authorization: Bearer ${token}" \ + "https://ghcr.io/v2/simstudioai/charts/sim/tags/list?n=1000" \ + | jq -r '.tags[]' \ + | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' \ + | { cat; echo "$current"; } | sort -uV \ + | awk -v current="$current" '$0 == current {print prev; exit} {prev = $0}') + if [ -z "$previous" ]; then + echo "::error::No published chart version below ${current} to upgrade from." + exit 1 + fi + echo "Installing published chart ${previous}, then upgrading to this checkout (${current})" helm install sim-upgrade "$chart" --version "$previous" \ --namespace sim-upgrade --create-namespace \ --values helm/sim/ci/default-values.yaml \ diff --git a/helm/sim/README.md b/helm/sim/README.md index 0b3ed2bd319..64ae023007a 100644 --- a/helm/sim/README.md +++ b/helm/sim/README.md @@ -654,7 +654,7 @@ kubectl --namespace sim logs deploy/sim-app -c migrations ``` The upgrade recreates them, and they adopt the running pods and existing PVCs. -* **Realtime is routed on the app host by default.** `ingress.realtime.host` now defaults to `""`, meaning `ingress.app.host`, and `ingress.realtime.paths` to `/socket.io`, which is where browsers connect when `NEXT_PUBLIC_SOCKET_URL` is empty. The old default (`sim-ws.local` with `/`) left realtime unreachable unless you also set `NEXT_PUBLIC_SOCKET_URL`. If you set a separate `ingress.realtime.host`, it keeps working, and when `NEXT_PUBLIC_SOCKET_URL` is set nowhere (`app.env`, `app.envDefaults`, `extraEnvVars`, `externalSecrets.remoteRefs.app`) the app now gets `http(s)://` (https when `ingress.tls.enabled` or `NEXT_PUBLIC_APP_URL` is https, as behind a TLS-terminating load balancer). If you relied on the old default paths while setting only the host, realtime on that host is now served under `/socket.io`, the only path the Socket.IO client uses. Sharing the app host with a realtime path of `/` now fails the render, because that rule sends every app request to realtime. +* **Realtime is routed on the app host by default.** `ingress.realtime.host` now defaults to `""`, meaning `ingress.app.host`, and `ingress.realtime.paths` to `/socket.io`, which is where browsers connect when `NEXT_PUBLIC_SOCKET_URL` is empty. The old default (`sim-ws.local` with `/`) left realtime unreachable unless you also set `NEXT_PUBLIC_SOCKET_URL`. If you set a separate `ingress.realtime.host`, it keeps working, and when `NEXT_PUBLIC_SOCKET_URL` is set nowhere (`app.env`, `app.envDefaults`, `extraEnvVars`, `externalSecrets.remoteRefs.app`) the app now gets `http(s)://` (https when `ingress.tls.enabled` or the `NEXT_PUBLIC_APP_URL` from `app.env`, `app.envDefaults` or `extraEnvVars` is https, as behind a TLS-terminating load balancer). If you relied on the old default paths while setting only the host, realtime on that host is now served under `/socket.io`, the only path the Socket.IO client uses. Sharing the app host with a realtime path of `/` now fails the render, because that rule sends every app request to realtime. A values file copied from an older chart that still names the old placeholder (`host: sim-ws.local`, path `/`) is treated as the new default: realtime on the app host under `/socket.io`. The derived URL can't read a `NEXT_PUBLIC_APP_URL` that only External Secrets supplies, so with TLS terminated in front of the ingress (and `ingress.tls.enabled=false`) set `NEXT_PUBLIC_SOCKET_URL` yourself; in `app.secrets.existingSecret` mode the chart never derives it, so keep it in the Secret. * **`BETTER_AUTH_URL` follows `NEXT_PUBLIC_APP_URL`.** It is no longer an `envDefaults` key fixed at `http://localhost:3000`; unless you set it (`app.env`, `realtime.env`, `envDefaults`, `extraEnvVars`, or `externalSecrets.remoteRefs.app`), the app and realtime pods get `$(NEXT_PUBLIC_APP_URL)`. In `app.secrets.existingSecret` mode the chart cannot see your Secret, so it sets nothing: keep `BETTER_AUTH_URL` in the Secret or in `app.env`. * **External Secrets: a synced key is no longer masked by an `envDefaults` value.** A key mapped in `externalSecrets.remoteRefs.app` (for example `NEXT_PUBLIC_APP_URL`) used to be overridden by the inline `envDefaults` value; the chart now skips that default. * **existingSecret mode applies the `envDefaults` you change.** Previously every `envDefaults` value was dropped in this mode, including ones you set. Now a value that differs from the chart's default is inlined; one still at the chart's default is not, so it never masks a key your Secret holds. diff --git a/helm/sim/examples/values-aws-marketplace.yaml b/helm/sim/examples/values-aws-marketplace.yaml index 39d031f3700..17049172fd7 100644 --- a/helm/sim/examples/values-aws-marketplace.yaml +++ b/helm/sim/examples/values-aws-marketplace.yaml @@ -57,11 +57,19 @@ app: # set it to the product ID shown on the listing. Its presence turns on the License Manager check. AWS_MARKETPLACE_LICENSE_PRODUCT_SKU: "prod-xxxxxxxxxxxxx" # EDIT # Object storage for uploads (REQUIRED with more than one app replica: local storage is per - # pod). The IRSA role below also needs s3:GetObject, s3:PutObject, s3:DeleteObject and - # s3:ListBucket on the bucket, or add AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY to sim-app-secrets. + # pod). The IRSA role below also needs s3:GetObject, s3:PutObject, s3:DeleteObject, + # s3:ListBucket, s3:AbortMultipartUpload and s3:ListMultipartUploadParts on every bucket (large + # uploads are multipart), or add AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY to sim-app-secrets. STORAGE_PROVIDER: "s3" AWS_REGION: "us-east-1" # EDIT: the bucket's region S3_BUCKET_NAME: "sim-workspace-files" # EDIT + # EDIT: these purposes do not fall back to S3_BUCKET_NAME, so each needs a + # bucket (OG images and workspace logos do fall back). + S3_KB_BUCKET_NAME: "sim-knowledge-base" + S3_EXECUTION_FILES_BUCKET_NAME: "sim-execution-files" + S3_CHAT_BUCKET_NAME: "sim-chat-files" + S3_COPILOT_BUCKET_NAME: "sim-copilot-files" + S3_PROFILE_PICTURES_BUCKET_NAME: "sim-profile-pictures" realtime: replicaCount: 2 diff --git a/helm/sim/examples/values-aws.yaml b/helm/sim/examples/values-aws.yaml index 3e5a97a1763..6077a23a7de 100644 --- a/helm/sim/examples/values-aws.yaml +++ b/helm/sim/examples/values-aws.yaml @@ -13,6 +13,8 @@ # does not work with ALB — ALB cannot serve Kubernetes TLS Secrets # # Install: +# # Examples are not in the chart package: fetch them at the chart's release tag. +# curl -fsSLO "https://raw.githubusercontent.com/simstudioai/sim/helm-chart-${CHART_VERSION}/helm/sim/examples/values-aws.yaml" # helm install sim oci://ghcr.io/simstudioai/charts/sim --version "$CHART_VERSION" \ # --namespace sim --create-namespace \ # --values values-aws.yaml \ diff --git a/helm/sim/examples/values-azure.yaml b/helm/sim/examples/values-azure.yaml index b447510d081..e30859312ea 100644 --- a/helm/sim/examples/values-azure.yaml +++ b/helm/sim/examples/values-azure.yaml @@ -11,6 +11,8 @@ # - (optional) GPU node pool tainted with sku=gpu:NoSchedule for Ollama # # Install: +# # Examples are not in the chart package: fetch them at the chart's release tag. +# curl -fsSLO "https://raw.githubusercontent.com/simstudioai/sim/helm-chart-${CHART_VERSION}/helm/sim/examples/values-azure.yaml" # helm install sim oci://ghcr.io/simstudioai/charts/sim --version "$CHART_VERSION" \ # --namespace sim --create-namespace \ # --values values-azure.yaml \ diff --git a/helm/sim/examples/values-copilot.yaml b/helm/sim/examples/values-copilot.yaml index b93d365c89b..5299827bc29 100644 --- a/helm/sim/examples/values-copilot.yaml +++ b/helm/sim/examples/values-copilot.yaml @@ -16,6 +16,9 @@ # --docker-password="$COPILOT_REGISTRY_TOKEN" # # Install (merge with your main values file using multiple --values flags): +# # Examples are not in the chart package: fetch them at the chart's release tag. +# curl -fsSLO "https://raw.githubusercontent.com/simstudioai/sim/helm-chart-${CHART_VERSION}/helm/sim/examples/values-production.yaml" +# curl -fsSLO "https://raw.githubusercontent.com/simstudioai/sim/helm-chart-${CHART_VERSION}/helm/sim/examples/values-copilot.yaml" # helm install sim oci://ghcr.io/simstudioai/charts/sim --version "$CHART_VERSION" \ # --namespace sim --create-namespace \ # --values values-production.yaml \ diff --git a/helm/sim/examples/values-development.yaml b/helm/sim/examples/values-development.yaml index c3c86525352..fa57ac1efe8 100644 --- a/helm/sim/examples/values-development.yaml +++ b/helm/sim/examples/values-development.yaml @@ -7,6 +7,8 @@ # Prerequisites: a working kubectl context. # # Install: +# # Examples are not in the chart package: fetch them at the chart's release tag. +# curl -fsSLO "https://raw.githubusercontent.com/simstudioai/sim/helm-chart-${CHART_VERSION}/helm/sim/examples/values-development.yaml" # helm install sim-dev oci://ghcr.io/simstudioai/charts/sim --version "$CHART_VERSION" \ # --namespace sim-dev --create-namespace \ # --values values-development.yaml \ diff --git a/helm/sim/examples/values-existing-secret.yaml b/helm/sim/examples/values-existing-secret.yaml index e21680b3e16..fdea468b634 100644 --- a/helm/sim/examples/values-existing-secret.yaml +++ b/helm/sim/examples/values-existing-secret.yaml @@ -15,6 +15,8 @@ # Full Secret manifests are at the bottom of this file. # # Install: +# # Examples are not in the chart package: fetch them at the chart's release tag. +# curl -fsSLO "https://raw.githubusercontent.com/simstudioai/sim/helm-chart-${CHART_VERSION}/helm/sim/examples/values-existing-secret.yaml" # helm install sim oci://ghcr.io/simstudioai/charts/sim --version "$CHART_VERSION" \ # --namespace sim --create-namespace \ # --values values-existing-secret.yaml @@ -38,6 +40,13 @@ app: STORAGE_PROVIDER: "s3" AWS_REGION: "us-east-1" # EDIT S3_BUCKET_NAME: "example-sim-workspace-files" # EDIT + # EDIT: these purposes do not fall back to S3_BUCKET_NAME, so each needs a + # bucket (OG images and workspace logos do fall back). + S3_KB_BUCKET_NAME: "example-sim-knowledge-base" + S3_EXECUTION_FILES_BUCKET_NAME: "example-sim-execution-files" + S3_CHAT_BUCKET_NAME: "example-sim-chat-files" + S3_COPILOT_BUCKET_NAME: "example-sim-copilot-files" + S3_PROFILE_PICTURES_BUCKET_NAME: "example-sim-profile-pictures" realtime: enabled: true diff --git a/helm/sim/examples/values-external-db.yaml b/helm/sim/examples/values-external-db.yaml index b83c75f90b0..9d1629e3d54 100644 --- a/helm/sim/examples/values-external-db.yaml +++ b/helm/sim/examples/values-external-db.yaml @@ -18,6 +18,8 @@ # export CRON_SECRET=$(openssl rand -hex 32) # export DB_PASSWORD=$(openssl rand -hex 24) # +# # Examples are not in the chart package: fetch them at the chart's release tag. +# curl -fsSLO "https://raw.githubusercontent.com/simstudioai/sim/helm-chart-${CHART_VERSION}/helm/sim/examples/values-external-db.yaml" # helm install sim oci://ghcr.io/simstudioai/charts/sim --version "$CHART_VERSION" \ # --namespace sim --create-namespace \ # --values values-external-db.yaml \ @@ -61,6 +63,13 @@ app: STORAGE_PROVIDER: "s3" AWS_REGION: "us-east-1" # EDIT S3_BUCKET_NAME: "acme-sim-workspace-files" # EDIT + # EDIT: these purposes do not fall back to S3_BUCKET_NAME, so each needs a + # bucket (OG images and workspace logos do fall back). + S3_KB_BUCKET_NAME: "acme-sim-knowledge-base" + S3_EXECUTION_FILES_BUCKET_NAME: "acme-sim-execution-files" + S3_CHAT_BUCKET_NAME: "acme-sim-chat-files" + S3_COPILOT_BUCKET_NAME: "acme-sim-copilot-files" + S3_PROFILE_PICTURES_BUCKET_NAME: "acme-sim-profile-pictures" # Security settings (REQUIRED - replace with your own secure secrets) # Generate using: openssl rand -hex 32 @@ -189,6 +198,8 @@ networkPolicy: port: 5432 # Example deployment command with secure secret generation: +# # Examples are not in the chart package: fetch them at the chart's release tag. +# curl -fsSLO "https://raw.githubusercontent.com/simstudioai/sim/helm-chart-${CHART_VERSION}/helm/sim/examples/values-external-db.yaml" # helm install sim oci://ghcr.io/simstudioai/charts/sim --version "$CHART_VERSION" \ # --values values-external-db.yaml \ # --set externalDatabase.host="your-db-host.com" \ diff --git a/helm/sim/examples/values-external-secrets.yaml b/helm/sim/examples/values-external-secrets.yaml index 81916200cf8..0202f94372b 100644 --- a/helm/sim/examples/values-external-secrets.yaml +++ b/helm/sim/examples/values-external-secrets.yaml @@ -16,6 +16,8 @@ # externalSecrets.remoteRefs below. # # Install: +# # Examples are not in the chart package: fetch them at the chart's release tag. +# curl -fsSLO "https://raw.githubusercontent.com/simstudioai/sim/helm-chart-${CHART_VERSION}/helm/sim/examples/values-external-secrets.yaml" # helm install sim oci://ghcr.io/simstudioai/charts/sim --version "$CHART_VERSION" \ # --namespace sim --create-namespace \ # --values values-external-secrets.yaml @@ -68,6 +70,13 @@ app: STORAGE_PROVIDER: "s3" AWS_REGION: "us-east-1" # EDIT S3_BUCKET_NAME: "example-sim-workspace-files" # EDIT + # EDIT: these purposes do not fall back to S3_BUCKET_NAME, so each needs a + # bucket (OG images and workspace logos do fall back). + S3_KB_BUCKET_NAME: "example-sim-knowledge-base" + S3_EXECUTION_FILES_BUCKET_NAME: "example-sim-execution-files" + S3_CHAT_BUCKET_NAME: "example-sim-chat-files" + S3_COPILOT_BUCKET_NAME: "example-sim-copilot-files" + S3_PROFILE_PICTURES_BUCKET_NAME: "example-sim-profile-pictures" realtime: enabled: true diff --git a/helm/sim/examples/values-gcp.yaml b/helm/sim/examples/values-gcp.yaml index 6435ccf6aee..9b1834f63ce 100644 --- a/helm/sim/examples/values-gcp.yaml +++ b/helm/sim/examples/values-gcp.yaml @@ -11,6 +11,8 @@ # - (optional) GPU node pool with accelerator labels for Ollama # # Install: +# # Examples are not in the chart package: fetch them at the chart's release tag. +# curl -fsSLO "https://raw.githubusercontent.com/simstudioai/sim/helm-chart-${CHART_VERSION}/helm/sim/examples/values-gcp.yaml" # helm install sim oci://ghcr.io/simstudioai/charts/sim --version "$CHART_VERSION" \ # --namespace sim --create-namespace \ # --values values-gcp.yaml \ diff --git a/helm/sim/examples/values-production.yaml b/helm/sim/examples/values-production.yaml index d10f962f549..f3dc8833a55 100644 --- a/helm/sim/examples/values-production.yaml +++ b/helm/sim/examples/values-production.yaml @@ -12,6 +12,8 @@ # - (recommended) External Secrets Operator — see values-external-secrets.yaml # # Install: +# # Examples are not in the chart package: fetch them at the chart's release tag. +# curl -fsSLO "https://raw.githubusercontent.com/simstudioai/sim/helm-chart-${CHART_VERSION}/helm/sim/examples/values-production.yaml" # helm install sim oci://ghcr.io/simstudioai/charts/sim --version "$CHART_VERSION" \ # --namespace sim --create-namespace \ # --values values-production.yaml \ @@ -56,6 +58,13 @@ app: STORAGE_PROVIDER: "s3" AWS_REGION: "us-east-1" # EDIT S3_BUCKET_NAME: "acme-sim-workspace-files" # EDIT + # EDIT: these purposes do not fall back to S3_BUCKET_NAME, so each needs a + # bucket (OG images and workspace logos do fall back). + S3_KB_BUCKET_NAME: "acme-sim-knowledge-base" + S3_EXECUTION_FILES_BUCKET_NAME: "acme-sim-execution-files" + S3_CHAT_BUCKET_NAME: "acme-sim-chat-files" + S3_COPILOT_BUCKET_NAME: "acme-sim-copilot-files" + S3_PROFILE_PICTURES_BUCKET_NAME: "acme-sim-profile-pictures" # Security settings (REQUIRED - pass with --set or an external secret manager; # the install fails while any is empty). Generate using: openssl rand -hex 32 diff --git a/helm/sim/templates/_helpers.tpl b/helm/sim/templates/_helpers.tpl index d613889ade3..8e3eeb9e47f 100644 --- a/helm/sim/templates/_helpers.tpl +++ b/helm/sim/templates/_helpers.tpl @@ -1028,11 +1028,29 @@ mask it. {{- end }} {{/* -The host the public ingress serves realtime on: ingress.realtime.host, or the app host when empty. -Takes the ingress values (.Values.ingress or .Values.ingressInternal). +The host an ingress serves realtime on: realtime.host, or the app host when it is empty or +sim-ws.local, the placeholder charts before 1.20.0 shipped (a values file copied from one still names +it, and no browser connects there). Takes the ingress values (.Values.ingress or .Values.ingressInternal). */}} {{- define "sim.ingressRealtimeHost" -}} -{{- default .app.host .realtime.host -}} +{{- if or (not .realtime.host) (eq (toString .realtime.host) "sim-ws.local") -}} +{{- .app.host -}} +{{- else -}} +{{- .realtime.host -}} +{{- end -}} +{{- end }} + +{{/* +The realtime ingress paths, as a YAML list. Under the pre-1.20.0 placeholder host the old default +paths ([/ Prefix]) become /socket.io, since that host now resolves to the app host. Takes the +ingress values. +*/}} +{{- define "sim.ingressRealtimePaths" -}} +{{- $paths := .realtime.paths | default list -}} +{{- if and (eq (toString .realtime.host) "sim-ws.local") (eq (len $paths) 1) (eq (toString (index $paths 0).path) "/") (eq (toString (index $paths 0).pathType) "Prefix") -}} +{{- $paths = list (dict "path" "/socket.io" "pathType" "Prefix") -}} +{{- end -}} +{{- toYaml $paths -}} {{- end }} {{/* @@ -1042,7 +1060,7 @@ would route every app request to realtime. Takes (list " ", https when ingress.tls.enabled or NEXT_PUBLIC_APP_URL is https. On the app - # host a "/" path fails the render: it would route every app request to realtime. + # http(s)://, https when ingress.tls.enabled or NEXT_PUBLIC_APP_URL is https (a URL only + # externalSecrets supplies can't be read: with TLS terminated in front of the ingress, set + # NEXT_PUBLIC_SOCKET_URL). In app.secrets.existingSecret mode the chart never derives it, so set + # NEXT_PUBLIC_SOCKET_URL in that Secret (or app.env). On the app host a "/" path fails the render: + # it would route every app request to realtime. The pre-1.20.0 placeholder host sim-ws.local + # counts as the app host, and its old "/" path as /socket.io. realtime: host: "" paths: From 85b5b6a485faef6d1b37d32f8c3b11e7c2158d96 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Fri, 4 Dec 2026 11:22:24 -0600 Subject: [PATCH 3/4] improvement(helm): one env resolver, shared ingress and env templates, and concise upgrade notes --- .github/workflows/helm.yml | 3 +- .../docs/platform/self-hosting/kubernetes.mdx | 23 +- .../docs/platform/self-hosting/networking.mdx | 13 +- .../docs/platform/self-hosting/scaling.mdx | 2 +- .../docs/platform/self-hosting/verify.mdx | 2 +- .../scripts/fixtures/content-baseline.json | 8 +- .../sim-helm/references/values-model.md | 14 +- helm/sim/README.md | 37 +-- .../aws-marketplace-prerequisites.yaml | 35 ++- helm/sim/examples/values-aws-marketplace.yaml | 23 +- helm/sim/examples/values-existing-secret.yaml | 4 +- helm/sim/examples/values-external-db.yaml | 6 +- .../sim/examples/values-external-secrets.yaml | 3 +- helm/sim/examples/values-production.yaml | 6 +- helm/sim/templates/NOTES.txt | 16 +- helm/sim/templates/_helpers.tpl | 283 ++++++------------ helm/sim/templates/_ingress.tpl | 142 +++++++++ helm/sim/templates/deployment-app.yaml | 4 +- helm/sim/templates/deployment-realtime.yaml | 47 +-- helm/sim/templates/ingress-internal.yaml | 132 +------- helm/sim/templates/ingress.yaml | 132 +------- helm/sim/tests/env-defaults_test.yaml | 129 ++------ helm/sim/tests/ingress-realtime_test.yaml | 17 +- helm/sim/tests/storage_test.yaml | 2 +- helm/sim/tests/validators_test.yaml | 2 +- .../tests/values/historical-env-defaults.yaml | 62 ---- helm/sim/values.yaml | 41 +-- 27 files changed, 409 insertions(+), 779 deletions(-) create mode 100644 helm/sim/templates/_ingress.tpl delete mode 100644 helm/sim/tests/values/historical-env-defaults.yaml diff --git a/.github/workflows/helm.yml b/.github/workflows/helm.yml index 4e49d960635..06fefc3133f 100644 --- a/.github/workflows/helm.yml +++ b/.github/workflows/helm.yml @@ -196,7 +196,8 @@ jobs: # a label that moves with the chart version there breaks every upgrade of # the bundled Postgres while fresh installs keep passing. Install the newest # published chart in its own namespace, then upgrade it to this checkout - # with the same values. + # with the same values, so ci/default-values.yaml and ci/kind-overlay.yaml + # must stay valid for the previous published chart too. - name: Upgrade from the published chart run: | set -euo pipefail diff --git a/apps/docs/content/docs/platform/self-hosting/kubernetes.mdx b/apps/docs/content/docs/platform/self-hosting/kubernetes.mdx index 142cc2da857..d2d40d5da3c 100644 --- a/apps/docs/content/docs/platform/self-hosting/kubernetes.mdx +++ b/apps/docs/content/docs/platform/self-hosting/kubernetes.mdx @@ -88,7 +88,7 @@ Open [http://localhost:3000](http://localhost:3000). For public access, complete ## Public access [#key-configuration] -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: +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: ```yaml app: @@ -96,14 +96,10 @@ app: tag: "v0.9.72" env: NEXT_PUBLIC_APP_URL: "https://sim.yourdomain.com" - BETTER_AUTH_URL: "https://sim.yourdomain.com" - NEXT_PUBLIC_SOCKET_URL: "https://sim.yourdomain.com" realtime: image: tag: "v0.9.72" - env: - ALLOWED_ORIGINS: "https://sim.yourdomain.com" migrations: image: @@ -120,17 +116,12 @@ ingress: nginx.ingress.kubernetes.io/force-ssl-redirect: null app: host: sim.yourdomain.com - realtime: - host: sim.yourdomain.com - paths: - - path: /socket.io - pathType: Prefix tls: enabled: true secretName: sim-tls ``` -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. +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. Create `sim-tls` in `simstudio` from your certificate and private key, or configure your certificate manager to populate that Secret: @@ -141,12 +132,9 @@ kubectl create secret tls sim-tls -n simstudio \ 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. -For a separate realtime hostname, change all three fields together: +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): ```yaml -app: - env: - NEXT_PUBLIC_SOCKET_URL: "https://sim-ws.yourdomain.com" ingress: realtime: host: sim-ws.yourdomain.com @@ -155,7 +143,7 @@ ingress: pathType: Prefix ``` -Keep `ALLOWED_ORIGINS` set to the app origin, and use a TLS certificate covering both hosts. App/auth URLs remain on `sim.yourdomain.com`. +Use a TLS certificate covering both hosts. App/auth URLs remain on `sim.yourdomain.com`. 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. @@ -238,8 +226,7 @@ Configure model provider keys, such as `OPENAI_API_KEY`, through the same select Use a cloud example as a starting file, not a complete install configuration. Fetch it from the release corresponding to the pinned chart example: ```bash -SIM_RELEASE=v0.9.72 -curl -fsSLO "https://raw.githubusercontent.com/simstudioai/sim/$SIM_RELEASE/helm/sim/examples/values-aws.yaml" +curl -fsSLO "https://raw.githubusercontent.com/simstudioai/sim/helm-chart-${CHART_VERSION}/helm/sim/examples/values-aws.yaml" ``` 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: diff --git a/apps/docs/content/docs/platform/self-hosting/networking.mdx b/apps/docs/content/docs/platform/self-hosting/networking.mdx index 19c953b1641..229351f23bf 100644 --- a/apps/docs/content/docs/platform/self-hosting/networking.mdx +++ b/apps/docs/content/docs/platform/self-hosting/networking.mdx @@ -22,33 +22,28 @@ sim.yourdomain.com/ → app:3000 sim.yourdomain.com/socket.io → realtime:3002 ``` -`NEXT_PUBLIC_SOCKET_URL` can be left unset — the client defaults to the page origin. +`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. -Use separate hostnames when your ingress setup cannot split paths across backends. GKE's example values use this layout. +Optionally, use separate hostnames when your ingress setup cannot split paths across backends. GKE's example values use this layout. ``` sim.yourdomain.com → app:3000 sim-ws.yourdomain.com → realtime:3002 ``` -Then tell the client where realtime lives, and tell realtime which origins to accept: +Then tell the client where realtime lives: ```yaml app: env: NEXT_PUBLIC_APP_URL: "https://sim.yourdomain.com" - BETTER_AUTH_URL: "https://sim.yourdomain.com" NEXT_PUBLIC_SOCKET_URL: "https://sim-ws.yourdomain.com" - -realtime: - env: - ALLOWED_ORIGINS: "https://sim.yourdomain.com" ``` -`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. +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. Both hostnames need DNS records and TLS certificates. diff --git a/apps/docs/content/docs/platform/self-hosting/scaling.mdx b/apps/docs/content/docs/platform/self-hosting/scaling.mdx index 0b98104a6f6..ae04fbfe7ea 100644 --- a/apps/docs/content/docs/platform/self-hosting/scaling.mdx +++ b/apps/docs/content/docs/platform/self-hosting/scaling.mdx @@ -39,7 +39,7 @@ app: cpu: 1000m ``` -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. +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. 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. diff --git a/apps/docs/content/docs/platform/self-hosting/verify.mdx b/apps/docs/content/docs/platform/self-hosting/verify.mdx index a649427f341..0f1ca56b6fb 100644 --- a/apps/docs/content/docs/platform/self-hosting/verify.mdx +++ b/apps/docs/content/docs/platform/self-hosting/verify.mdx @@ -107,7 +107,7 @@ Expect `simstudio`, `realtime`, `db`, `redis`, and `cron` to be running, with `m | --- | --- | | 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. | | 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`. | -| 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`. | +| 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`. | | Edits do not propagate | Realtime connectivity and Redis on every replica; verify which pods hold the connections. | | 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. | | Cloud upload fails | Bucket CORS for the Sim origin and signed headers; server permissions to complete multipart uploads. S3 completion needs `s3:ListMultipartUploadParts`. | diff --git a/apps/docs/scripts/fixtures/content-baseline.json b/apps/docs/scripts/fixtures/content-baseline.json index 89a18efcee8..d8140275676 100644 --- a/apps/docs/scripts/fixtures/content-baseline.json +++ b/apps/docs/scripts/fixtures/content-baseline.json @@ -173934,7 +173934,7 @@ { "lang": "yaml", "meta": null, - "sha256": "795844d38101f8147ddbc9228260ac3079e0ab89a452246656ac336c74f131ce", + "sha256": "ca65367d373ed281d6a04c4677304bffbbc0c590d97d958f02404d65476790bd", "bytes": 701, "line": 85 }, @@ -173948,7 +173948,7 @@ { "lang": "yaml", "meta": null, - "sha256": "df68603f8a69b1564ae8792b1bf46bead93f1635ad2cf6aba1b0e53e250f2276", + "sha256": "b9ce9aab8d379f8e9173ab0d3fff2feaee5253bd26c6db477e96e984e9925970", "bytes": 176, "line": 138 }, @@ -173976,7 +173976,7 @@ { "lang": "bash", "meta": null, - "sha256": "d829002daa160ca953fad98f7df3af21515ccbd34feb96e5fa8f4d5d6c314278", + "sha256": "c970c43eea56151320bf4b5baa8118312be6dbfcf47eff7caf2210731151e359", "bytes": 130, "line": 232 }, @@ -174233,7 +174233,7 @@ { "lang": "yaml", "meta": null, - "sha256": "770a221e2ed89426cca37de3d61fce8a5d99e1f0cf5db0c5fe4586473de3ed0d", + "sha256": "ad130fab18b02e1e22b7229ed4d14696a5abb404e383e9738e0b2bcf4d004d47", "bytes": 243, "line": 35 }, diff --git a/helm/sim/.claude/skills/sim-helm/references/values-model.md b/helm/sim/.claude/skills/sim-helm/references/values-model.md index 1384c598121..820bd5bb2ab 100644 --- a/helm/sim/.claude/skills/sim-helm/references/values-model.md +++ b/helm/sim/.claude/skills/sim-helm/references/values-model.md @@ -18,7 +18,8 @@ The Sim chart splits configuration across **four** layers. Understanding which l ┌───────────────────────────────────────────────────────────────────────────┐ │ Layer 2: app.envDefaults / realtime.envDefaults │ │ → Rendered as inline env: on the Deployment │ -│ → SKIPPED for any key already set in app.env (or realtime.env) │ +│ → SKIPPED for any key already set in app.env (or realtime.env), or │ +│ mapped in externalSecrets.remoteRefs.app; none in existingSecret mode │ │ → Use for: operational tunables and safe fallback defaults │ │ → Examples: NODE_ENV=production, RATE_LIMIT_*, IVM_* │ └───────────────────────────────────────────────────────────────────────────┘ @@ -27,7 +28,9 @@ The Sim chart splits configuration across **four** layers. Understanding which l ▼ ┌───────────────────────────────────────────────────────────────────────────┐ │ Layer 3: chart-computed (inline env: on the Deployment) │ -│ → DATABASE_URL, SOCKET_SERVER_URL, OLLAMA_URL, PII_URL │ +│ → DATABASE_URL, SOCKET_SERVER_URL, OLLAMA_URL, PII_URL │ +│ → BETTER_AUTH_URL=$(NEXT_PUBLIC_APP_URL) and NEXT_PUBLIC_SOCKET_URL │ +│ (separate realtime ingress host), only when you set them nowhere │ │ → Derived from postgresql.* / externalDatabase.* / service.* values │ │ → CANNOT be overridden via app.env — chart filters them out │ └───────────────────────────────────────────────────────────────────────────┘ @@ -46,7 +49,7 @@ The Sim chart splits configuration across **four** layers. Understanding which l **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.` or it's silently missing. Layers 2–4 are unaffected by ESO. -**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). +**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). ## Where keys live — the canonical list @@ -56,7 +59,7 @@ The exhaustive list of keys per layer lives in `helm/sim/values.yaml`. Read the |---|---|---| | Auth secrets | 1 (app.env) | `BETTER_AUTH_SECRET`, `ENCRYPTION_KEY`, `INTERNAL_API_SECRET`, `CRON_SECRET`, `API_ENCRYPTION_KEY` | | Provider API keys | 1 (app.env) | `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, `GOOGLE_CLIENT_SECRET`, etc. | -| Per-environment URLs | 1 (app.env) | `NEXT_PUBLIC_APP_URL`, `BETTER_AUTH_URL`, `NEXT_PUBLIC_SOCKET_URL` | +| 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) | | Feature flags | 1 (app.env) | `ENTERPRISE_ENABLED`, `ACCESS_CONTROL_ENABLED`, `ORGANIZATIONS_ENABLED`, `SSO_ENABLED` (server only; enterprise features have no `NEXT_PUBLIC_` twins) | | Operational defaults | 2 (envDefaults) | `NODE_ENV=production`, `EMAIL_VERIFICATION_ENABLED=false`, `VERTEX_LOCATION=us-central1` | | 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 app: env: NEXT_PUBLIC_APP_URL: "https://sim.example.com" - BETTER_AUTH_URL: "https://sim.example.com" ``` -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. +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. ### "I want to inject a value from another ConfigMap" diff --git a/helm/sim/README.md b/helm/sim/README.md index 64ae023007a..7d7cfdd3385 100644 --- a/helm/sim/README.md +++ b/helm/sim/README.md @@ -310,9 +310,8 @@ Pre-built values files for common scenarios live in [`helm/sim/examples/`](https Use one with: ```bash -# The Sim release your chart version installs, so the example matches it -SIM_RELEASE=$(helm show chart oci://ghcr.io/simstudioai/charts/sim --version "$CHART_VERSION" | awk '/^appVersion:/ {print $2}' | tr -d '"') -curl -fsSLO "https://raw.githubusercontent.com/simstudioai/sim/$SIM_RELEASE/helm/sim/examples/values-production.yaml" +# The example as of your chart version's release tag +curl -fsSLO "https://raw.githubusercontent.com/simstudioai/sim/helm-chart-${CHART_VERSION}/helm/sim/examples/values-production.yaml" helm install sim oci://ghcr.io/simstudioai/charts/sim \ --version "$CHART_VERSION" \ @@ -358,7 +357,7 @@ or extract it from a pulled chart with `helm pull --untar`. Before installing in production, confirm each of the following: -* **High availability** — scale `app.replicaCount > 1`. The chart auto-creates a `PodDisruptionBudget` with `maxUnavailable: "25%"`. Set `podDisruptionBudget.minAvailable` instead for a stricter policy. +* **High availability** — scale `app.replicaCount > 1`, which needs object storage (S3, Azure Blob, or GCS; see `STORAGE_PROVIDER`) or the `app.storage.allowLocalWithReplicas` opt-out. The chart auto-creates a `PodDisruptionBudget` with `maxUnavailable: "25%"`. Set `podDisruptionBudget.minAvailable` instead for a stricter policy. * **Pinned images** — override `image.tag` (or `image.digest`) with an explicit version. Do not rely on the chart's default tag in production. * **Secrets management** — provide secrets via External Secrets Operator (ESO) or pre-created Kubernetes Secrets. Never commit secrets to `values.yaml`. * **TLS / Ingress** — set the `cert-manager.io/cluster-issuer` annotation on the ingress and tune `proxy-body-size` / `proxy-read-timeout` for your workload. See commented examples in `values.yaml`. @@ -391,7 +390,7 @@ Before installing in production, confirm each of the following: ``` * **Namespace hardening** — label the install namespace with Pod Security Standards `restricted` enforcement (`pod-security.kubernetes.io/enforce=restricted`). All workloads set `runAsNonRoot`, drop all Linux capabilities, disable privilege escalation, and set `seccompProfile: RuntimeDefault` — the four controls the Restricted profile requires. `readOnlyRootFilesystem` is defaulted on only for the bundled Redis (Postgres/Ollama genuinely need a writable root; the stateless services — `realtime`, `pii`, `copilot` — could tolerate it but aren't pre-wired with a `/tmp` `emptyDir`). If your policy requires it, set `.securityContext.readOnlyRootFilesystem: true` and mount writable `emptyDir` volumes yourself via `extraVolumes`/`extraVolumeMounts`: `/tmp` for every component, plus `/app/apps/sim/.next/cache` and `/app/apps/sim/.next/server/route-cache` for `app`. * **Env validation** — keys under `app.env`, `realtime.env`, and `copilot.server.env` are passed through to the application and validated at startup. The JSON Schema intentionally does not enforce `additionalProperties: false` (would break custom user envs), so typos like `OPENA_API_KEY` (instead of `OPENAI_API_KEY`) surface as missing-key errors at runtime, not at `helm install` time. Review your env block carefully. -* **Set public URLs** — `app.env.NEXT_PUBLIC_APP_URL` and `app.env.BETTER_AUTH_URL` must match your public origin (e.g. `https://sim.example.com`). Leaving them as `localhost` breaks sign-in. +* **Set public URLs** — `app.env.NEXT_PUBLIC_APP_URL` must match your public origin (e.g. `https://sim.example.com`); `BETTER_AUTH_URL` follows it (in `app.secrets.existingSecret` mode set both in the Secret). Leaving it as `localhost` breaks sign-in. --- @@ -500,7 +499,7 @@ User-supplied `securityContext` values are merged with the defaults — your val Other security features: * `automountServiceAccountToken: false` on the ServiceAccount **and** every pod. -* Every value in `app.env` and `realtime.env` is written to a chart-managed Secret and mounted via `envFrom: secretRef` — no values are inlined on the container spec. This eliminates a sensitivity classifier (no static list of "secret" keys to maintain) and ensures new provider keys can never accidentally leak into pod manifests. Two categories are inlined on the container instead: chart-computed values (`DATABASE_URL`, `SOCKET_SERVER_URL`, `OLLAMA_URL`, `PII_URL`) and operational defaults under `app.envDefaults` / `realtime.envDefaults` (rate limits, timeouts, IVM tunables, feature-flag defaults, the `http://localhost:3000` `NEXT_PUBLIC_APP_URL` fallback). Operational defaults are non-sensitive by design — moving them out of `app.env` keeps the Secret small and means External Secrets Operator users only have to map the keys they actually set, not every chart default. A **non-empty** value placed in `app.env` wins over the same key in `app.envDefaults` (the template skips the inline default when an override exists). An **empty** value does not — to remove a key rather than change it, see [Removing an inherited env key](#removing-an-inherited-env-key). Likewise, under External Secrets a key mapped in `externalSecrets.remoteRefs.app` wins, and in `app.secrets.existingSecret` mode only the `envDefaults` values you changed from the chart's defaults are inlined. +* Every value in `app.env` and `realtime.env` is written to a chart-managed Secret and mounted via `envFrom: secretRef` — no values are inlined on the container spec. This eliminates a sensitivity classifier (no static list of "secret" keys to maintain) and ensures new provider keys can never accidentally leak into pod manifests. Two categories are inlined on the container instead: chart-computed values (`DATABASE_URL`, `SOCKET_SERVER_URL`, `OLLAMA_URL`, `PII_URL`, `BETTER_AUTH_URL` from `NEXT_PUBLIC_APP_URL`, and `NEXT_PUBLIC_SOCKET_URL` for a separate realtime ingress host, each only when you have not set it) and operational defaults under `app.envDefaults` / `realtime.envDefaults` (rate limits, timeouts, IVM tunables, feature-flag defaults, the `http://localhost:3000` `NEXT_PUBLIC_APP_URL` fallback). Operational defaults are non-sensitive by design — moving them out of `app.env` keeps the Secret small and means External Secrets Operator users only have to map the keys they actually set, not every chart default. A **non-empty** value placed in `app.env` wins over the same key in `app.envDefaults` (the template skips the inline default when an override exists). An **empty** value does not — to remove a key rather than change it, see [Removing an inherited env key](#removing-an-inherited-env-key). Likewise, under External Secrets a key mapped in `externalSecrets.remoteRefs.app` wins, and in `app.secrets.existingSecret` mode no `envDefaults` are inlined (put overrides in `app.env`). * Optional `networkPolicy.enabled=true` enforces east-west isolation and blocks cloud metadata endpoints in egress. --- @@ -646,28 +645,20 @@ kubectl --namespace sim logs deploy/sim-app -c migrations ## Upgrading to 1.20.0 -* **Bundled Postgres upgrades work again.** Kubernetes forbids any change to a StatefulSet's `volumeClaimTemplates`, and the chart used to put its version labels on them, so every chart or appVersion bump failed `helm upgrade` with `spec: Forbidden: updates to statefulset spec for fields other than ...`. The `postgresql` and `copilot-postgresql` StatefulSets now keep the claim template labels they already have (read with `lookup`) and give new installs only labels that never change. `helm upgrade` needs no action, including a release stuck on that error, and neither does Flux (its helm-controller runs a real install or upgrade, so `lookup` works). **Argo CD and `helm template | kubectl apply` users**, where `lookup` returns nothing, get the new labels on a StatefulSet that has the old ones, so once, before upgrading, delete the StatefulSets without touching their pods or volumes: +Covers 1.19.0–1.20.0; 1.18.0 is the previous published chart. This release refuses some values earlier charts accepted; run `helm template` with your values before upgrading. + +* **Argo CD or `helm template | kubectl apply`: recreate the bundled Postgres StatefulSets once.** Their volume claim labels no longer carry the chart version (Kubernetes forbids changing them, which broke every upgrade). `helm upgrade` and Flux reuse the existing labels and need nothing; tools that render without `lookup` must orphan-delete first, which keeps the pods and PVCs: ```bash kubectl --namespace sim delete statefulset -postgresql --cascade=orphan kubectl --namespace sim delete statefulset -copilot-postgresql --cascade=orphan # only with copilot.postgresql.enabled ``` - - The upgrade recreates them, and they adopt the running pods and existing PVCs. -* **Realtime is routed on the app host by default.** `ingress.realtime.host` now defaults to `""`, meaning `ingress.app.host`, and `ingress.realtime.paths` to `/socket.io`, which is where browsers connect when `NEXT_PUBLIC_SOCKET_URL` is empty. The old default (`sim-ws.local` with `/`) left realtime unreachable unless you also set `NEXT_PUBLIC_SOCKET_URL`. If you set a separate `ingress.realtime.host`, it keeps working, and when `NEXT_PUBLIC_SOCKET_URL` is set nowhere (`app.env`, `app.envDefaults`, `extraEnvVars`, `externalSecrets.remoteRefs.app`) the app now gets `http(s)://` (https when `ingress.tls.enabled` or the `NEXT_PUBLIC_APP_URL` from `app.env`, `app.envDefaults` or `extraEnvVars` is https, as behind a TLS-terminating load balancer). If you relied on the old default paths while setting only the host, realtime on that host is now served under `/socket.io`, the only path the Socket.IO client uses. Sharing the app host with a realtime path of `/` now fails the render, because that rule sends every app request to realtime. A values file copied from an older chart that still names the old placeholder (`host: sim-ws.local`, path `/`) is treated as the new default: realtime on the app host under `/socket.io`. The derived URL can't read a `NEXT_PUBLIC_APP_URL` that only External Secrets supplies, so with TLS terminated in front of the ingress (and `ingress.tls.enabled=false`) set `NEXT_PUBLIC_SOCKET_URL` yourself; in `app.secrets.existingSecret` mode the chart never derives it, so keep it in the Secret. -* **`BETTER_AUTH_URL` follows `NEXT_PUBLIC_APP_URL`.** It is no longer an `envDefaults` key fixed at `http://localhost:3000`; unless you set it (`app.env`, `realtime.env`, `envDefaults`, `extraEnvVars`, or `externalSecrets.remoteRefs.app`), the app and realtime pods get `$(NEXT_PUBLIC_APP_URL)`. In `app.secrets.existingSecret` mode the chart cannot see your Secret, so it sets nothing: keep `BETTER_AUTH_URL` in the Secret or in `app.env`. -* **External Secrets: a synced key is no longer masked by an `envDefaults` value.** A key mapped in `externalSecrets.remoteRefs.app` (for example `NEXT_PUBLIC_APP_URL`) used to be overridden by the inline `envDefaults` value; the chart now skips that default. -* **existingSecret mode applies the `envDefaults` you change.** Previously every `envDefaults` value was dropped in this mode, including ones you set. Now a value that differs from the chart's default is inlined; one still at the chart's default is not, so it never masks a key your Secret holds. -* **Object storage is required for more than one app replica.** With no object store configured (S3: `AWS_REGION` + `S3_BUCKET_NAME`; Azure Blob: `AZURE_STORAGE_CONTAINER_NAME` + `AZURE_CONNECTION_STRING` or `AZURE_ACCOUNT_NAME` + `AZURE_ACCOUNT_KEY`; GCS: `GCS_BUCKET_NAME`; in `app.env`, `app.envDefaults`, `extraEnvVars`, or `externalSecrets.remoteRefs.app`), uploads go to each pod's own filesystem. With `app.replicaCount > 1` or `autoscaling.enabled`, the render now fails, on install and upgrade alike (Argo CD renders with `helm template`, which cannot tell them apart). Fix it by configuring object storage, by mounting a shared (ReadWriteMany) volume at `/app/apps/sim/uploads` (`app.extraVolumes` / `app.extraVolumeMounts`), or by setting `app.storage.allowLocalWithReplicas=true` to accept that uploads stay on the pod that received them and are lost when it restarts. A single replica on local storage only prints a warning. `app.secrets.existingSecret` mode is trusted, since the chart cannot read the Secret. -* **New render-time checks.** An enabled `existingSecret` with an empty `name` (`app.secrets`, `postgresql.auth`, `externalDatabase`) now fails, as does enabling both `postgresql` and `externalDatabase`: the chart used the bundled database in that case, so set `externalDatabase.enabled=false` to keep it, or migrate your data and set `postgresql.enabled=false`. - -## Upgrading to 1.19.0 - -* **New default-on CronJob `cronjobs.jobs.cleanupCredentialGroupLinks`** (hourly, `/api/cron/cleanup-credential-group-links`). Its route ships with the next app release, so with an older Sim image it fails until you upgrade the app; set `cronjobs.jobs.cleanupCredentialGroupLinks.enabled=false` until then if you want quiet job history. - -## Upgrading to 1.17.0 and 1.18.0 - -* **Opt-in Kubernetes sandbox provider.** 1.17 adds `sandbox.kubernetes` (Function and workflow sandboxes as pods in a dedicated namespace, no third-party service) and 1.18 adds `sandbox.kubernetes.warmCapacity`. Both are off by default; installs that do not enable them need no action. +* **More than one app replica needs object storage.** With `app.replicaCount > 1` or `autoscaling.enabled` and no S3, Azure Blob, or GCS configured, the render fails. Configure one in `app.env` (see `STORAGE_PROVIDER`), mount a ReadWriteMany volume at `/app/apps/sim/uploads`, or set `app.storage.allowLocalWithReplicas=true`. +* **Realtime is served on the app host under `/socket.io`.** `ingress.realtime.host` defaults to `""` (the app host). A separate host keeps working, and the chart sets `NEXT_PUBLIC_SOCKET_URL` to it unless you do (set it yourself in `app.secrets.existingSecret` mode). A `/` realtime path on the app host now fails the render; a copied `sim-ws.local` block is read as the new default. +* **`BETTER_AUTH_URL` defaults to `NEXT_PUBLIC_APP_URL`.** Delete a copied `app.envDefaults.BETTER_AUTH_URL: http://localhost:3000`. In `app.secrets.existingSecret` mode, keep `BETTER_AUTH_URL` in the Secret. +* **External Secrets: synced keys win over `envDefaults`.** A key mapped in `externalSecrets.remoteRefs.app` is no longer masked by the chart default. No action. +* **existingSecret mode applies no `envDefaults`.** Put overrides in `app.env`, which is inlined in that mode. +* **New render checks.** An enabled `existingSecret` with an empty `name` (`app.secrets`, `postgresql.auth`, `externalDatabase`) fails, as does enabling both `postgresql` and `externalDatabase`. ## Upgrading to 1.16.0 diff --git a/helm/sim/examples/aws-marketplace-prerequisites.yaml b/helm/sim/examples/aws-marketplace-prerequisites.yaml index 12aa148a415..bbd4a387671 100644 --- a/helm/sim/examples/aws-marketplace-prerequisites.yaml +++ b/helm/sim/examples/aws-marketplace-prerequisites.yaml @@ -2,7 +2,8 @@ AWSTemplateFormatVersion: '2010-09-09' Description: >- Prerequisites for Sim from the AWS Marketplace container listing: Amazon RDS for PostgreSQL 17 (pgvector), Amazon ElastiCache (Valkey) with TLS and an auth token, and the IAM role the Sim - ServiceAccount assumes (IRSA) to check the Marketplace license in AWS License Manager. Deploy it + ServiceAccount assumes (IRSA) to check the Marketplace license in AWS License Manager and, with + UploadBucketPrefix, to use your S3 upload buckets. Deploy it in the region and VPC of your EKS cluster, then use its outputs in values.yaml and the two Kubernetes Secrets described in the listing's usage instructions. @@ -36,6 +37,17 @@ Parameters: Type: String Default: cache.m7g.large Description: ElastiCache node type. + UploadBucketPrefix: + Type: String + Default: '' + AllowedPattern: '^$|^[a-z0-9][a-z0-9.-]{0,40}$' + Description: >- + Name prefix of the S3 buckets you create for uploads (e.g. "sim" for sim-workspace-files, + sim-knowledge-base, ...). The license role is then granted read, write and multipart access + to -* buckets. Empty grants no S3 access. + +Conditions: + GrantUploadBuckets: !Not [!Equals [!Ref UploadBucketPrefix, '']] Resources: DatabaseSecurityGroup: @@ -132,7 +144,7 @@ Resources: LicenseRole: Type: AWS::IAM::Role Properties: - Description: Lets the Sim ServiceAccount check the AWS Marketplace license (IRSA) + Description: Lets the Sim ServiceAccount check the AWS Marketplace license and use its upload buckets (IRSA) # Substituted as a whole document: the condition keys embed the cluster's issuer. AssumeRolePolicyDocument: !Sub | { @@ -164,6 +176,25 @@ Resources: # resource-level permissions, so it cannot be scoped below '*'. Action: license-manager:CheckoutLicense Resource: '*' + - !If + - GrantUploadBuckets + - PolicyName: sim-upload-buckets + PolicyDocument: + Version: '2012-10-17' + Statement: + - Effect: Allow + Action: s3:ListBucket + Resource: !Sub 'arn:${AWS::Partition}:s3:::${UploadBucketPrefix}-*' + # Large uploads are multipart: Sim aborts and lists the parts of its own uploads. + - Effect: Allow + Action: + - s3:GetObject + - s3:PutObject + - s3:DeleteObject + - s3:AbortMultipartUpload + - s3:ListMultipartUploadParts + Resource: !Sub 'arn:${AWS::Partition}:s3:::${UploadBucketPrefix}-*/*' + - !Ref AWS::NoValue Outputs: DatabaseEndpoint: diff --git a/helm/sim/examples/values-aws-marketplace.yaml b/helm/sim/examples/values-aws-marketplace.yaml index 17049172fd7..dd1e15eda24 100644 --- a/helm/sim/examples/values-aws-marketplace.yaml +++ b/helm/sim/examples/values-aws-marketplace.yaml @@ -21,12 +21,17 @@ # provider (for IRSA). # 2. RDS for PostgreSQL 17 and ElastiCache reachable from the cluster. The listing's # CloudFormation template creates both in your VPC. -# 3. An IAM role for the ServiceAccount below that allows license-manager:CheckoutLicense (the -# CloudFormation template creates it; AWS's managed AWSLicenseManagerConsumptionPolicy -# grants it too). License Manager must be set up in the account: open its console once, or run +# 3. An IAM role for the ServiceAccount below that allows license-manager:CheckoutLicense and +# the S3 actions on the upload buckets listed under app.env (the CloudFormation template +# creates it; set its UploadBucketPrefix parameter, e.g. "sim", to grant the S3 actions on +# -* buckets). License Manager must be set up in the account: open its console once, +# or run # aws iam create-service-linked-role --aws-service-name license-manager.amazonaws.com -# 4. An ACM certificate for the two hostnames below. -# 5. Two Secrets in the install namespace (no secret ever goes in this file). The template's +# 4. S3 buckets for uploads, in the region set below: one per name under app.env +# (S3_BUCKET_NAME and the S3_*_BUCKET_NAME purpose buckets), e.g. +# aws s3 mb s3://sim-workspace-files --region us-east-1 +# 5. An ACM certificate for the two hostnames below. +# 6. Two Secrets in the install namespace (no secret ever goes in this file). The template's # DatabasePasswordArn and CacheAuthTokenArn outputs are the ARNs of the Secrets Manager # secrets holding the two passwords; read each password with: # aws secretsmanager get-secret-value --secret-id --query SecretString --output text @@ -56,10 +61,10 @@ app: # The listing's product ID, which the Marketplace chart sets; rendered from this repository, # set it to the product ID shown on the listing. Its presence turns on the License Manager check. AWS_MARKETPLACE_LICENSE_PRODUCT_SKU: "prod-xxxxxxxxxxxxx" # EDIT - # Object storage for uploads (REQUIRED with more than one app replica: local storage is per - # pod). The IRSA role below also needs s3:GetObject, s3:PutObject, s3:DeleteObject, - # s3:ListBucket, s3:AbortMultipartUpload and s3:ListMultipartUploadParts on every bucket (large - # uploads are multipart), or add AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY to sim-app-secrets. + # Object storage (required with more than one app replica; prerequisites 3 and 4). The IRSA + # role needs s3:ListBucket on each bucket and s3:GetObject, s3:PutObject, s3:DeleteObject, + # s3:AbortMultipartUpload and s3:ListMultipartUploadParts on its objects (large uploads are + # multipart), or add AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY to sim-app-secrets. STORAGE_PROVIDER: "s3" AWS_REGION: "us-east-1" # EDIT: the bucket's region S3_BUCKET_NAME: "sim-workspace-files" # EDIT diff --git a/helm/sim/examples/values-existing-secret.yaml b/helm/sim/examples/values-existing-secret.yaml index fdea468b634..e9eea58fd38 100644 --- a/helm/sim/examples/values-existing-secret.yaml +++ b/helm/sim/examples/values-existing-secret.yaml @@ -32,9 +32,7 @@ app: NEXT_PUBLIC_APP_URL: "https://sim.example.com" BETTER_AUTH_URL: "https://sim.example.com" NODE_ENV: "production" - # Object storage (REQUIRED with more than one app replica: local storage is - # per pod). S3 shown; Azure Blob and GCS keys are listed in values.yaml. The - # chart cannot read your Secret, so it does not check these: put them here + # Object storage (required with more than one app replica). Put these here # or in the Secret, with AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY in the # Secret unless the pod has a cloud identity (IRSA, Workload Identity). STORAGE_PROVIDER: "s3" diff --git a/helm/sim/examples/values-external-db.yaml b/helm/sim/examples/values-external-db.yaml index 9d1629e3d54..21ee5e83ff7 100644 --- a/helm/sim/examples/values-external-db.yaml +++ b/helm/sim/examples/values-external-db.yaml @@ -53,11 +53,9 @@ app: env: NEXT_PUBLIC_APP_URL: "https://simstudio.acme.com" BETTER_AUTH_URL: "https://simstudio.acme.com" - # Realtime is served on the app host under /socket.io (ingress below), so - # NEXT_PUBLIC_SOCKET_URL stays unset and browsers use the page origin. + # Realtime is served on the app host under /socket.io; leave NEXT_PUBLIC_SOCKET_URL unset. - # Object storage (REQUIRED with more than one app replica: local storage is - # per pod). S3 shown; Azure Blob and GCS keys are listed in values.yaml. + # Object storage (required with more than one app replica). # Credentials: AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY here, or a pod # identity (IRSA / EKS Pod Identity) via serviceAccount.annotations. STORAGE_PROVIDER: "s3" diff --git a/helm/sim/examples/values-external-secrets.yaml b/helm/sim/examples/values-external-secrets.yaml index 0202f94372b..5874e4e9714 100644 --- a/helm/sim/examples/values-external-secrets.yaml +++ b/helm/sim/examples/values-external-secrets.yaml @@ -65,8 +65,7 @@ app: NEXT_PUBLIC_APP_URL: "https://sim.example.com" BETTER_AUTH_URL: "https://sim.example.com" NODE_ENV: "production" - # Object storage (REQUIRED with more than one app replica: local storage is - # per pod). S3 shown; Azure Blob and GCS keys are listed in values.yaml. + # Object storage (required with more than one app replica). STORAGE_PROVIDER: "s3" AWS_REGION: "us-east-1" # EDIT S3_BUCKET_NAME: "example-sim-workspace-files" # EDIT diff --git a/helm/sim/examples/values-production.yaml b/helm/sim/examples/values-production.yaml index f3dc8833a55..77fc7dfceca 100644 --- a/helm/sim/examples/values-production.yaml +++ b/helm/sim/examples/values-production.yaml @@ -48,11 +48,9 @@ app: env: NEXT_PUBLIC_APP_URL: "https://sim.acme.ai" BETTER_AUTH_URL: "https://sim.acme.ai" - # Realtime is served on the app host under /socket.io (ingress below), so - # NEXT_PUBLIC_SOCKET_URL stays unset and browsers use the page origin. + # Realtime is served on the app host under /socket.io; leave NEXT_PUBLIC_SOCKET_URL unset. - # Object storage (REQUIRED with more than one app replica: local storage is - # per pod). S3 shown; Azure Blob and GCS keys are listed in values.yaml. + # Object storage (required with more than one app replica). # Credentials: AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY here, or a pod # identity (IRSA / EKS Pod Identity) via serviceAccount.annotations. STORAGE_PROVIDER: "s3" diff --git a/helm/sim/templates/NOTES.txt b/helm/sim/templates/NOTES.txt index 34a2d401d45..073e99de317 100644 --- a/helm/sim/templates/NOTES.txt +++ b/helm/sim/templates/NOTES.txt @@ -8,10 +8,9 @@ Thank you for installing {{ .Chart.Name }} ({{ .Chart.Name }}-{{ .Chart.Version Your release is named {{ .Release.Name }} in namespace {{ .Release.Namespace }}. {{- if include "sim.localStorageInUse" . }} -WARNING: no object storage is configured, so uploads are written to each app -pod's own filesystem: they are lost when the pod restarts and are not shared -between replicas. Configure S3 (AWS_REGION + S3_BUCKET_NAME), Azure Blob, or -GCS (GCS_BUCKET_NAME) in app.env; see STORAGE_PROVIDER in values.yaml. +WARNING: no object storage is configured, so uploads stay on each app pod and +are lost when it restarts. Configure S3, Azure Blob, or GCS (see +STORAGE_PROVIDER in values.yaml). {{- end }} 1. Watch the rollout finish: @@ -45,7 +44,10 @@ GCS (GCS_BUCKET_NAME) in app.env; see STORAGE_PROVIDER in values.yaml. kubectl --namespace {{ .Release.Namespace }} port-forward svc/{{ include "sim.fullname" . }}-app {{ .Values.app.service.port | default 3000 }}:{{ .Values.app.service.port | default 3000 }} {{- if .Values.realtime.enabled }} - kubectl --namespace {{ .Release.Namespace }} port-forward svc/{{ include "sim.fullname" . }}-realtime {{ .Values.realtime.service.port | default 3002 }}:{{ .Values.realtime.service.port | default 3002 }} + + and, in a second terminal, realtime (the browser connects to localhost:3002): + + kubectl --namespace {{ .Release.Namespace }} port-forward svc/{{ include "sim.fullname" . }}-realtime 3002:{{ .Values.realtime.service.port | default 3002 }} {{- end }} Then open http://localhost:{{ .Values.app.service.port | default 3000 }} @@ -94,8 +96,8 @@ GCS (GCS_BUCKET_NAME) in app.env; see STORAGE_PROVIDER in values.yaml. # Upgrade after changing values helm upgrade {{ .Release.Name }} oci://ghcr.io/simstudioai/charts/sim --version --namespace {{ .Release.Namespace }} -f your-values.yaml -5. Upgrading: read the "Upgrading" section of helm/sim/README.md before moving - to a newer chart version. +5. Before upgrading the chart, read the new version's upgrade notes: + helm show readme oci://ghcr.io/simstudioai/charts/sim --version 6. Where to go next: diff --git a/helm/sim/templates/_helpers.tpl b/helm/sim/templates/_helpers.tpl index 8e3eeb9e47f..cc5dcaf7918 100644 --- a/helm/sim/templates/_helpers.tpl +++ b/helm/sim/templates/_helpers.tpl @@ -282,7 +282,7 @@ Skip validation when using existing secrets or External Secrets Operator {{- $useExistingPostgresSecret := and .Values.postgresql.auth.existingSecret .Values.postgresql.auth.existingSecret.enabled }} {{- $useExistingExternalDbSecret := and .Values.externalDatabase.existingSecret .Values.externalDatabase.existingSecret.enabled }} {{- if and .Values.postgresql.enabled .Values.externalDatabase.enabled }} -{{- fail "Both postgresql.enabled and externalDatabase.enabled are true. The chart currently uses the bundled database; set externalDatabase.enabled=false to keep it, or migrate your data and set postgresql.enabled=false." }} +{{- fail "postgresql.enabled and externalDatabase.enabled are both true; the chart uses the bundled database. Set externalDatabase.enabled=false to keep it, or migrate your data and set postgresql.enabled=false." }} {{- end }} {{- if and $useExistingAppSecret (not .Values.app.secrets.existingSecret.name) }} {{- fail "app.secrets.existingSecret.enabled=true but app.secrets.existingSecret.name is empty. Set it to the name of your pre-created app Secret." }} @@ -832,182 +832,126 @@ Validate Copilot configuration {{- end }} {{/* -Inline env entries the app container applies over its Secret, in precedence order (a later entry -for the same name wins): envDefaults (see sim.envDefaultsEntries), existingSecret-mode app.env -values, then extraEnvVars. The derived NEXT_PUBLIC_SOCKET_URL and BETTER_AUTH_URL are emitted only -when no other source sets them; BETTER_AUTH_URL comes last, so its $(NEXT_PUBLIC_APP_URL) expands -whichever entry defines that. Shared with the migrations init container so both resolve a key alike. +Inline env entries a container (dict "root" $ "component" "app"|"realtime") applies over its +Secret, in precedence order (a later entry for the same name wins): envDefaults (see +sim.envDefaultsEntries); in existingSecret mode, app.env (overlaid on realtime by non-empty +realtime.env), since no chart Secret carries it; then extraEnvVars. The derived +NEXT_PUBLIC_SOCKET_URL (app only) and BETTER_AUTH_URL are emitted only when nothing else sets them; +BETTER_AUTH_URL comes last, so its $(NEXT_PUBLIC_APP_URL) expands whichever entry defines that. +The migrations init container reads the app's entries so both resolve a key alike. */}} -{{- define "sim.appEnvOverrides" -}} -{{- include "sim.envDefaultsEntries" (dict "root" . "component" "app") }} -{{- /* - In existingSecret mode the chart-managed Secret is not rendered, so - non-empty values in app.env would otherwise go nowhere — inline them - here so the user's overrides actually reach the pod. Skipped in ESO - mode (ESO is the source of truth; inlining would mask the synced value) - and in inline mode (values flow through the chart-managed Secret). -*/}} -{{- if and .Values.app.secrets.existingSecret.enabled (not .Values.externalSecrets.enabled) }} +{{- define "sim.envOverrides" -}} +{{- $root := .root -}} +{{- $values := $root.Values -}} +{{- include "sim.envDefaultsEntries" (dict "root" $root "component" .component) }} +{{- if and $values.app.secrets.existingSecret.enabled (not $values.externalSecrets.enabled) }} {{- $chartComputed := list "DATABASE_URL" "SOCKET_SERVER_URL" "OLLAMA_URL" "PII_URL" }} -{{- range $key, $value := .Values.app.env | default dict }} +{{- /* Overlay by hand: sprig merge keeps the first source and treats "" as a value. */}} +{{- $effective := deepCopy ($values.app.env | default dict) }} +{{- if eq .component "realtime" }} +{{- range $key, $value := $values.realtime.env | default dict }} +{{- if and (ne (toString $value) "") (ne (toString $value) "") }} +{{- $_ := set $effective $key $value }} +{{- end }} +{{- end }} +{{- end }} +{{- range $key, $value := $effective }} {{- if and (ne (toString $value) "") (ne (toString $value) "") (not (has $key $chartComputed)) }} - name: {{ $key }} value: {{ $value | quote }} {{- end }} {{- end }} {{- end }} -{{- include "sim.socketUrlEntry" . }} -{{- with .Values.extraEnvVars }} +{{- if eq .component "app" }} +{{- include "sim.socketUrlEntry" $root }} +{{- end }} +{{- with $values.extraEnvVars }} {{ toYaml . }} {{- end }} -{{- include "sim.betterAuthUrlEntry" (dict "root" . "component" "app") }} +{{- include "sim.betterAuthUrlEntry" (dict "root" $root "component" .component) }} {{- end }} {{/* -Every envDefaults value a released chart has shipped, per component ("app" or "realtime"), as YAML -mapping each key to a list of values. In existingSecret mode a value on this list is not the -operator's choice, even from a values file copied from an older chart (NEXT_PUBLIC_BRAND_NAME, -BETTER_AUTH_URL, the free-tier limits), so it is never inlined over the Secret. Helm does not -expose a chart's own values.yaml to templates (.Files leaves it out), so the values are listed -here. Only ever add to a list: tests/env-defaults_test.yaml fails when today's values.yaml holds a -value missing here, or when one from tests/values/historical-env-defaults.yaml is dropped. +The app.env / realtime.env maps that reach a component's pod (dict "root" $ "component" +"app"|"realtime"), as a YAML list, lowest precedence first. The chart-managed Secret, which both +pods read, holds both maps with non-empty app.env winning; in existingSecret mode only realtime +inlines realtime.env, over app.env. */}} -{{- define "sim.shippedEnvDefaults" -}} -{{- if eq . "realtime" }} -ALLOWED_ORIGINS: ["http://localhost:3000"] -BETTER_AUTH_URL: ["http://localhost:3000"] -NEXT_PUBLIC_APP_URL: ["http://localhost:3000"] -NODE_ENV: ["production"] -{{- else }} -ACCESS_CONTROL_ENABLED: ["false"] -ADMISSION_GATE_MAX_INFLIGHT: ["500"] -BETTER_AUTH_URL: ["http://localhost:3000"] -BILLING_CONCURRENCY_LIMIT_ENTERPRISE: ["1000"] -BILLING_CONCURRENCY_LIMIT_FREE: ["10"] -BILLING_CONCURRENCY_LIMIT_PRO: ["50"] -BILLING_CONCURRENCY_LIMIT_TEAM: ["200"] -EMAIL_VERIFICATION_ENABLED: ["false"] -ENTERPRISE_TABLE_ROWS_LIMIT: ["1000000"] -ENTERPRISE_TABLES_LIMIT: ["10000"] -EXECUTION_TIMEOUT_ASYNC_ENTERPRISE: ["5400"] -EXECUTION_TIMEOUT_ASYNC_FREE: ["5400"] -EXECUTION_TIMEOUT_ASYNC_PRO: ["5400"] -EXECUTION_TIMEOUT_ASYNC_TEAM: ["5400"] -EXECUTION_TIMEOUT_ENTERPRISE: ["3000"] -EXECUTION_TIMEOUT_FREE: ["300"] -EXECUTION_TIMEOUT_PRO: ["3000"] -EXECUTION_TIMEOUT_TEAM: ["3000"] -FREE_TABLE_ROWS_LIMIT: ["1000"] -FREE_TABLES_LIMIT: ["3"] -IVM_DISTRIBUTED_LEASE_MIN_TTL_MS: ["120000"] -IVM_DISTRIBUTED_MAX_INFLIGHT_PER_OWNER: ["2200"] -IVM_MAX_ACTIVE_PER_OWNER: ["200"] -IVM_MAX_CONCURRENT: ["10000"] -IVM_MAX_FETCH_OPTIONS_JSON_CHARS: ["262144"] -IVM_MAX_FETCH_RESPONSE_BYTES: ["8388608"] -IVM_MAX_FETCH_RESPONSE_CHARS: ["4000000"] -IVM_MAX_FETCH_URL_LENGTH: ["8192"] -IVM_MAX_OWNER_WEIGHT: ["5"] -IVM_MAX_PER_WORKER: ["2500"] -IVM_MAX_QUEUE_SIZE: ["10000"] -IVM_MAX_QUEUED_PER_OWNER: ["2000"] -IVM_MAX_STDOUT_CHARS: ["200000"] -IVM_POOL_SIZE: ["4"] -IVM_QUEUE_TIMEOUT_MS: ["300000"] -IVM_WORKER_IDLE_TIMEOUT_MS: ["60000"] -NEXT_PUBLIC_ACCESS_CONTROL_ENABLED: ["false"] -NEXT_PUBLIC_APP_URL: ["http://localhost:3000"] -NEXT_PUBLIC_BRAND_NAME: ["Sim"] -NEXT_PUBLIC_ORGANIZATIONS_ENABLED: ["false"] -NEXT_PUBLIC_SUPPORT_EMAIL: ["help@sim.ai"] -NEXT_TELEMETRY_DISABLED: ["1"] -NODE_ENV: ["production"] -ORGANIZATIONS_ENABLED: ["false"] -PRO_TABLE_ROWS_LIMIT: ["5000"] -PRO_TABLES_LIMIT: ["25"] -RATE_LIMIT_FREE_ASYNC: ["200"] -RATE_LIMIT_FREE_SYNC: ["50"] -RATE_LIMIT_WINDOW_MS: ["60000"] -TEAM_TABLE_ROWS_LIMIT: ["10000"] -TEAM_TABLES_LIMIT: ["100"] -VERTEX_LOCATION: ["us-central1"] -{{- end }} -{{- end }} - -{{/* -"true" when an extraEnvVars entry (first arg: the list) supplies the key (second arg), by a -non-empty value or a valueFrom. -*/}} -{{- define "sim.extraEnvSets" -}} -{{- $key := index . 1 -}} -{{- range index . 0 | default list -}} -{{- if and (eq (toString .name) $key) (or .valueFrom (and .value (ne (toString .value) ""))) -}} -true -{{- end -}} +{{- define "sim.secretEnvs" -}} +{{- $values := .root.Values -}} +{{- $appEnv := $values.app.env | default dict -}} +{{- $realtimeEnv := $values.realtime.env | default dict -}} +{{- if not (and $values.app.secrets.existingSecret.enabled (not $values.externalSecrets.enabled)) -}} +{{- toYaml (list $realtimeEnv $appEnv) -}} +{{- else if eq .component "realtime" -}} +{{- toYaml (list $appEnv $realtimeEnv) -}} +{{- else -}} +{{- toYaml (list $appEnv) -}} {{- end -}} {{- end }} {{/* -"true" when the key (dict "root" $ "key" "") is mapped in externalSecrets.remoteRefs.app and -External Secrets is on, so the synced app Secret carries it. +The value a key resolves to on a component's pod (dict "root" $ "key" "" "component" +"app"|"realtime"), in Kubernetes precedence: envDefaults (inlined except in existingSecret mode), +then app.env and realtime.env (see sim.secretEnvs), then externalSecrets.remoteRefs.app, then +extraEnvVars (the last entry wins). "" when unset; "?" when only a secret reference supplies it, so +the chart cannot read it. A pre-created app Secret is unreadable and not considered. */}} -{{- define "sim.remoteRefMapsApp" -}} +{{- define "sim.envValue" -}} {{- $values := .root.Values -}} -{{- if $values.externalSecrets.enabled -}} -{{- $remoteRefs := default (dict) (default (dict) $values.externalSecrets.remoteRefs).app -}} -{{- if index $remoteRefs .key -}} -true +{{- $key := .key -}} +{{- $value := "" -}} +{{- if not (and $values.app.secrets.existingSecret.enabled (not $values.externalSecrets.enabled)) -}} +{{- $defaults := (index $values .component).envDefaults | default dict -}} +{{- if include "sim.nonEmptyEnv" (list $defaults $key) -}} +{{- $value = toString (index $defaults $key) -}} {{- end -}} {{- end -}} -{{- end }} - -{{/* -"true" when the operator supplies the key (dict "root" $ "key" "" "component" "app"|"realtime") -anywhere the chart can see on that component's pod: app.env (the shared Secret), the component's -env and envDefaults, extraEnvVars, or remoteRefs.app under External Secrets. -*/}} -{{- define "sim.keySupplied" -}} -{{- $values := .root.Values -}} -{{- $component := index $values .component -}} -{{- if or (include "sim.nonEmptyEnv" (list $values.app.env .key)) (include "sim.nonEmptyEnv" (list $component.env .key)) (include "sim.nonEmptyEnv" (list $component.envDefaults .key)) (include "sim.extraEnvSets" (list $values.extraEnvVars .key)) (include "sim.remoteRefMapsApp" (dict "root" .root "key" .key)) -}} -true +{{- $envs := include "sim.secretEnvs" . | fromYamlArray -}} +{{- range $env := $envs -}} +{{- if include "sim.nonEmptyEnv" (list $env $key) -}} +{{- $value = toString (index $env $key) -}} +{{- end -}} {{- end -}} +{{- if and $values.externalSecrets.enabled (index (default (dict) (default (dict) $values.externalSecrets.remoteRefs).app) $key) -}} +{{- $value = "?" -}} +{{- end -}} +{{- range $values.extraEnvVars | default list -}} +{{- if eq (toString .name) $key -}} +{{- $value = ternary "?" (toString (.value | default "")) (not (empty .valueFrom)) -}} +{{- end -}} +{{- end -}} +{{- $value -}} {{- end }} {{/* Inline env entries for a component's envDefaults (dict "root" $ "component" "app"|"realtime"). -Kubernetes `env` beats `envFrom`, so a default is skipped wherever it would mask a value the -operator supplied through the Secret: - - app.env (and, for realtime, realtime.env) sets the key: it reaches the pod via the Secret, or - inline in existingSecret mode - - External Secrets maps the key in remoteRefs.app: the synced Secret carries it - - existingSecret mode and the value is still the chart's shipped default: the pre-created Secret - is the source of truth, so only a value the operator changed in envDefaults is inlined +Kubernetes `env` beats `envFrom`, so a default is skipped where it would mask a value the operator +supplies through the Secret: app.env or realtime.env sets the key (see sim.secretEnvs), or External +Secrets maps it in remoteRefs.app. None are inlined in existingSecret mode: the pre-created Secret +is the source of truth there, and app.env (inlined in that mode) carries overrides. */}} {{- define "sim.envDefaultsEntries" -}} -{{- $root := .root -}} -{{- $values := $root.Values -}} -{{- $useExistingSecret := and $values.app.secrets.existingSecret.enabled (not $values.externalSecrets.enabled) -}} -{{- $maskingEnvs := list $values.app.env -}} -{{- if eq .component "realtime" -}} -{{- $maskingEnvs = append $maskingEnvs $values.realtime.env -}} +{{- $values := .root.Values -}} +{{- if not (and $values.app.secrets.existingSecret.enabled (not $values.externalSecrets.enabled)) -}} +{{- $remoteRefs := dict -}} +{{- if $values.externalSecrets.enabled -}} +{{- $remoteRefs = default (dict) (default (dict) $values.externalSecrets.remoteRefs).app -}} {{- end -}} -{{- $shipped := include "sim.shippedEnvDefaults" .component | fromYaml -}} +{{- $maskingEnvs := include "sim.secretEnvs" . | fromYamlArray -}} {{- range $key, $value := (index $values .component).envDefaults | default dict -}} -{{- $masked := include "sim.remoteRefMapsApp" (dict "root" $root "key" $key) -}} +{{- $masked := index $remoteRefs $key -}} {{- range $env := $maskingEnvs -}} {{- if include "sim.nonEmptyEnv" (list $env $key) -}} -{{- $masked = "true" -}} +{{- $masked = true -}} {{- end -}} {{- end -}} -{{- if and $useExistingSecret (has (toString $value) (index $shipped $key | default list)) -}} -{{- $masked = "true" -}} -{{- end -}} {{- if and (not $masked) (ne (toString $value) "") (ne (toString $value) "") }} - name: {{ $key }} value: {{ $value | quote }} {{- end -}} {{- end -}} +{{- end -}} {{- end }} {{/* @@ -1020,7 +964,7 @@ mask it. {{- define "sim.betterAuthUrlEntry" -}} {{- $values := .root.Values -}} {{- $useExistingSecret := and $values.app.secrets.existingSecret.enabled (not $values.externalSecrets.enabled) -}} -{{- $explicit := include "sim.keySupplied" (dict "root" .root "key" "BETTER_AUTH_URL" "component" .component) -}} +{{- $explicit := include "sim.envValue" (dict "root" .root "key" "BETTER_AUTH_URL" "component" .component) -}} {{- if not (or $useExistingSecret $explicit) }} - name: BETTER_AUTH_URL value: "$(NEXT_PUBLIC_APP_URL)" @@ -1029,8 +973,8 @@ mask it. {{/* The host an ingress serves realtime on: realtime.host, or the app host when it is empty or -sim-ws.local, the placeholder charts before 1.20.0 shipped (a values file copied from one still names -it, and no browser connects there). Takes the ingress values (.Values.ingress or .Values.ingressInternal). +sim-ws.local, the old default placeholder, which no browser connects to. Takes the ingress values +(.Values.ingress or .Values.ingressInternal). */}} {{- define "sim.ingressRealtimeHost" -}} {{- if or (not .realtime.host) (eq (toString .realtime.host) "sim-ws.local") -}} @@ -1041,8 +985,8 @@ it, and no browser connects there). Takes the ingress values (.Values.ingress or {{- end }} {{/* -The realtime ingress paths, as a YAML list. Under the pre-1.20.0 placeholder host the old default -paths ([/ Prefix]) become /socket.io, since that host now resolves to the app host. Takes the +The realtime ingress paths, as a YAML list. Under sim-ws.local, the old default placeholder, the old +default paths ([/ Prefix]) become /socket.io, since that host resolves to the app host. Takes the ingress values. */}} {{- define "sim.ingressRealtimePaths" -}} @@ -1062,7 +1006,7 @@ would route every app request to realtime. Takes (list " " 1 or autoscaling.enabled) with uploads stored on each pod's own filesystem: no object storage is configured. Fix it one of three ways: (1) configure object storage in app.env, e.g. STORAGE_PROVIDER=s3 with AWS_REGION + S3_BUCKET_NAME, STORAGE_PROVIDER=azure with AZURE_STORAGE_CONTAINER_NAME + AZURE_CONNECTION_STRING (or AZURE_ACCOUNT_NAME + AZURE_ACCOUNT_KEY), or STORAGE_PROVIDER=gcs with GCS_BUCKET_NAME; (2) mount a shared (ReadWriteMany) volume at /app/apps/sim/uploads via app.extraVolumes and app.extraVolumeMounts; or (3) set app.storage.allowLocalWithReplicas=true to accept that uploads stay on the pod that received them and are lost when it restarts." -}} +{{- fail "More than one app replica (app.replicaCount > 1 or autoscaling.enabled) needs object storage: uploads on each pod's filesystem are not shared and are lost on restart. Configure S3, Azure Blob, or GCS in app.env (see STORAGE_PROVIDER in values.yaml), mount a ReadWriteMany volume at /app/apps/sim/uploads, or set app.storage.allowLocalWithReplicas=true." -}} {{- end -}} {{- end }} @@ -1178,8 +1091,8 @@ with, always reports an install), unless app.storage.allowLocalWithReplicas acce Volume claim template labels for a bundled database StatefulSet (dict "root" $ "name" "" "claim" "" "selectorLabels" ""). Kubernetes rejects any change to volumeClaimTemplates, so these must never change across upgrades: -an existing StatefulSet's labels are reused verbatim (releases made before 1.20.0 carry the chart -version in them), and a new one gets only labels that never change. +an existing StatefulSet's labels are reused verbatim, and a new one gets only labels that never +change. */}} {{- define "sim.volumeClaimTemplateLabels" -}} {{- $root := .root -}} diff --git a/helm/sim/templates/_ingress.tpl b/helm/sim/templates/_ingress.tpl new file mode 100644 index 00000000000..18c945976bb --- /dev/null +++ b/helm/sim/templates/_ingress.tpl @@ -0,0 +1,142 @@ +{{/* +One Ingress for the public (ingress) or internal (ingressInternal) values: +(dict "root" $ "cfg" "key" "ingress"|"ingressInternal" "suffix" ""). +When services share a host, their paths join one rule: realtime, then copilot, then the app. +*/}} +{{- define "sim.ingress" -}} +{{- $root := .root -}} +{{- $cfg := .cfg -}} +{{- $key := .key -}} +{{- $suffix := .suffix -}} +{{- $appActive := $root.Values.app.enabled -}} +{{- $realtimeActive := $root.Values.realtime.enabled -}} +{{- $hasCopilotIngress := and $root.Values.copilot.enabled $cfg.copilot -}} +{{- $realtimeHost := include "sim.ingressRealtimeHost" $cfg -}} +{{- if and $appActive $realtimeActive }} +{{- include "sim.validateIngressRealtimePaths" (list $cfg $key) }} +{{- end }} +{{- $realtimeHasOwnRule := and $realtimeActive (or (not $appActive) (ne $realtimeHost (toString $cfg.app.host))) -}} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ include "sim.fullname" $root }}-{{ $suffix }} + namespace: {{ $root.Release.Namespace }} + labels: + {{- include "sim.labels" $root | nindent 4 }} + {{- with $cfg.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if $cfg.className }} + ingressClassName: {{ $cfg.className }} + {{- end }} + {{- if $cfg.tls.enabled }} + tls: + - hosts: + {{- if $appActive }} + - {{ $cfg.app.host | quote }} + {{- end }} + {{- if $realtimeHasOwnRule }} + - {{ $realtimeHost | quote }} + {{- end }} + {{- if $hasCopilotIngress }} + {{- $copilotHostCovered := false }} + {{- if and $appActive (eq $cfg.copilot.host $cfg.app.host) }} + {{- $copilotHostCovered = true }} + {{- end }} + {{- if and $realtimeHasOwnRule (eq $cfg.copilot.host $realtimeHost) }} + {{- $copilotHostCovered = true }} + {{- end }} + {{- if not $copilotHostCovered }} + - {{ $cfg.copilot.host | quote }} + {{- end }} + {{- end }} + secretName: {{ $cfg.tls.secretName }} + {{- end }} + rules: + {{- if $appActive }} + - host: {{ $cfg.app.host | quote }} + http: + paths: + {{- if and $realtimeActive (eq $realtimeHost (toString $cfg.app.host)) }} + {{- range include "sim.ingressRealtimePaths" $cfg | fromYamlArray }} + - path: {{ .path }} + pathType: {{ .pathType }} + backend: + service: + name: {{ include "sim.fullname" $root }}-realtime + port: + number: {{ $root.Values.realtime.service.port }} + {{- end }} + {{- end }} + {{- if and $hasCopilotIngress (eq $cfg.copilot.host $cfg.app.host) }} + {{- range $cfg.copilot.paths }} + - path: {{ .path }} + pathType: {{ .pathType }} + backend: + service: + name: {{ include "sim.fullname" $root }}-copilot + port: + number: {{ $root.Values.copilot.server.service.port }} + {{- end }} + {{- end }} + {{- range $cfg.app.paths }} + - path: {{ .path }} + pathType: {{ .pathType }} + backend: + service: + name: {{ include "sim.fullname" $root }}-app + port: + number: {{ $root.Values.app.service.port }} + {{- end }} + {{- end }} + {{- if $realtimeHasOwnRule }} + - host: {{ $realtimeHost | quote }} + http: + paths: + {{- range include "sim.ingressRealtimePaths" $cfg | fromYamlArray }} + - path: {{ .path }} + pathType: {{ .pathType }} + backend: + service: + name: {{ include "sim.fullname" $root }}-realtime + port: + number: {{ $root.Values.realtime.service.port }} + {{- end }} + {{- if and $hasCopilotIngress (eq $cfg.copilot.host $realtimeHost) }} + {{- range $cfg.copilot.paths }} + - path: {{ .path }} + pathType: {{ .pathType }} + backend: + service: + name: {{ include "sim.fullname" $root }}-copilot + port: + number: {{ $root.Values.copilot.server.service.port }} + {{- end }} + {{- end }} + {{- end }} + {{- if $hasCopilotIngress }} + {{- $copilotServed := false }} + {{- if and $appActive (eq $cfg.copilot.host $cfg.app.host) }} + {{- $copilotServed = true }} + {{- end }} + {{- if and $realtimeHasOwnRule (eq $cfg.copilot.host $realtimeHost) }} + {{- $copilotServed = true }} + {{- end }} + {{- if not $copilotServed }} + - host: {{ $cfg.copilot.host | quote }} + http: + paths: + {{- range $cfg.copilot.paths }} + - path: {{ .path }} + pathType: {{ .pathType }} + backend: + service: + name: {{ include "sim.fullname" $root }}-copilot + port: + number: {{ $root.Values.copilot.server.service.port }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/helm/sim/templates/deployment-app.yaml b/helm/sim/templates/deployment-app.yaml index d5cf8fbdb81..06937fa1625 100644 --- a/helm/sim/templates/deployment-app.yaml +++ b/helm/sim/templates/deployment-app.yaml @@ -68,7 +68,7 @@ spec: extraEnvVars), else the app Secret. Without a usable key the step stays pending. */}} env: - {{- $appOverrides := include "sim.appEnvOverrides" . | fromYamlArray }} + {{- $appOverrides := include "sim.envOverrides" (dict "root" . "component" "app") | fromYamlArray }} {{- range $key := list "ENCRYPTION_KEY" "ENCRYPT_ACCOUNT_TOKENS" }} {{- $override := dict }} {{- range $appOverrides }} @@ -154,7 +154,7 @@ spec: {{- include "sim.sandbox.appEnv" . | nindent 12 }} {{- end }} {{- /* Operator overrides last, so they win over the defaults above and over envFrom. */}} - {{- include "sim.appEnvOverrides" . | trim | nindent 12 }} + {{- include "sim.envOverrides" (dict "root" . "component" "app") | trim | nindent 12 }} envFrom: # Bundled Redis URL. Listed FIRST so any operator-supplied REDIS_URL # in a later source overrides it — see templates/configmap-redis.yaml. diff --git a/helm/sim/templates/deployment-realtime.yaml b/helm/sim/templates/deployment-realtime.yaml index 2d67e3f4e7a..38e7b4db001 100644 --- a/helm/sim/templates/deployment-realtime.yaml +++ b/helm/sim/templates/deployment-realtime.yaml @@ -74,51 +74,8 @@ spec: - name: OTEL_RESOURCE_ATTRIBUTES value: "service.name=sim-realtime,service.version={{ .Chart.AppVersion }},deployment.environment={{ $nodeEnv }}" {{- end }} - {{- /* - realtime.envDefaults, skipping any key a Secret-bound source supplies (see - sim.envDefaultsEntries). The app Secret is shared with the app pod, so a key set - in app.env masks the default here too. - */}} - {{- $rtEnv := .Values.realtime.env | default dict }} - {{- $appEnv := .Values.app.env | default dict }} - {{- with include "sim.envDefaultsEntries" (dict "root" . "component" "realtime") | trim }} - {{- . | nindent 12 }} - {{- end }} - {{- /* - In existingSecret mode the chart-managed Secret is not rendered, so - non-empty values in realtime.env / app.env would otherwise go nowhere - — inline them here so the user's overrides actually reach the pod. - realtime.env wins over app.env on collision (realtime-specific intent). - Skipped in ESO mode and inline mode for the same reasons as the app - deployment. - */}} - {{- if and .Values.app.secrets.existingSecret.enabled (not .Values.externalSecrets.enabled) }} - {{- $chartComputed := list "DATABASE_URL" "SOCKET_SERVER_URL" "OLLAMA_URL" "PII_URL" }} - {{- /* - Build the effective realtime env from app.env as the base, then - overlay non-empty realtime.env values. Sprig's `merge` keeps the - first source on collision and treats "" as a real value, which - would shadow non-empty app.env entries — so do the overlay - manually with an explicit empty-string check. - */}} - {{- $effective := deepCopy $appEnv }} - {{- range $key, $value := $rtEnv }} - {{- if and (ne (toString $value) "") (ne (toString $value) "") }} - {{- $_ := set $effective $key $value }} - {{- end }} - {{- end }} - {{- range $key, $value := $effective }} - {{- if and (ne (toString $value) "") (ne (toString $value) "") (not (has $key $chartComputed)) }} - - name: {{ $key }} - value: {{ $value | quote }} - {{- end }} - {{- end }} - {{- end }} - {{- with .Values.extraEnvVars }} - {{- toYaml . | nindent 12 }} - {{- end }} - {{- /* Last, so $(NEXT_PUBLIC_APP_URL) expands whichever entry above defines it. */}} - {{- with include "sim.betterAuthUrlEntry" (dict "root" . "component" "realtime") | trim }} + {{- /* Operator overrides last, so they win over the defaults above and over envFrom. */}} + {{- with include "sim.envOverrides" (dict "root" . "component" "realtime") | trim }} {{- . | nindent 12 }} {{- end }} envFrom: diff --git a/helm/sim/templates/ingress-internal.yaml b/helm/sim/templates/ingress-internal.yaml index 01bc7fb05d4..0c73897e69e 100644 --- a/helm/sim/templates/ingress-internal.yaml +++ b/helm/sim/templates/ingress-internal.yaml @@ -1,133 +1,3 @@ {{- if .Values.ingressInternal.enabled }} -{{- $appActive := .Values.app.enabled -}} -{{- $realtimeActive := .Values.realtime.enabled -}} -{{- $hasCopilotIngress := and .Values.copilot.enabled .Values.ingressInternal.copilot -}} -{{- $realtimeHost := include "sim.ingressRealtimeHost" .Values.ingressInternal -}} -{{- if and $appActive $realtimeActive }} -{{- include "sim.validateIngressRealtimePaths" (list .Values.ingressInternal "ingressInternal") }} -{{- end }} -{{- $realtimeHasOwnRule := and $realtimeActive (or (not $appActive) (ne $realtimeHost (toString .Values.ingressInternal.app.host))) -}} -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - name: {{ include "sim.fullname" . }}-ingress-internal - namespace: {{ .Release.Namespace }} - labels: - {{- include "sim.labels" . | nindent 4 }} - {{- with .Values.ingressInternal.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -spec: - {{- if .Values.ingressInternal.className }} - ingressClassName: {{ .Values.ingressInternal.className }} - {{- end }} - {{- if .Values.ingressInternal.tls.enabled }} - tls: - - hosts: - {{- if $appActive }} - - {{ .Values.ingressInternal.app.host | quote }} - {{- end }} - {{- if $realtimeHasOwnRule }} - - {{ $realtimeHost | quote }} - {{- end }} - {{- if $hasCopilotIngress }} - {{- $copilotHostCovered := false }} - {{- if and $appActive (eq .Values.ingressInternal.copilot.host .Values.ingressInternal.app.host) }} - {{- $copilotHostCovered = true }} - {{- end }} - {{- if and $realtimeHasOwnRule (eq .Values.ingressInternal.copilot.host $realtimeHost) }} - {{- $copilotHostCovered = true }} - {{- end }} - {{- if not $copilotHostCovered }} - - {{ .Values.ingressInternal.copilot.host | quote }} - {{- end }} - {{- end }} - secretName: {{ .Values.ingressInternal.tls.secretName }} - {{- end }} - rules: - {{- if $appActive }} - - host: {{ .Values.ingressInternal.app.host | quote }} - http: - paths: - {{- if and $realtimeActive (eq $realtimeHost (toString .Values.ingressInternal.app.host)) }} - {{- range include "sim.ingressRealtimePaths" .Values.ingressInternal | fromYamlArray }} - - path: {{ .path }} - pathType: {{ .pathType }} - backend: - service: - name: {{ include "sim.fullname" $ }}-realtime - port: - number: {{ $.Values.realtime.service.port }} - {{- end }} - {{- end }} - {{- if and $hasCopilotIngress (eq .Values.ingressInternal.copilot.host .Values.ingressInternal.app.host) }} - {{- range .Values.ingressInternal.copilot.paths }} - - path: {{ .path }} - pathType: {{ .pathType }} - backend: - service: - name: {{ include "sim.fullname" $ }}-copilot - port: - number: {{ $.Values.copilot.server.service.port }} - {{- end }} - {{- end }} - {{- range .Values.ingressInternal.app.paths }} - - path: {{ .path }} - pathType: {{ .pathType }} - backend: - service: - name: {{ include "sim.fullname" $ }}-app - port: - number: {{ $.Values.app.service.port }} - {{- end }} - {{- end }} - {{- if $realtimeHasOwnRule }} - - host: {{ $realtimeHost | quote }} - http: - paths: - {{- range include "sim.ingressRealtimePaths" .Values.ingressInternal | fromYamlArray }} - - path: {{ .path }} - pathType: {{ .pathType }} - backend: - service: - name: {{ include "sim.fullname" $ }}-realtime - port: - number: {{ $.Values.realtime.service.port }} - {{- end }} - {{- if and $hasCopilotIngress (eq .Values.ingressInternal.copilot.host $realtimeHost) }} - {{- range .Values.ingressInternal.copilot.paths }} - - path: {{ .path }} - pathType: {{ .pathType }} - backend: - service: - name: {{ include "sim.fullname" $ }}-copilot - port: - number: {{ $.Values.copilot.server.service.port }} - {{- end }} - {{- end }} - {{- end }} - {{- if $hasCopilotIngress }} - {{- $copilotServed := false }} - {{- if and $appActive (eq .Values.ingressInternal.copilot.host .Values.ingressInternal.app.host) }} - {{- $copilotServed = true }} - {{- end }} - {{- if and $realtimeHasOwnRule (eq .Values.ingressInternal.copilot.host $realtimeHost) }} - {{- $copilotServed = true }} - {{- end }} - {{- if not $copilotServed }} - - host: {{ .Values.ingressInternal.copilot.host | quote }} - http: - paths: - {{- range .Values.ingressInternal.copilot.paths }} - - path: {{ .path }} - pathType: {{ .pathType }} - backend: - service: - name: {{ include "sim.fullname" $ }}-copilot - port: - number: {{ $.Values.copilot.server.service.port }} - {{- end }} - {{- end }} - {{- end }} +{{- include "sim.ingress" (dict "root" . "cfg" .Values.ingressInternal "key" "ingressInternal" "suffix" "ingress-internal") }} {{- end }} diff --git a/helm/sim/templates/ingress.yaml b/helm/sim/templates/ingress.yaml index fec8a2c1add..d0de7516d09 100644 --- a/helm/sim/templates/ingress.yaml +++ b/helm/sim/templates/ingress.yaml @@ -1,133 +1,3 @@ {{- if .Values.ingress.enabled }} -{{- $appActive := .Values.app.enabled -}} -{{- $realtimeActive := .Values.realtime.enabled -}} -{{- $hasCopilotIngress := and .Values.copilot.enabled .Values.ingress.copilot -}} -{{- $realtimeHost := include "sim.ingressRealtimeHost" .Values.ingress -}} -{{- if and $appActive $realtimeActive }} -{{- include "sim.validateIngressRealtimePaths" (list .Values.ingress "ingress") }} -{{- end }} -{{- $realtimeHasOwnRule := and $realtimeActive (or (not $appActive) (ne $realtimeHost (toString .Values.ingress.app.host))) -}} -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - name: {{ include "sim.fullname" . }}-ingress - namespace: {{ .Release.Namespace }} - labels: - {{- include "sim.labels" . | nindent 4 }} - {{- with .Values.ingress.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -spec: - {{- if .Values.ingress.className }} - ingressClassName: {{ .Values.ingress.className }} - {{- end }} - {{- if .Values.ingress.tls.enabled }} - tls: - - hosts: - {{- if $appActive }} - - {{ .Values.ingress.app.host | quote }} - {{- end }} - {{- if $realtimeHasOwnRule }} - - {{ $realtimeHost | quote }} - {{- end }} - {{- if $hasCopilotIngress }} - {{- $copilotHostCovered := false }} - {{- if and $appActive (eq .Values.ingress.copilot.host .Values.ingress.app.host) }} - {{- $copilotHostCovered = true }} - {{- end }} - {{- if and $realtimeHasOwnRule (eq .Values.ingress.copilot.host $realtimeHost) }} - {{- $copilotHostCovered = true }} - {{- end }} - {{- if not $copilotHostCovered }} - - {{ .Values.ingress.copilot.host | quote }} - {{- end }} - {{- end }} - secretName: {{ .Values.ingress.tls.secretName }} - {{- end }} - rules: - {{- if $appActive }} - - host: {{ .Values.ingress.app.host | quote }} - http: - paths: - {{- if and $realtimeActive (eq $realtimeHost (toString .Values.ingress.app.host)) }} - {{- range include "sim.ingressRealtimePaths" .Values.ingress | fromYamlArray }} - - path: {{ .path }} - pathType: {{ .pathType }} - backend: - service: - name: {{ include "sim.fullname" $ }}-realtime - port: - number: {{ $.Values.realtime.service.port }} - {{- end }} - {{- end }} - {{- if and $hasCopilotIngress (eq .Values.ingress.copilot.host .Values.ingress.app.host) }} - {{- range .Values.ingress.copilot.paths }} - - path: {{ .path }} - pathType: {{ .pathType }} - backend: - service: - name: {{ include "sim.fullname" $ }}-copilot - port: - number: {{ $.Values.copilot.server.service.port }} - {{- end }} - {{- end }} - {{- range .Values.ingress.app.paths }} - - path: {{ .path }} - pathType: {{ .pathType }} - backend: - service: - name: {{ include "sim.fullname" $ }}-app - port: - number: {{ $.Values.app.service.port }} - {{- end }} - {{- end }} - {{- if $realtimeHasOwnRule }} - - host: {{ $realtimeHost | quote }} - http: - paths: - {{- range include "sim.ingressRealtimePaths" .Values.ingress | fromYamlArray }} - - path: {{ .path }} - pathType: {{ .pathType }} - backend: - service: - name: {{ include "sim.fullname" $ }}-realtime - port: - number: {{ $.Values.realtime.service.port }} - {{- end }} - {{- if and $hasCopilotIngress (eq .Values.ingress.copilot.host $realtimeHost) }} - {{- range .Values.ingress.copilot.paths }} - - path: {{ .path }} - pathType: {{ .pathType }} - backend: - service: - name: {{ include "sim.fullname" $ }}-copilot - port: - number: {{ $.Values.copilot.server.service.port }} - {{- end }} - {{- end }} - {{- end }} - {{- if $hasCopilotIngress }} - {{- $copilotServed := false }} - {{- if and $appActive (eq .Values.ingress.copilot.host .Values.ingress.app.host) }} - {{- $copilotServed = true }} - {{- end }} - {{- if and $realtimeHasOwnRule (eq .Values.ingress.copilot.host $realtimeHost) }} - {{- $copilotServed = true }} - {{- end }} - {{- if not $copilotServed }} - - host: {{ .Values.ingress.copilot.host | quote }} - http: - paths: - {{- range .Values.ingress.copilot.paths }} - - path: {{ .path }} - pathType: {{ .pathType }} - backend: - service: - name: {{ include "sim.fullname" $ }}-copilot - port: - number: {{ $.Values.copilot.server.service.port }} - {{- end }} - {{- end }} - {{- end }} +{{- include "sim.ingress" (dict "root" . "cfg" .Values.ingress "key" "ingress" "suffix" "ingress") }} {{- end }} diff --git a/helm/sim/tests/env-defaults_test.yaml b/helm/sim/tests/env-defaults_test.yaml index 2abca4dff40..dcf2ad1a2ca 100644 --- a/helm/sim/tests/env-defaults_test.yaml +++ b/helm/sim/tests/env-defaults_test.yaml @@ -160,124 +160,33 @@ tests: name: ALLOWED_ORIGINS value: http://localhost:3000 - # existingSecret mode: an envDefaults value the operator changed reaches the pod; one still at the - # chart's default does not, so it cannot mask a key kept in the pre-created Secret. - - it: existingSecret mode inlines an app envDefault the operator changed + # existingSecret mode: the pre-created Secret is the source of truth, so no envDefaults value is + # inlined over it, even one the operator changed (overrides go in app.env, inlined in this mode). + - it: existingSecret mode inlines no app envDefaults, even changed ones template: deployment-app.yaml set: app.secrets.existingSecret.enabled: true app.secrets.existingSecret.name: my-secret postgresql.auth.password: xxxxxxxx app.envDefaults.IVM_POOL_SIZE: "8" - app.envDefaults.SOME_OPERATOR_KEY: "on" - asserts: - - contains: - path: spec.template.spec.containers[0].env - content: - name: IVM_POOL_SIZE - value: "8" - - contains: - path: spec.template.spec.containers[0].env - content: - name: SOME_OPERATOR_KEY - value: "on" - - notContains: - path: spec.template.spec.containers[0].env - content: - name: IVM_MAX_CONCURRENT - value: "10000" - - - it: existingSecret mode inlines a realtime envDefault the operator changed - template: deployment-realtime.yaml - set: - app.secrets.existingSecret.enabled: true - app.secrets.existingSecret.name: my-secret - postgresql.auth.password: xxxxxxxx - realtime.envDefaults.ALLOWED_ORIGINS: https://sim.example.com - asserts: - - contains: - path: spec.template.spec.containers[0].env - content: - name: ALLOWED_ORIGINS - value: https://sim.example.com - - notContains: - path: spec.template.spec.containers[0].env - content: - name: NODE_ENV - value: production - - # Guards sim.shippedEnvDefaults against drift from values.yaml: a default missing from that list - # (or holding another value) would be inlined here, past the chart-computed entries. - - it: existingSecret mode with untouched defaults inlines only chart-computed app env - template: deployment-app.yaml - set: - app.secrets.existingSecret.enabled: true - app.secrets.existingSecret.name: my-secret - postgresql.auth.password: xxxxxxxx - asserts: - - lengthEqual: - path: spec.template.spec.containers[0].env - count: 4 - - - it: existingSecret mode with untouched defaults inlines only chart-computed realtime env - template: deployment-realtime.yaml - set: - app.secrets.existingSecret.enabled: true - app.secrets.existingSecret.name: my-secret - postgresql.auth.password: xxxxxxxx - asserts: - - lengthEqual: - path: spec.template.spec.containers[0].env - count: 1 - - # A values file copied from any released chart carries that chart's defaults (1.11 shipped - # NEXT_PUBLIC_BRAND_NAME "Sim"); none of them may mask the white-label values in the Secret. - - it: existingSecret mode inlines no default any released chart shipped, on the app pod - template: deployment-app.yaml - values: - - values/historical-env-defaults.yaml - set: - app.secrets.existingSecret.enabled: true - app.secrets.existingSecret.name: my-secret - postgresql.auth.password: xxxxxxxx + app.envDefaults.NEXT_PUBLIC_BRAND_NAME: Sim asserts: - lengthEqual: path: spec.template.spec.containers[0].env count: 4 - - it: existingSecret mode inlines no default any released chart shipped, on the realtime pod + - it: existingSecret mode inlines no realtime envDefaults, even changed ones template: deployment-realtime.yaml - values: - - values/historical-env-defaults.yaml set: app.secrets.existingSecret.enabled: true app.secrets.existingSecret.name: my-secret postgresql.auth.password: xxxxxxxx + realtime.envDefaults.ALLOWED_ORIGINS: https://sim.example.com asserts: - lengthEqual: path: spec.template.spec.containers[0].env count: 1 - - it: existingSecret mode keeps the old NEXT_PUBLIC_BRAND_NAME default off the pod but inlines a changed one - template: deployment-app.yaml - set: - app.secrets.existingSecret.enabled: true - app.secrets.existingSecret.name: my-secret - postgresql.auth.password: xxxxxxxx - app.envDefaults.NEXT_PUBLIC_BRAND_NAME: Sim - app.envDefaults.NEXT_PUBLIC_SUPPORT_EMAIL: support@acme.example - asserts: - - notContains: - path: spec.template.spec.containers[0].env - content: - name: NEXT_PUBLIC_BRAND_NAME - any: true - - contains: - path: spec.template.spec.containers[0].env - content: - name: NEXT_PUBLIC_SUPPORT_EMAIL - value: support@acme.example - # BETTER_AUTH_URL follows NEXT_PUBLIC_APP_URL unless the operator sets it somewhere. - it: app BETTER_AUTH_URL defaults to NEXT_PUBLIC_APP_URL, after it template: deployment-app.yaml @@ -368,3 +277,29 @@ tests: - notContains: path: spec.template.spec.containers[0].env content: { name: BETTER_AUTH_URL, value: $(NEXT_PUBLIC_APP_URL) } + + # In inline mode realtime.env is written into the app Secret both pods read, so it counts on the app + # pod too: nothing inline may override it there. + - it: a realtime.env BETTER_AUTH_URL also wins on the app pod + template: deployment-app.yaml + set: + <<: *defaults + realtime.env.BETTER_AUTH_URL: https://auth.example.com + asserts: + - notContains: + path: spec.template.spec.containers[0].env + content: + name: BETTER_AUTH_URL + any: true + + - it: a realtime.env value masks the app envDefault for the same key + template: deployment-app.yaml + set: + <<: *defaults + realtime.env.NEXT_PUBLIC_APP_URL: https://sim.example.com + asserts: + - notContains: + path: spec.template.spec.containers[0].env + content: + name: NEXT_PUBLIC_APP_URL + any: true diff --git a/helm/sim/tests/ingress-realtime_test.yaml b/helm/sim/tests/ingress-realtime_test.yaml index a0e30b73f9a..676d1281000 100644 --- a/helm/sim/tests/ingress-realtime_test.yaml +++ b/helm/sim/tests/ingress-realtime_test.yaml @@ -139,6 +139,19 @@ tests: name: NEXT_PUBLIC_SOCKET_URL value: http://ws.example.com + - it: keeps a realtime.env NEXT_PUBLIC_SOCKET_URL, which the shared Secret gives the app + template: deployment-app.yaml + set: + <<: *defaults + ingress.realtime.host: ws.example.com + realtime.env.NEXT_PUBLIC_SOCKET_URL: wss://ws.example.com + asserts: + - notContains: + path: spec.template.spec.containers[0].env + content: + name: NEXT_PUBLIC_SOCKET_URL + any: true + - it: keeps an operator-set NEXT_PUBLIC_SOCKET_URL for a separate realtime host template: deployment-app.yaml set: @@ -217,7 +230,7 @@ tests: pathType: Prefix asserts: - failedTemplate: - errorMessage: 'ingress.realtime.paths contains "/" while realtime shares the app host "sim.example.com": that rule would send every app request to the realtime service. Use the path /socket.io (the default), or set ingress.realtime.host to a separate hostname.' + errorMessage: 'ingress.realtime.paths has "/" on the app host "sim.example.com", which would send every app request to realtime. Use /socket.io (the default) or a separate ingress.realtime.host.' - it: refuses a "/" realtime path on the internal ingress app host template: ingress-internal.yaml @@ -229,4 +242,4 @@ tests: pathType: Prefix asserts: - failedTemplate: - errorMessage: 'ingressInternal.realtime.paths contains "/" while realtime shares the app host "sim-internal.local": that rule would send every app request to the realtime service. Use the path /socket.io (the default), or set ingressInternal.realtime.host to a separate hostname.' + errorMessage: 'ingressInternal.realtime.paths has "/" on the app host "sim-internal.local", which would send every app request to realtime. Use /socket.io (the default) or a separate ingressInternal.realtime.host.' diff --git a/helm/sim/tests/storage_test.yaml b/helm/sim/tests/storage_test.yaml index d24ad4cc857..de47fb303d9 100644 --- a/helm/sim/tests/storage_test.yaml +++ b/helm/sim/tests/storage_test.yaml @@ -16,7 +16,7 @@ tests: app.replicaCount: 2 asserts: - failedTemplate: - errorMessage: "More than one app replica (app.replicaCount > 1 or autoscaling.enabled) with uploads stored on each pod's own filesystem: no object storage is configured. Fix it one of three ways: (1) configure object storage in app.env, e.g. STORAGE_PROVIDER=s3 with AWS_REGION + S3_BUCKET_NAME, STORAGE_PROVIDER=azure with AZURE_STORAGE_CONTAINER_NAME + AZURE_CONNECTION_STRING (or AZURE_ACCOUNT_NAME + AZURE_ACCOUNT_KEY), or STORAGE_PROVIDER=gcs with GCS_BUCKET_NAME; (2) mount a shared (ReadWriteMany) volume at /app/apps/sim/uploads via app.extraVolumes and app.extraVolumeMounts; or (3) set app.storage.allowLocalWithReplicas=true to accept that uploads stay on the pod that received them and are lost when it restarts." + errorMessage: "More than one app replica (app.replicaCount > 1 or autoscaling.enabled) needs object storage: uploads on each pod's filesystem are not shared and are lost on restart. Configure S3, Azure Blob, or GCS in app.env (see STORAGE_PROVIDER in values.yaml), mount a ReadWriteMany volume at /app/apps/sim/uploads, or set app.storage.allowLocalWithReplicas=true." - it: refuses an autoscaled install that stores uploads on the pod template: deployment-app.yaml diff --git a/helm/sim/tests/validators_test.yaml b/helm/sim/tests/validators_test.yaml index 9f5ce89c542..ef45c5fee6a 100644 --- a/helm/sim/tests/validators_test.yaml +++ b/helm/sim/tests/validators_test.yaml @@ -171,4 +171,4 @@ tests: externalDatabase.password: xxxxxxxx asserts: - failedTemplate: - errorMessage: "Both postgresql.enabled and externalDatabase.enabled are true. The chart currently uses the bundled database; set externalDatabase.enabled=false to keep it, or migrate your data and set postgresql.enabled=false." + errorMessage: "postgresql.enabled and externalDatabase.enabled are both true; the chart uses the bundled database. Set externalDatabase.enabled=false to keep it, or migrate your data and set postgresql.enabled=false." diff --git a/helm/sim/tests/values/historical-env-defaults.yaml b/helm/sim/tests/values/historical-env-defaults.yaml deleted file mode 100644 index cbb05fde099..00000000000 --- a/helm/sim/tests/values/historical-env-defaults.yaml +++ /dev/null @@ -1,62 +0,0 @@ -# Every envDefaults value a released chart has shipped (from helm/sim/values.yaml history). -# A values file copied from any of those charts must read as untouched in existingSecret mode. -app: - envDefaults: - ACCESS_CONTROL_ENABLED: "false" - ADMISSION_GATE_MAX_INFLIGHT: "500" - BETTER_AUTH_URL: "http://localhost:3000" - BILLING_CONCURRENCY_LIMIT_ENTERPRISE: "1000" - BILLING_CONCURRENCY_LIMIT_FREE: "10" - BILLING_CONCURRENCY_LIMIT_PRO: "50" - BILLING_CONCURRENCY_LIMIT_TEAM: "200" - EMAIL_VERIFICATION_ENABLED: "false" - ENTERPRISE_TABLE_ROWS_LIMIT: "1000000" - ENTERPRISE_TABLES_LIMIT: "10000" - EXECUTION_TIMEOUT_ASYNC_ENTERPRISE: "5400" - EXECUTION_TIMEOUT_ASYNC_FREE: "5400" - EXECUTION_TIMEOUT_ASYNC_PRO: "5400" - EXECUTION_TIMEOUT_ASYNC_TEAM: "5400" - EXECUTION_TIMEOUT_ENTERPRISE: "3000" - EXECUTION_TIMEOUT_FREE: "300" - EXECUTION_TIMEOUT_PRO: "3000" - EXECUTION_TIMEOUT_TEAM: "3000" - FREE_TABLE_ROWS_LIMIT: "1000" - FREE_TABLES_LIMIT: "3" - IVM_DISTRIBUTED_LEASE_MIN_TTL_MS: "120000" - IVM_DISTRIBUTED_MAX_INFLIGHT_PER_OWNER: "2200" - IVM_MAX_ACTIVE_PER_OWNER: "200" - IVM_MAX_CONCURRENT: "10000" - IVM_MAX_FETCH_OPTIONS_JSON_CHARS: "262144" - IVM_MAX_FETCH_RESPONSE_BYTES: "8388608" - IVM_MAX_FETCH_RESPONSE_CHARS: "4000000" - IVM_MAX_FETCH_URL_LENGTH: "8192" - IVM_MAX_OWNER_WEIGHT: "5" - IVM_MAX_PER_WORKER: "2500" - IVM_MAX_QUEUE_SIZE: "10000" - IVM_MAX_QUEUED_PER_OWNER: "2000" - IVM_MAX_STDOUT_CHARS: "200000" - IVM_POOL_SIZE: "4" - IVM_QUEUE_TIMEOUT_MS: "300000" - IVM_WORKER_IDLE_TIMEOUT_MS: "60000" - NEXT_PUBLIC_ACCESS_CONTROL_ENABLED: "false" - NEXT_PUBLIC_APP_URL: "http://localhost:3000" - NEXT_PUBLIC_BRAND_NAME: "Sim" - NEXT_PUBLIC_ORGANIZATIONS_ENABLED: "false" - NEXT_PUBLIC_SUPPORT_EMAIL: "help@sim.ai" - NEXT_TELEMETRY_DISABLED: "1" - NODE_ENV: "production" - ORGANIZATIONS_ENABLED: "false" - PRO_TABLE_ROWS_LIMIT: "5000" - PRO_TABLES_LIMIT: "25" - RATE_LIMIT_FREE_ASYNC: "200" - RATE_LIMIT_FREE_SYNC: "50" - RATE_LIMIT_WINDOW_MS: "60000" - TEAM_TABLE_ROWS_LIMIT: "10000" - TEAM_TABLES_LIMIT: "100" - VERTEX_LOCATION: "us-central1" -realtime: - envDefaults: - ALLOWED_ORIGINS: "http://localhost:3000" - BETTER_AUTH_URL: "http://localhost:3000" - NEXT_PUBLIC_APP_URL: "http://localhost:3000" - NODE_ENV: "production" diff --git a/helm/sim/values.yaml b/helm/sim/values.yaml index 25e501a5693..59a92287a0d 100644 --- a/helm/sim/values.yaml +++ b/helm/sim/values.yaml @@ -29,9 +29,9 @@ app: # Number of replicas replicaCount: 1 - # Upload storage. With more than one replica (or autoscaling) and no object storage configured - # (see STORAGE_PROVIDER under app.env), the render fails, because each pod would keep its own - # uploads and lose them on restart. Set allowLocalWithReplicas=true only to accept exactly that. + # More than one replica (or autoscaling) needs object storage (STORAGE_PROVIDER) or a shared + # volume at /app/apps/sim/uploads, or the render fails. allowLocalWithReplicas=true accepts + # per-pod uploads that are lost on restart. storage: allowLocalWithReplicas: false @@ -75,11 +75,9 @@ app: # Environment variables env: - # Application URLs — set NEXT_PUBLIC_APP_URL to your public origin (e.g. https://sim.example.com). - # It defaults to http://localhost:3000 via app.envDefaults for local installs; override here - # (or via --set) for production. BETTER_AUTH_URL follows NEXT_PUBLIC_APP_URL when left empty - # (set it in your Secret in app.secrets.existingSecret mode). Set values here go into the - # chart-managed Secret and take precedence over envDefaults at runtime. + # Public origin, e.g. https://sim.example.com (defaults to http://localhost:3000 via + # envDefaults). BETTER_AUTH_URL follows NEXT_PUBLIC_APP_URL when empty, except in + # app.secrets.existingSecret mode, where your Secret must hold it. NEXT_PUBLIC_APP_URL: "" BETTER_AUTH_URL: "" INTERNAL_API_BASE_URL: "" # Optional server-side internal base URL for /api self-calls (include http:// or https://); falls back to NEXT_PUBLIC_APP_URL when empty @@ -292,11 +290,7 @@ app: # Optional file storage override. One of: local, s3, azure, gcs. # Empty preserves legacy Azure → S3 → GCS → local precedence. - # Local storage writes uploads to the pod's own filesystem (lost on restart, not shared), so - # app.replicaCount > 1 or autoscaling.enabled fails to render without an object store: S3 - # (AWS_REGION + S3_BUCKET_NAME), Azure Blob (AZURE_STORAGE_CONTAINER_NAME + - # AZURE_CONNECTION_STRING, or AZURE_ACCOUNT_NAME + AZURE_ACCOUNT_KEY), or GCS (GCS_BUCKET_NAME), - # unless a shared volume is mounted at /app/apps/sim/uploads or app.storage.allowLocalWithReplicas. + # Without an object store, more than one app replica fails to render (see app.storage). STORAGE_PROVIDER: "" # AWS S3 Cloud Storage Configuration (optional - for file storage) @@ -349,10 +343,8 @@ app: # does NOT remove it: every key under `app.env` ships as a "" placeholder, so the templates # must read "" as "unspecified". See "Removing an inherited env key" in README.md. envDefaults: - # Application URL (override in app.env or app.envDefaults for production). BETTER_AUTH_URL is - # not preset: unless app.env, envDefaults, extraEnvVars, or externalSecrets.remoteRefs.app sets - # it, the chart sets it to $(NEXT_PUBLIC_APP_URL) (not in app.secrets.existingSecret mode, - # where the pre-created Secret must hold it). + # Application URL (override in app.env for production). BETTER_AUTH_URL is derived from it; + # see app.env. NEXT_PUBLIC_APP_URL: "http://localhost:3000" # Node environment @@ -530,7 +522,6 @@ realtime: # Operational defaults shipped with the chart. Rendered as inline `env:` on the realtime # container (NOT written into the Secret, NOT required in externalSecrets.remoteRefs). # User-set values in `realtime.env` above take precedence. - # BETTER_AUTH_URL follows NEXT_PUBLIC_APP_URL unless set (same rule as app.envDefaults). envDefaults: NEXT_PUBLIC_APP_URL: "http://localhost:3000" ALLOWED_ORIGINS: "http://localhost:3000" @@ -1049,16 +1040,10 @@ ingress: - path: / pathType: Prefix - # Realtime service. An empty host serves it on ingress.app.host under /socket.io, which is where - # browsers connect when app.env.NEXT_PUBLIC_SOCKET_URL is empty. To use a separate hostname, set - # host (paths may then be /); unless NEXT_PUBLIC_SOCKET_URL is set (app.env, app.envDefaults, - # extraEnvVars, or externalSecrets.remoteRefs.app), the chart points the app at - # http(s)://, https when ingress.tls.enabled or NEXT_PUBLIC_APP_URL is https (a URL only - # externalSecrets supplies can't be read: with TLS terminated in front of the ingress, set - # NEXT_PUBLIC_SOCKET_URL). In app.secrets.existingSecret mode the chart never derives it, so set - # NEXT_PUBLIC_SOCKET_URL in that Secret (or app.env). On the app host a "/" path fails the render: - # it would route every app request to realtime. The pre-1.20.0 placeholder host sim-ws.local - # counts as the app host, and its old "/" path as /socket.io. + # Realtime. An empty host serves it on ingress.app.host under /socket.io (a "/" path there fails + # the render). With a separate host the chart sets NEXT_PUBLIC_SOCKET_URL=http(s):// unless + # you set it; set it yourself in existingSecret mode, or when TLS terminates before the ingress and + # NEXT_PUBLIC_APP_URL comes only from External Secrets. realtime: host: "" paths: From aa3c62579be13031cb222ff51a3fa3f10fa3ba05 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Fri, 4 Dec 2026 14:31:33 -0800 Subject: [PATCH 4/4] fix(helm): grant Marketplace S3 access to the named upload buckets only --- .../aws-marketplace-prerequisites.yaml | 42 ++++++++++++++----- helm/sim/examples/values-aws-marketplace.yaml | 6 +-- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/helm/sim/examples/aws-marketplace-prerequisites.yaml b/helm/sim/examples/aws-marketplace-prerequisites.yaml index bbd4a387671..c3b4eb82e5a 100644 --- a/helm/sim/examples/aws-marketplace-prerequisites.yaml +++ b/helm/sim/examples/aws-marketplace-prerequisites.yaml @@ -3,7 +3,7 @@ Description: >- Prerequisites for Sim from the AWS Marketplace container listing: Amazon RDS for PostgreSQL 17 (pgvector), Amazon ElastiCache (Valkey) with TLS and an auth token, and the IAM role the Sim ServiceAccount assumes (IRSA) to check the Marketplace license in AWS License Manager and, with - UploadBucketPrefix, to use your S3 upload buckets. Deploy it + UploadBuckets, to use your S3 upload buckets. Deploy it in the region and VPC of your EKS cluster, then use its outputs in values.yaml and the two Kubernetes Secrets described in the listing's usage instructions. @@ -37,17 +37,19 @@ Parameters: Type: String Default: cache.m7g.large Description: ElastiCache node type. - UploadBucketPrefix: - Type: String + UploadBuckets: + Type: CommaDelimitedList Default: '' - AllowedPattern: '^$|^[a-z0-9][a-z0-9.-]{0,40}$' Description: >- - Name prefix of the S3 buckets you create for uploads (e.g. "sim" for sim-workspace-files, - sim-knowledge-base, ...). The license role is then granted read, write and multipart access - to -* buckets. Empty grants no S3 access. + Exact names of the S3 buckets you create for uploads, comma-separated without spaces + (S3_BUCKET_NAME and every S3_*_BUCKET_NAME in values.yaml). The license role is granted read, + write and multipart access to these buckets only. Empty grants no S3 access. Conditions: - GrantUploadBuckets: !Not [!Equals [!Ref UploadBucketPrefix, '']] + GrantUploadBuckets: !Not [!Equals [!Join ['', !Ref UploadBuckets], '']] + # Fn::Join takes only a literal delimiter, so each partition's ARN prefix is spelled out. + InChina: !Equals [!Ref AWS::Partition, aws-cn] + InGovCloud: !Equals [!Ref AWS::Partition, aws-us-gov] Resources: DatabaseSecurityGroup: @@ -184,7 +186,17 @@ Resources: Statement: - Effect: Allow Action: s3:ListBucket - Resource: !Sub 'arn:${AWS::Partition}:s3:::${UploadBucketPrefix}-*' + Resource: !Split + - ',' + - !Sub + - 'arn:${AWS::Partition}:s3:::${Names}' + - Names: !If + - InChina + - !Join [',arn:aws-cn:s3:::', !Ref UploadBuckets] + - !If + - InGovCloud + - !Join [',arn:aws-us-gov:s3:::', !Ref UploadBuckets] + - !Join [',arn:aws:s3:::', !Ref UploadBuckets] # Large uploads are multipart: Sim aborts and lists the parts of its own uploads. - Effect: Allow Action: @@ -193,7 +205,17 @@ Resources: - s3:DeleteObject - s3:AbortMultipartUpload - s3:ListMultipartUploadParts - Resource: !Sub 'arn:${AWS::Partition}:s3:::${UploadBucketPrefix}-*/*' + Resource: !Split + - ',' + - !Sub + - 'arn:${AWS::Partition}:s3:::${Names}/*' + - Names: !If + - InChina + - !Join ['/*,arn:aws-cn:s3:::', !Ref UploadBuckets] + - !If + - InGovCloud + - !Join ['/*,arn:aws-us-gov:s3:::', !Ref UploadBuckets] + - !Join ['/*,arn:aws:s3:::', !Ref UploadBuckets] - !Ref AWS::NoValue Outputs: diff --git a/helm/sim/examples/values-aws-marketplace.yaml b/helm/sim/examples/values-aws-marketplace.yaml index dd1e15eda24..d8d0573a4b0 100644 --- a/helm/sim/examples/values-aws-marketplace.yaml +++ b/helm/sim/examples/values-aws-marketplace.yaml @@ -23,9 +23,9 @@ # CloudFormation template creates both in your VPC. # 3. An IAM role for the ServiceAccount below that allows license-manager:CheckoutLicense and # the S3 actions on the upload buckets listed under app.env (the CloudFormation template -# creates it; set its UploadBucketPrefix parameter, e.g. "sim", to grant the S3 actions on -# -* buckets). License Manager must be set up in the account: open its console once, -# or run +# creates it; list those exact bucket names, comma-separated, in its UploadBuckets parameter +# to grant the S3 actions on them). License Manager must be set up in the account: open its +# console once, or run # aws iam create-service-linked-role --aws-service-name license-manager.amazonaws.com # 4. S3 buckets for uploads, in the region set below: one per name under app.env # (S3_BUCKET_NAME and the S3_*_BUCKET_NAME purpose buckets), e.g.