Skip to content

[FEATURE] Gateway CRD: mutual TLS - server client CA and outbound client certificates #311

Closed

Description

@inference-gateway-maintainer

Summary

The gateway gained mutual TLS in both directions (inference-gateway/inference-gateway#818, closes inference-gateway/inference-gateway#817), but a Gateway custom resource cannot express it, so the mTLS example in that PR has to ship a plain Deployment.

New gateway settings:

Variable Direction What it does
SERVER_TLS_CLIENT_CA_PATH inbound requires and verifies a client certificate signed by that bundle (tls.RequireAndVerifyClientCert)
CLIENT_TLS_CA_PATH outbound extra CA trusted on top of the system roots when calling providers
CLIENT_TLS_CERT_PATH / CLIENT_TLS_KEY_PATH outbound the certificate the gateway presents to a provider that requires mTLS

SERVER_TLS_CERT_PATH / SERVER_TLS_KEY_PATH and CLIENT_TLS_MIN_VERSION already exist and are covered by spec.server.tls.

What is missing in the CRD

  1. spec.server.tls.clientCARef (a SecretKeySelector, like certificateRef/keyRef): mounted, and SERVER_TLS_CLIENT_CA_PATH set from it. cert-manager already writes ca.crt into the same Secret as the server keypair, so in practice this is one more key from one Secret.
  2. An outbound block - spec.client.tls (or spec.providers.tls) with caRef, certificateRef and keyRef - mounted, and CLIENT_TLS_CA_PATH / CLIENT_TLS_CERT_PATH / CLIENT_TLS_KEY_PATH set from it. Needed for any provider or in-cluster proxy that requires a client certificate, and for a private CA in front of a provider.
  3. Health probes have to work while the server demands a client certificate. [BUG] Gateway with spec.server.tls never becomes Ready: probes stay HTTP on the TLS port #310 already covers scheme: HTTPS, but scheme: HTTPS alone is not enough once clientCARef is set: the kubelet cannot present a client certificate, so an httpGet probe fails the handshake no matter the scheme. Options: a tcpSocket probe when a client CA is configured (what the example does), an exec probe running curl with the certificate, or a plain-HTTP health listener. Worth deciding together with [BUG] Gateway with spec.server.tls never becomes Ready: probes stay HTTP on the TLS port #310.

Context

Activity

  1. edenreich commented on Nov 1, 2026

    @edenreich
    Contributor

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

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

    @inference-gateway-maintainer
    ContributorAuthor

    Claude finished @edenreich's task in 6m 58s —— View job • feat/issue-311-20261101-1306 • Create PR ➔


    Done - PR #313 is open

    • Read current spec.server.tls handling in the Gateway reconciler
    • Add clientCARef + outbound spec.client.tls to the API types
    • Mount the secrets and set the four env vars
    • Probe behavior under inbound mTLS: tcpSocket
    • Regenerate deepcopy, CRDs and manifests/
    • Tests + task test / task lint / task vet
    • Open PR, docs ticket and downstream tracking issue

    What it does

    Inbound - spec.server.tls.clientCARef (a SecretKeySelector, same shape as certificateRef/keyRef) mounts at /app/tls/client-ca/<key> and sets SERVER_TLS_CLIENT_CA_PATH. With cert-manager this is just one more key (ca.crt) off the Secret already holding the server keypair.

    Outbound - new spec.client.tls with caRef, certificateRef, keyRef, mounted under /app/tls/client/{ca,cert,key}/<key> and emitted as CLIENT_TLS_CA_PATH / CLIENT_TLS_CERT_PATH / CLIENT_TLS_KEY_PATH. Each reference is independent, so a private provider CA works without a client certificate. Put it under its own spec.client block rather than spec.providers.tls (that one is a list) - it also leaves the obvious home for CLIENT_TLS_MIN_VERSION later.

    Probes (point 3) - when clientCARef is set, liveness and readiness switch to tcpSocket on the server port. scheme: HTTPS from #312 is not enough there: the kubelet has no client certificate, so the handshake fails whatever the scheme. The plain server-TLS path from #312 is untouched.

    Implementation is small: secretKeyVolumes factored out of the existing tlsVolumes closure and reused for the client block, plus serverMTLSEnabled and clientTLSEnv. Three new specs cover the client CA mount/env/TCP probe, the spec.client.tls mounts/env, and the absence of CLIENT_TLS_ when unset.

    Follow-ups filed

    Skipped

    No example manifest in this repo (the mTLS example lives in the gateway repo, tracked above) and no validation webhook rejecting a cert without a key - the gateway already errors on that at startup. I did not run this against a real cluster with cert-manager, so the end-to-end handshake is verified only by the generated Deployment, not by live traffic. If the gateway's health listener later moves off the mTLS port, the tcpSocket probe becomes weaker than it needs to be and should go back to httpGet.

    | Branch

  3. moved this from Todo to In progress in 2026on Nov 1, 2026
  4. added a commit that references this issue on Nov 1, 2026
    b10f329
  5. moved this from In progress to QA in 2026on Nov 1, 2026
  6. moved this from QA to Done in 2026on Nov 1, 2026
  7. inference-gateway-releaser commented on Nov 1, 2026

    @inference-gateway-releaser
    Contributor

    🎉 This issue has been resolved in version 0.31.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

    released

    Type

    No type

    Projects

    • Status
      Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions