Skip to content

[FEATURE] Sidecar containers and volumes in spec.pod for Gateway, Agent and MCP workloads #316

Description

@edenreich

Summary

The workload CRDs cannot add containers or volumes to the pods the operator creates. spec.pod (#308) covers labels, annotations and scheduling, which is enough when a webhook injects the sidecar, such as Istio, Linkerd or the NetBird operator. A VPN or proxy without an injector needs the sidecar in the pod spec itself, and there is no field for it.

Found while building examples/kubernetes-session-teleport-headscale in inference-gateway/cli (inference-gateway/cli#1665). Every tailnet pod there runs a tailscale/tailscale sidecar. Headscale ships no injector, and Tailscale's own Kubernetes operator needs the Tailscale API, which Headscale does not implement. So the Gateway cannot join the tailnet, and the example puts a separate tailscale proxy pod in front of the Gateway Service until this lands.

Proposed shape, the same on every workload CRD (Gateway, Agent, MCP):

spec:
  pod:
    containers:
      - name: tailscale
        image: tailscale/tailscale:v1.104.4
        env:
          - name: TS_AUTHKEY
            valueFrom:
              secretKeyRef:
                name: tailnet-key-gateway
                key: authkey
        securityContext:
          privileged: true
        volumeMounts:
          - name: tailnet-ca
            mountPath: /etc/tailnet-ca
            readOnly: true
    initContainers: []
    volumes:
      - name: tailnet-ca
        configMap:
          name: tailnet-ca

containers are appended after the operator's own container. initContainers allows native sidecars (restartPolicy: Always) and setup steps. volumes are added to the pod, so the extra containers can mount them.

Acceptance Criteria

  • Gateway, Agent and MCP accept spec.pod.containers, spec.pod.initContainers and spec.pod.volumes, applied to the pod template of the Deployment each creates
  • The operator's own container stays first and unchanged, and its volumes keep their names. A user container or volume whose name collides with an operator-owned one is rejected with a clear error (validation or a status condition)
  • Changing any of these fields rolls the Deployment, and removing an entry removes it from the pod template
  • Controller tests cover each field, including the name collision, and the README documents them with a sidecar example

Activity

  1. added
    enhancement
    on Nov 1, 2026
  2. added theissue type on Nov 1, 2026
  3. moved this to Todo in 2026on Nov 1, 2026
  4. edenreich commented on Nov 1, 2026

    @edenreich
    ContributorAuthor

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

  5. inference-gateway-maintainer commented on Nov 1, 2026

    @inference-gateway-maintainer
    Contributor

    Claude finished @edenreich's task in 10m 19s —— View job • feat/issue-316-20261101-2010


    Done - PR #317

    PodSpec was already shared by all three CRDs with a single ApplyTo call, so the feature went in once in api/v1alpha1/pod_types.go and Gateway, Agent and MCP all got it.

    • Read PodSpec.ApplyTo and the three Deployment builders
    • spec.pod.containers / initContainers / volumes added to PodSpec, appended in ApplyTo (operator container stays first and untouched, its volumes keep their names)
    • ValidatePodTemplateNames rejects a name the operator already owns, called from each reconcileDeployment before the Deployment is written - error reads spec.pod.containers: "inference-gateway" is already used by the operator
    • Regenerated deepcopy, CRDs and manifests/
    • internal/controller/pod_spec_test.go covers the three fields per workload, the unset case, and a container- and volume-name collision per CRD
    • README documents the fields with the Tailscale sidecar example
    • task lint clean, task test green (controller coverage 71.6%)

    Rolling and removal needed no code: all three controllers already replace the whole pod template when it differs from the live one.

    Two things worth your call:

    1. Manifest size. Embedding the Kubernetes container/volume schemas three times takes the Gateway CRD from 196 KB to 542 KB and manifests/install.yaml from 505 KB to 1.5 MB. Under the per-object etcd limit, but a client-side kubectl apply stores a second copy in last-applied-configuration, so --server-side is now the safe install path. The alternative (a schemaless, unvalidated field) would have thrown away all validation.
    2. AgentReconciler.reconcileDeployment now returns only error - its *Deployment result was never used and unparam flagged it once a test called the function.

    Filed alongside: inference-gateway/docs#1074 (docs) and inference-gateway/cli#1675 (the headscale example can drop its proxy pod once this is released). Board item moved to QA.

    Create a PR - already opened as #317.
    | branch

  6. moved this from Todo to In progress in 2026on Nov 1, 2026
  7. moved this from In progress to QA in 2026on Nov 1, 2026
  8. inference-gateway-releaser commented on Nov 1, 2026

    @inference-gateway-releaser
    Contributor

    🎉 This issue has been resolved in version 0.32.0 🎉

    The release is available on GitHub release

    Your semantic-release bot 📦🚀

  9. moved this from QA to Done in 2026on Nov 2, 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