Skip to content

fix(gateway): pass server and metrics ports to container - #279

Merged
edenreich merged 2 commits into
mainfrom
fix/issue-271-20261004-1100
Oct 4, 2026
Merged

edenreich merged 2 commits into
mainfrom
fix/issue-271-20261004-1100

Conversation

@inference-gateway-maintainer

Copy link
Copy Markdown
Contributor

Summary

spec.server.* and spec.telemetry.metrics.port shaped the Deployment ports, probes, Service and HTTPRoute but were never passed to the gateway process, so a non-default port left it listening on 8080/9464 while Kubernetes probed and routed to the configured port. buildContainer now emits the env vars the gateway actually reads (verified against ServerConfig/TelemetryConfig in inference-gateway/inference-gateway config/config.go):

  • SERVER_PORT from spec.server.port (default 8080) - always emitted.
  • SERVER_HOST from spec.server.host (default 0.0.0.0) - the gateway's own default is loopback, which kubelet probes cannot reach.
  • TELEMETRY_METRICS_PORT from spec.telemetry.metrics.port (default 9464) when telemetry and metrics are enabled.
  • SERVER_TLS_CERT_PATH / SERVER_TLS_KEY_PATH when spec.server.tls.enabled.

spec.server.tls.certificateRef / keyRef are now honoured instead of ignored: each reference is mounted from its own Secret (/app/tls/cert/<key>, /app/tls/key/<key>) and the path env vars point at it. With no references set the behaviour is unchanged - the conventional inference-gateway-tls Secret at /app/tls with tls.crt/tls.key.

Also fixed along the way: buildContainerPorts returned early when spec.server was nil, so a Gateway with metrics enabled but no server block got no metrics container port even though the Service exposed one. Port and metrics-port resolution now lives in single helpers (gatewayServerPort, gatewayMetricsPort, metricsEnabled) shared by the container, the container ports and the Service, replacing three copies of the same default logic.

No CRD or API change, so no regenerated manifests.

Testing

  • task test - 176 specs pass (7 new specs covering port/host/metrics env, TLS paths with and without refs, and the disabled cases).
  • task fmt, task vet, task lint - clean.

Downstream impact

None outside this repo: the env var names already exist in the gateway, no new configuration surface is added. Users who relied on the undocumented hardcoded inference-gateway-tls Secret are unaffected - that path is the fallback when certificateRef/keyRef are unset.

Closes #271

@edenreich

Copy link
Copy Markdown
Contributor

@claude can you resolve the merge conflict?

@inference-gateway-maintainer

inference-gateway-maintainer Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor Author

Claude finished @edenreich's task in 3m 58s —— View job


Merge conflict resolved

  • Inspect conflict against origin/main
  • Resolve locally
  • Run tests
  • Push merge commit

The only conflict was in internal/controller/gateway_controller_test.go: this branch appends Describe("Gateway server and telemetry configuration") at the end of the file, while #278 on main appended Describe("Gateway providers summary") at the same spot. Both blocks are kept - the new Describe from main now follows this branch's block. gateway_controller.go auto-merged cleanly (main's change is in updateProvidersSummary, which this PR does not touch).

task test - all pass (internal/controller 68.7% coverage, 178 specs), go vet clean. PR is now MERGEABLE (merge commit f4bef93).
| branch fix/issue-271-20261004-1100

@edenreich
edenreich merged commit d3e3915 into main Oct 4, 2026
1 check passed
@edenreich
edenreich deleted the fix/issue-271-20261004-1100 branch October 4, 2026 11:35
inference-gateway-releaser Bot added a commit that referenced this pull request Oct 4, 2026
## [0.27.1](v0.27.0...v0.27.1) (2026-10-04)

### ♻️ Improvements

* bump go toolchain to 1.26.8 ([#282](#282)) ([949858a](949858a))

### 🐛 Bug Fixes

* **gateway:** pass server and metrics ports to container ([#279](#279)) ([d3e3915](d3e3915))
* **gateway:** skip providers without an env block ([#278](#278)) ([b069167](b069167))

### 📚 Documentation

* **agents:** add code readability guidelines ([#275](#275)) ([6b6a444](6b6a444))
* correct gateway auth and tracing claims ([#276](#276)) ([9f79f76](9f79f76))
* fix gateway label selector and orchestrator snippets ([#280](#280)) ([bb93ed2](bb93ed2))
* **readme:** document gateway spec.a2a support ([#277](#277)) ([aad725c](aad725c))
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.27.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Oct 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Gateway spec.server.port and telemetry.metrics.port never reach the gateway container

1 participant