Skip to content

fix(k8s): allow only the Ingress origins in Open WebUI - #5357

Merged
dan-petty merged 3 commits into
mainfrom
fix/5306-open-webui-cors-origins
Nov 13, 2026
Merged

dan-petty merged 3 commits into
mainfrom
fix/5306-open-webui-cors-origins

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

Open WebUI used its default CORS_ALLOW_ORIGIN of *: it allowed every origin for its API, with credentials, and for Socket.IO.

ConfigMap llm/open-webui-origins now holds the HTTPS origin of each host of Ingress llm/open-webui-ingress, under the placeholder domain. Application ingress renders it, and Open WebUI reads it through extraEnvFrom. The reference is not optional, so the pod never starts with the default.

host_patches also tests and replaces each ConfigMap data value that holds the placeholder, so deploy-stack sets the configured domain in the origins with the hosts. The Argo CD gate allows the placeholder only there. Without Argo CD, the llm stack applies the file before its charts. A k8s row check keeps the origins equal to the hosts.

A Helm value override on Application open-webui does not stay: each sync of cluster applies spec.sources from git.

Closes #5306

Change: openspec/changes/archive/2026-11-13-5306-open-webui-allows-every-cors-origin/

Open WebUI used its default CORS_ALLOW_ORIGIN of '*', so it allowed
every origin for its API, with credentials, and for Socket.IO.

ConfigMap llm/open-webui-origins now holds CORS_ALLOW_ORIGIN: the HTTPS
origin of each host of Ingress llm/open-webui-ingress, under the
placeholder domain. Application ingress renders it beside the Ingress,
and Open WebUI reads it through extraEnvFrom. The reference is not
optional, so the pod never starts with the default.

host_patches also tests and replaces each ConfigMap data value that
holds the placeholder, so deploy-stack sets the configured domain in
the origins with the hosts. The Argo CD gate allows the placeholder in
such a value only. Without Argo CD, the llm stack applies the file
before its charts. A check of the k8s row keeps the origins equal to
the Ingress hosts.

A Helm value override on Application open-webui does not stay: Argo
CD applies spec.sources from git at each sync of cluster.

Closes #5306
@dan-petty dan-petty added type/bug Type bug: the code does not do what it must scope/k8s Kubernetes commands, Helm charts, pods, services, and policies labels Nov 13, 2026
@dan-petty

dan-petty commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner Author

Review, render diff and steps for a person

Head: f7064d0f0cf3803ddf60630afadf38bbaa2b4167. The independent review found no defect in the code or the manifests. It added one commit, docs(k8s): stage ConfigMap placeholder values before a merge: step 1 of "When a pull request merges into main" in k8s/README.md did not name a new ConfigMap data value under the placeholder domain as a reason to stage with --argocd-revision, and this pull request is such a case.

Premise (upstream Open WebUI v0.11.4, the pinned image)

  • backend/open_webui/config.py: CORS_ALLOW_ORIGIN = os.getenv('CORS_ALLOW_ORIGIN', '*').split(';'). When the list is ['*'], it logs WARNING: CORS_ALLOW_ORIGIN IS SET TO '*' - NOT RECOMMENDED FOR PRODUCTION DEPLOYMENTS. Else it validates each origin and raises ValueError for an origin without an http or https scheme or without a host.
  • backend/open_webui/socket/main.py: SOCKETIO_CORS_ORIGINS = '*' if CORS_ALLOW_ORIGIN == ['*'] else CORS_ALLOW_ORIGIN, given to socketio.AsyncServer(cors_allowed_origins=...).
  • Live cluster, read only: StatefulSet llm/open-webui has no CORS_ALLOW_ORIGIN, and ConfigMap llm/open-webui-origins does not exist.

Deviation from acceptance criterion 1 (confirmed)

The issue asks for a Helm value override on Application open-webui. That Application has spec.sources, a list that the Application CRD gives no list type, so server-side apply of cluster replaces the full list from git and removes an override that kubectl patch sets. The fix uses the Kustomize patches of the single-source Application ingress, as the other hosts do. test_deploy_stack_on_argo_cd_sets_the_open_webui_origins_under_the_configured_domain shows that deploy-stack writes CORS_ALLOW_ORIGIN=https://chat.<configured domain> on Application ingress.

Render diff, origin/main against this branch

  • kubectl kustomize k8s/overlays/homelab/ingress (Application ingress): 1 new object, ConfigMap llm/open-webui-origins, with CORS_ALLOW_ORIGIN: https://chat.example.com;https://homelab.example.com and the labels app.kubernetes.io/name: open-webui and app.kubernetes.io/part-of: devops-cli-stack. The other 489 lines are the same.
  • helm template open-webui chart 18.3.0 with k8s/llm/values-open-webui.yaml (Application open-webui): 1 change. The container envFrom of StatefulSet llm/open-webui adds - configMapRef: {name: open-webui-origins} after the valkey-auth secretRef.
  • host_patches on each render: devops 1 patch on both, mattermost 1 on both, ingress 19 on main and 20 on the branch. The new patch targets ConfigMap llm/open-webui-origins. The other patches are the same.
  • k8s/argocd/apps and k8s/argocd/bootstrap have no change.

Restarts at the merge

  • The pod template of StatefulSet llm/open-webui changes, so the controller replaces pod open-webui-0 one time. No other workload changes. The new ConfigMap restarts nothing.
  • The pod is Pending now (Unschedulable: its volume is on a cordoned node). The StatefulSet uses OrderedReady, and its controller does not replace a pod that is not Running and Ready. Thus, when the pod schedules, it can start one time with the old template (every origin) and then the controller replaces it with the new template. To prevent that start, a person can delete the Pending pod after the merge, so that it comes back with the new template.
  • The configMapRef is not optional. If Application open-webui syncs before Application ingress, the container waits until the ConfigMap exists.

Steps for a person

  1. Before the merge, stage the origins: uv run devops k8s deploy-stack --stack infra --argocd-revision f7064d0f0cf3803ddf60630afadf38bbaa2b4167. Kustomize skips the ConfigMap patch until the ConfigMap exists. If nobody stages it, the ConfigMap holds the placeholder origins after the merge, and Socket.IO from the real host fails. Then run the same command without --argocd-revision, and then kubectl -n llm rollout restart statefulset/open-webui.
  2. After the merge, when the pod runs: the start log in Loki ({namespace="llm", container="open-webui"} |= "CORS_ALLOW_ORIGIN") has no IS SET TO '*' line, and kubectl -n llm get configmap open-webui-origins -o jsonpath='{.data.CORS_ALLOW_ORIGIN}' shows the two origins under the configured domain.
  3. After the merge: the chat page at https://chat.<domain> loads, and its Socket.IO connection opens with no is not an accepted origin line in the Open WebUI log.

Changed behavior

A browser at an origin that is not an Ingress host, such as the minikube NodePort URL or a port-forward to localhost, gets no Socket.IO connection. k8s/README.md and k8s/llm/values-open-webui.yaml record this.

Local checks on the head

  • uv run devops ci --check --only lint,format,domain,docs,k8s,constructs,test-tree,swallowed-failures,typecheck: all rows pass.
  • uv run devops ci test tests/k8s/test_k8s_argocd_overrides.py tests/k8s/test_k8s_argocd_gate.py tests/k8s/test_k8s_valkey_stack.py tests/commands/k8s/test_k8s.py tests/commands/k8s/test_k8s_devops_stack.py tests/invariants/test_k8s_argocd_apps.py tests/invariants/test_k8s_manifests.py tests/config: all pass.
  • Fail-to-pass: the builder's local uv run devops ci fail-to-pass --base origin/main exits 1. The changed tests and the new k8s gate case fail on the base and pass on the head. Cases of unchanged check modules also fail on the base, because the gate replay imports the head source (fix(ci): fail-to-pass gate replay imports the head source on the base #5353). The Fail-to-Pass Check run of this pull request is the record (devops pr evidence).

The merge steps of k8s/README.md named only the Ingress hosts and
the devops-cli-config example as reasons to stage the overrides with
--argocd-revision. A new or changed container environment value or
ConfigMap data value under the placeholder domain, such as the origins
of Open WebUI, also needs the overrides before the merge.
@dan-petty
dan-petty force-pushed the fix/5306-open-webui-cors-origins branch from b8d5777 to f7064d0 Compare November 13, 2026 04:32
@dan-petty

Copy link
Copy Markdown
Owner Author

Check results

Head commit: f7064d0f0cf3803ddf60630afadf38bbaa2b4167

Check Conclusion Link
Tests & Coverage success run
devops-cli success run
zizmor success run
trivy-config success run
CodeQL success run
Plan Check skipped run
Dependency Freshness skipped run
Tests on Main skipped run
Test Job Duration skipped run
Tests & Coverage (shard 3 of 4) success run
Tests & Coverage (shard 4 of 4) success run
Tests & Coverage (shard 2 of 4) success run
Design Tokens success run
Static Analysis success run
Changed-Test Independence success run
MCP Server Image success run
Service Image success run
Tests & Coverage (shard 1 of 4) success run
Runner Image success run
Analyze (actions) success run
Analyze (python) success run
Image Pins success run
Fail-to-Pass Check failure run
Semantic PR title success run

Skipped check: Plan Check
Skipped check: Dependency Freshness
Skipped check: Tests on Main
Skipped check: Test Job Duration

@dan-petty dan-petty closed this Nov 13, 2026
@dan-petty dan-petty reopened this Nov 13, 2026
@dan-petty
dan-petty marked this pull request as ready for review November 13, 2026 11:29
@dan-petty
dan-petty merged commit fdab229 into main Nov 13, 2026
44 of 45 checks passed
@dan-petty
dan-petty deleted the fix/5306-open-webui-cors-origins branch November 13, 2026 11:30
dan-petty added a commit that referenced this pull request Nov 13, 2026
Each event of a pull request starts its workflows in a new check suite,
and the REST check-runs API lists the latest run of a check in each
suite. The reader dropped only a cancelled run that a newer run
replaced, so the failed run of a push stayed beside the passed run of a
close and reopen. `devops pr ready` refused the head of #5357 on that
old failure, but the latest run of each check passed or was skipped, and
`gh pr checks` showed the check as passed.

The REST reader now keeps the latest run of each check, whatever its
conclusion. A check is a name and an app id. The time of a run is its
`started_at`, else its `completed_at`. A run with no time, and each run
at the latest time of its check, stays. A newer failure or cancel still
fails the check. `devops pr ready`, `devops pr check-readiness`, `devops
pr monitor` and the roadmap readiness rows read the same runs.

Closes #5383

Change:
`openspec/changes/archive/2026-11-13-5383-readiness-latest-check-run/`
dan-petty pushed a commit that referenced this pull request Nov 13, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.127.1](v0.127.0...v0.127.1)
(2026-11-13)


### Bug Fixes

* **ci:** alarm at 360 s, one P0 issue, shards by recorded time
([#5377](#5377))
([2abd6ff](2abd6ff))
* **github:** read the plan diff and the release files from the merge
base ([#5401](#5401))
([c54e14c](c54e14c))
* **infra:** turn off the Ansible color of every playbook run
([#5381](#5381))
([5bafb1a](5bafb1a)),
closes [#5352](#5352)
* install-tools --check passes an older openspec binary
([#5355](#5355))
([625c89d](625c89d))
* **k8s:** allow only the Ingress origins in Open WebUI
([#5357](#5357))
([fdab229](fdab229))
* **pr:** count only the latest run of each check
([#5393](#5393))
([634dc91](634dc91))
* **review:** drop the fixed gateway URL of the review dry run
([#5399](#5399))
([0666d3d](0666d3d))
* **review:** review a pull request at the merge base of its base branch
([#5387](#5387))
([351ba2a](351ba2a)),
closes [#5346](#5346)
* **roadmap:** end fix-plan at a time budget with a result line
([#5380](#5380))
([20468f4](20468f4)),
closes [#5363](#5363)
* **roadmap:** refine skips an item that changed during the write
([#5392](#5392))
([a863dda](a863dda))
* **roadmap:** stage writes RENAMED and REMOVED spec deltas
([#5367](#5367))
([4abbbd2](4abbbd2))
* **roadmap:** title the delivery by the summary of its plan
([#5376](#5376))
([10e1069](10e1069))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/k8s Kubernetes commands, Helm charts, pods, services, and policies type/bug Type bug: the code does not do what it must

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(k8s): Open WebUI allows every CORS origin

1 participant