Skip to content

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

Closed

Description

@inference-gateway-maintainer

Summary

The Gateway controller applies spec.server.port to the container port, both probes, the Service and the HTTPRoute backend, and spec.telemetry.metrics.port to the metrics container and Service port, but it never tells the gateway process about either value: no SERVER_PORT or TELEMETRY_METRICS_PORT env var is emitted anywhere in internal/ (internal/controller/gateway_controller.go L480-483 and L723-742 for the probes, L527-540 for the base env, L864-899 for the Service, L1553-1591 for the container ports). The gateway reads both from env with defaults 8080 and 9464 (ServerConfig.Port and TelemetryConfig.MetricsPort in inference-gateway/inference-gateway config/config.go), so any non-default value leaves the process listening on the default port while Kubernetes probes and routes traffic to the configured one. The README presents both as working settings (telemetry.metrics.port in the Quick Start and Minimal Gateway examples, "1024-65535 for server ports" under Configuration Validation, and the Port print column on kubectl get gateway). spec.server.tls has the same gap: the controller mounts a hardcoded Secret inference-gateway-tls at /app/tls (L377-391), ignores certificateRef / keyRef, and never sets SERVER_TLS_CERT_PATH / SERVER_TLS_KEY_PATH.

Steps to Reproduce

  1. In a namespace labeled inference-gateway.com/managed=true, apply a Gateway with one provider plus spec.server.port: 9000 and spec.telemetry: {enabled: true, metrics: {enabled: true, port: 9465}}.
  2. Inspect the generated Deployment: kubectl get deploy <name> -o jsonpath='{.spec.template.spec.containers[0]}'. Container ports are 9000 and 9465 and both probes target 9000, but the env contains only ENVIRONMENT, TELEMETRY_ENABLED, AUTH_ENABLED and the provider vars.
  3. Watch the pod (kubectl get pod -l app=<name> -w) and, from inside the cluster, run curl http://<name>:9465/metrics.

The same Deployment and Service shape was reproduced offline by calling GatewayReconciler.Reconcile against a controller-runtime fake client.

Expected Behavior

The controller emits SERVER_PORT from spec.server.port and TELEMETRY_METRICS_PORT from spec.telemetry.metrics.port (and the TLS path vars when spec.server.tls.enabled), so the gateway listens where the probes, Service and HTTPRoute point.

Actual Behavior

The gateway always listens on 8080 and serves metrics on 9464. With server.port: 9000 the liveness and readiness probes on 9000 fail, so the pod never becomes Ready and is restarted repeatedly. With metrics.port: 9465 the Service's metrics port targets a closed port and scraping fails.

Activity

  1. added
    bug
    on Oct 4, 2026
  2. edenreich commented on Oct 4, 2026

    @edenreich
    Contributor

    @claude can you work on this? use /ponytail:ponytail

  3. inference-gateway-maintainer commented on Oct 4, 2026

    @inference-gateway-maintainer
    ContributorAuthor

    Claude finished @edenreich's task in 7m 39s —— View job • fix/issue-271-20261004-1100 • [Create PR ➔](https://github.com/inference-gateway/operator/compare/main...fix/issue-271-20261004-1100?quick_pull=1&title=Issue%20%23271%3A%20Changes%20from%20Claude&body=This%20PR%20addresses%20issue%20%23271%0A%0AGenerated%20with%20%5BClaude%20Code%5D(https%3A%2F%2Fclaude.ai%2Fcode)


    Done

    • Track on roadmap board (project fix: Make deployment more configurable #8, now QA)
    • Read gateway controller env/TLS wiring (env names verified against inference-gateway config/config.go)
    • Emit SERVER_HOST / SERVER_PORT / TELEMETRY_METRICS_PORT / SERVER_TLS_CERT_PATH / SERVER_TLS_KEY_PATH
    • Honour spec.server.tls.certificateRef / keyRef instead of the hardcoded Secret
    • Tests (7 new specs, 176 total pass)
    • Commit + PR + docs follow-up

    What changed

    internal/controller/gateway_controller.go:

    • buildContainer now emits SERVER_PORT (from spec.server.port, default 8080) and SERVER_HOST (from spec.server.host, default 0.0.0.0 - the gateway's own default is loopback, unreachable from kubelet probes), plus TELEMETRY_METRICS_PORT when telemetry and metrics are enabled.
    • TLS: certificateRef / keyRef are each mounted from their own Secret (/app/tls/cert/<key>, /app/tls/key/<key>) and SERVER_TLS_CERT_PATH / SERVER_TLS_KEY_PATH point at them. With no refs set, behaviour is unchanged - the conventional inference-gateway-tls Secret at /app/tls.
    • Root-cause cleanup: port/metrics defaulting lived in three copies (container, container ports, Service). Now single helpers (gatewayServerPort, gatewayMetricsPort, metricsEnabled, serverTLSEnabled). That surfaced a second bug - buildContainerPorts returned early when spec.server was nil, so a Gateway with metrics enabled but no server block got no metrics container port while the Service exposed one. Fixed.

    No CRD/API change, so no regenerated manifests. task test (176 specs), task fmt, task vet, task lint all clean.

    Skipped: the hardcoded 8443 https container/Service port - not part of this issue, and spec.server.tls has no port field to drive it. Worth a separate ticket if you want it configurable.

    Docs follow-up filed: inference-gateway/docs#962.

    PR

    #279
    | Branch

  4. inference-gateway-releaser commented on Oct 4, 2026

    @inference-gateway-releaser
    Contributor

    🎉 This issue has been resolved in version 0.27.1 🎉

    The release is available on GitHub release

    Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugreleased

    Type

    Projects

    • Status
      Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions