Skip to content

[FEATURE] Pod labels, annotations and scheduling for Gateway, Agent and MCP workloads #308

Description

@edenreich

Summary

The workload CRDs give no way to shape the pods the operator creates. Gateway, Agent and MCP have no fields for pod labels, pod annotations, nodeSelector, tolerations or affinity. The only annotations in the API are Gateway.spec.service.annotations, which land on the Service, not the pods. A pod gets exactly the app: <name> label the controller sets, and nothing else can be added.

This blocks common integrations:

  • Sidecar injection keyed on pod labels or annotations, such as Istio (sidecar.istio.io/inject), Linkerd (linkerd.io/inject) or the NetBird Kubernetes operator's SidecarProfile.podSelector. NetBird works today only because the selector can reuse app: <name>. Anything that needs its own label or an annotation cannot opt in.
  • Scheduling: pinning a gateway to a node pool, tolerating a taint (for example a GPU or edge pool), or spreading replicas with affinity.

Found while building examples/kubernetes-session-teleport-netbird in inference-gateway/cli (inference-gateway/cli#1671). There, a Gateway is a NetBird peer through an injected sidecar, and its pod could not be pinned to a node like the other workloads in the example.

Proposed shape, the same on every workload CRD:

spec:
  pod:
    labels:
      sidecar.example.com/inject: "true"
    annotations:
      linkerd.io/inject: enabled
    nodeSelector:
      kubernetes.io/hostname: worker-0
    tolerations:
      - key: gpu
        operator: Exists
        effect: NoSchedule
    affinity: {}

Acceptance Criteria

  • Gateway, Agent and MCP accept spec.pod.labels and spec.pod.annotations, applied to the pod template of the Deployment each creates
  • User labels never replace the operator's own app: <name> label, so the Deployment selector and Services keep working
  • spec.pod.nodeSelector, spec.pod.tolerations and spec.pod.affinity pass through to the pod spec unchanged
  • Changing any spec.pod field rolls the Deployment, and removing a field removes it from the pod template
  • Controller tests cover each field, and the README documents spec.pod with an example

Activity

  1. added
    enhancement
    on Oct 31, 2026
  2. moved this to Todo in 2026on Oct 31, 2026
  3. edenreich commented on Oct 31, 2026

    @edenreich
    ContributorAuthor

    @claude can you work on this? use /ponytail:ponytail /domain-driven-design /clean-architecture /clean-code /go /go-concurrency

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

    @inference-gateway-maintainer
    Contributor

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


    spec.pod for Gateway, Agent and MCP - done

    • Read the three controllers and API types
    • Add shared PodSpec type + spec.pod on Gateway/Agent/MCP
    • Apply labels/annotations/nodeSelector/tolerations/affinity to the pod templates
    • Regenerate deepcopy, CRDs and manifests/
    • Controller tests covering every field across all three CRDs
    • README documents spec.pod with an example
    • task fmt, go vet, task lint (0 issues), task test - all pass
    • PR opened: feat(api): add spec.pod to Gateway, Agent and MCP workloads #309

    What changed

    One new API type carries the whole feature: PodSpec in api/v1alpha1/pod_types.go with labels, annotations, nodeSelector, tolerations, affinity, plus an ApplyTo(*corev1.PodTemplateSpec) method. Each workload CRD gained Pod *PodSpec (spec.pod), and each builder calls ApplyTo on the template it just built - gateway_controller.go, agent_controller.go, mcp_controller.go, one line each.

    Operator-owned labels and annotations win on a key conflict, so app: <name> can never be replaced and the Deployment selector plus Services keep working. All three controllers already replace the whole pod template on update, so changing a spec.pod field rolls the Deployment and removing one drops it - no extra code needed.

    Tests live in internal/controller/pod_spec_test.go: a table over the Gateway/Agent/MCP builders asserting every field passes through and the app label survives a hijack attempt, plus the unset case where nothing is added.

    Also filed inference-gateway/docs#1059 for the user-facing docs.

    Not done / risk

    I did not add spec.pod to Orchestrator or GPU - the issue scoped it to the three workload CRDs, and the orchestrator builds its pod template differently (it already sets its own pod annotations and has a sandbox path). Easy follow-up if wanted. Only the pod template is touched, so spec.pod.labels do not reach the Deployment's own metadata labels or the Service selector, which is what the acceptance criteria asked for. The focused Ginkgo run needed envtest assets I could not pass inline in this sandbox, so the new specs were verified through the full task test run rather than in isolation.
    | Branch | PR #309

  5. moved this from Todo to In progress in 2026on Oct 31, 2026
  6. moved this from In progress to QA in 2026on Oct 31, 2026
  7. inference-gateway-releaser commented on Oct 31, 2026

    @inference-gateway-releaser
    Contributor

    🎉 This issue has been resolved in version 0.30.0 🎉

    The release is available on GitHub release

    Your semantic-release bot 📦🚀

  8. moved this from QA to Done in 2026on Oct 31, 2026
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

    enhancementreleased

    Projects

    • Status
      Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions