Skip to content

[BUG] Gateway spec.service.type and spec.service.annotations are ignored #254

Closed

Description

Summary

The README advertises Gateway Service configuration with ClusterIP, NodePort and LoadBalancer types (README.md L149), and the Gateway CRD exposes spec.service.type (enum ClusterIP, NodePort, LoadBalancer, ExternalName) and spec.service.annotations (api/v1alpha1/gateway_types.go L562-580). However, reconcileService in internal/controller/gateway_controller.go (L821-910) builds the Service from only selector and ports, never reads Spec.Service.Type or Spec.Service.Annotations, and its update path only compares ports and selector. Both fields have no effect. For example, the service.beta.kubernetes.io/aws-load-balancer-type: "nlb" annotation in config/samples/core_v1alpha1_gateway_hpa.yaml is never applied. Only spec.service.port is honored.

Steps to Reproduce

  1. Create a namespace labeled inference-gateway.com/managed=true (required by the operator's default WATCH_NAMESPACE_SELECTOR).
  2. Apply a Gateway in that namespace with spec.service.type: LoadBalancer and spec.service.annotations set to example.com/test: "true".
  3. After reconciliation, run kubectl get service <gateway-name> -n <namespace> -o yaml.
  4. Change spec.service.type to NodePort and inspect the Service again.

Expected Behavior

The Service has type: LoadBalancer (then NodePort after the change) and carries the example.com/test: "true" annotation, as described by the README Networking section and the CRD.

Actual Behavior

The operator creates the Service without a type or annotations, so the API server defaults it to ClusterIP and no annotations are set. Later changes to spec.service.type or spec.service.annotations never update the Service, because reconcileService only diffs ports and selector.

Activity

  1. edenreich commented on Sep 25, 2026

    @edenreich
    Contributor

    @claude can you work on this?

  2. inference-gateway-maintainer commented on Sep 25, 2026

    @inference-gateway-maintainer
    ContributorAuthor

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


    Done - PR opened

    • Read reconcileService and ServiceSpec
    • Apply spec.service.type + spec.service.annotations to the Service
    • Handle update drift (type + annotations) without fighting API-server defaults
    • Add controller tests
    • Verify (go vet, logic exercised against the fake client)
    • Commit + open PR (#260)

    What changed

    internal/controller/gateway_controller.go - reconcileService:

    • Desired Service now carries Spec.Type from spec.service.type (defaulting to ClusterIP) and metadata.annotations from spec.service.annotations.
    • The update path diffs type and annotations in addition to ports/selector, so later spec changes reach the live Service.
    • Two follow-on correctness bits that the naive fix would have broken: the API-server-assigned nodePorts are preserved while the type still exposes them (otherwise a NodePort/LoadBalancer Service would be rewritten on every reconcile), and the existing clusterIP is no longer copied when the type is ExternalName.

    Annotations are authoritative on this operator-owned Service, matching the existing upstream Gateway/HTTPRoute reconciler at gateway_controller.go:1116 - removing a key from the spec removes it from the Service.

    internal/controller/gateway_controller_test.go - new Gateway service configuration specs: type + annotations on create, the ClusterIP default when spec.service is nil, type/annotation updates (including removal of a stale key), and nodePort preservation.

    Only internal/controller changed - no CRD/API edits, so no task generate/task manifests output to commit.

    Verification caveat

    task and the envtest/Ginkgo binaries are not available in this runner, so I could not run task test or task lint. I ran go vet ./internal/controller/ ./api/... (clean) and exercised the exact reconcileService paths through the fake client in a throwaway standalone test, which passed for all four behaviors above before I removed it in favour of the Ginkgo specs. CI should run the real suite.

    Also filed inference-gateway/docs#791 so the docs note these fields actually work and from which operator version.
    | Branch

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

    @inference-gateway-releaser
    Contributor

    🎉 This issue has been resolved in version 0.27.0 🎉

    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

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions