Repository navigation
feat(orchestrator): link a Gateway and park it while suspended - #307
Merged
Merged
Conversation
Co-authored-by: Eden Reich <[email protected]>
inference-gateway-maintainer
Bot
requested a review
from a team
as a code owner
October 31, 2026 20:11
This was referenced Oct 31, 2026
edenreich
reviewed
Oct 31, 2026
Contributor
|
🎉 This PR is included in version 0.29.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
6 tasks done
edenreich
added a commit
to inference-gateway/cli
that referenced
this pull request
Oct 31, 2026
…y ref (#1670) ## Summary A `standard` Kubernetes workspace now links every session Orchestrator to its Gateway with `spec.gateway.ref` instead of a `spec.gateway.url` with a hard-coded port. The operator derives the daemon's `INFER_GATEWAY_URL` from the Gateway's Service, and it runs the Gateway with no pod while every Orchestrator referencing it is suspended. An idle workspace now keeps no gateway pod, while its Gateway, Deployment and credentials Secret stay. Requires operator v0.29.0 or later (inference-gateway/operator#307). Closes #1669 ## Changes - `internal/agent/infrastructure/kubernetes/gateway.go` - `orchestratorGateway` returns `{ref: <workspace gateway>}` in `standard` mode with `gateway_env`, and `{url: http://127.0.0.1:8080}` in `all-in-one` mode, unchanged. `gatewayURL`, `gatewayPort` and the ponytail note about idle gateway cost are gone. - The Gateway spec no longer sets `server.port`. The operator's default (8080) applies, and it addresses the Service on that port. - `internal/agent/infrastructure/kubernetes/workspace.go` - `reach` waits for the workspace gateway on every reach, not only on create. A turn or a teleport home that resumes a parked session waits for the gateway, because the operator scales it up at the same time as the resume but does not hold the Orchestrator's `Ready` for it. - `minOperatorVersion` is `v0.29.0`. Strict field validation makes an older operator refuse `spec.gateway.ref`, and the error now says the operator may predate that version. - Docs: `docs/daemon.md` (operator requirement and parking), the session-teleport README's cloud section, and the example's `OPERATOR_VERSION`. ## Out of scope - Orchestrators that rc.9 created with `spec.gateway.url` keep it. The operator does not count them as referencing the Gateway, so a mix of old and new sessions on one workspace could park the Gateway under a running old session. Stop those sessions or delete their Orchestrators by hand. - `task chat` in the example sets `INFER_AGENT_MODEL=mock/openai/gpt-4o`, so reattaching a `k8s-cloud` session with it fails with `model ... not available`. This predates the change. Set `INFER_AGENT_MODEL` to the workspace's model to chat there. ## Test plan - [x] `go test -race` for `internal/agent/...`, `internal/sessions/...` and `cmd/daemon/...` - [x] `TestReachWaitsForAParkedGateway` fails (nil TLS provider panic after skipping the wait) with the old `create &&` guard and passes with the change - [x] `task precommit:run` - [x] k3d `infer-workspaces` with operator v0.29.0: teleport to `k8s-cloud`. The Orchestrator has `spec.gateway: {ref: infer-gateway-ad2f918bfc2f}`, and the pod's `INFER_GATEWAY_URL` is `http://infer-gateway-ad2f918bfc2f.infer-workspaces.svc.cluster.local:8080` with no provider key in its env - [x] Suspending the session's Orchestrator (the same `operatingMode: Suspended` change the operator makes once the pod idles out) scales the gateway Deployment to `0/0` with no pod. The Gateway and its credentials Secret stay - [x] Reattaching the session from `infer chat --daemon --session-id` resumes the Orchestrator, the gateway comes back to `1/1`, and a turn on `ollama_cloud/glm-5.3-flash` answers from the pod through it
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Orchestrator.spec.gatewaynow takesref- the name of aGatewayin the same namespace - as an alternative tourl(one or the other, enforced by CEL). The link does two things:INFER_GATEWAY_URLfrom that Gateway's Service (scheme fromspec.server.tls, port fromspec.service.port/spec.server.port), so nobody hard-codes the gateway's port. The Orchestrator stored in the cluster keeps its spec - the address is resolved per reconcile.spec.sandbox.operatingMode: Suspended), and goes back tospec.replicasas soon as one resumes. The Gateway controller now watches Orchestrators, so the same event that resumes a Sandbox scales the Gateway back up.A parked Gateway also has no HPA for as long as it is parked, since an HPA would scale the parked Deployment straight back up -
reconcileHPAtreats parked as disabled and recreates the HPA when the Gateway is unparked. Nothing is deleted: Deployment, Service and Secrets stay. A Gateway that no Orchestrator references is never parked, so itsspec.replicasand HPA behave exactly as before. An Orchestrator whoserefnames no Gateway reportsReady=Falsewith reasonGatewayNotFound.While there, the Deployment update path stopped recomputing the replica count from the spec and now follows the count the builder put on the desired Deployment, which keeps one rule for parked / HPA /
spec.replicasinstead of two copies.Acceptance criteria
Readyon the Gateway's readiness - see the risk note below.spec.replicasand HPA behavior unchanged (covered by a test).operatingModebullet, andconfig/samples/core_v1alpha1_orchestrator_sandbox.yamlswitched toref.Tests
task test(envtest, 227+ specs) andtask lintare green. New specs cover parking across suspended/running/unreferenced Orchestrators, the replica count for parked + HPA combinations, the HPA being removed while parked, the Orchestrator-to-Gateway mapper, and the URL derived fromref(including the missing-Gateway error).What I skipped
refis the issue's primary shape, and it does not tie the Gateway's lifetime to one session.kubectl get orchalready shows which Orchestrators are suspended.Readyuntil the Gateway has an available replica, so a daemon that calls the gateway in its first instant could still race a cold gateway pod. Say the word and I will gate the Orchestrator's readiness on the linked Gateway'sstatus.availableReplicas.Downstream impact
inference-gateway/cli: theinferCLI can drop the hard-codedINFER_GATEWAY_URLport and setspec.gateway.refon the Orchestrators it creates per workspace session - that is what turns the scale-to-zero on.inference-gateway/docs:[DOCS]issue filed for the Orchestrator page.Closes #305