Skip to content

k8s: Traefik CRD codegen (IngressRoute, Middleware, and the traefik.io proxy surface) #1320

Closed

Description

@lex00

Part of #1318 · one of four CRD gaps blocking a Fountain production deployment.

Repo/where. INTENTIUS/chant, k8s lexicon at lexicons/k8s/. Design rule: spec-true — type the real upstream API.

Goal. Code-generate typed Traefik proxy CRDs through the existing CRD codegen pipeline.

Why

Traefik is one of the two or three ingress controllers people actually run, and its IngressRoute is not a networking.k8s.io Ingress — it is a distinct CRD with its own matcher grammar. chant can express an Ingress today and cannot express a Traefik route at all, so any estate fronted by Traefik has an unmodellable edge.

BinaryBourbon/fountain's k8s/ingressroute.yaml is the concrete case: two IngressRoute objects, one on the websecure entrypoint with tls.secretName, one on web that references a cross-namespace redirect-https middleware:

routes:
  - match: "Host(`fountain.inevitable.fyi`)"
    kind: Rule
    middlewares:
      - name: redirect-https
        namespace: default
    services:
      - name: fountain
        port: 80

The cross-namespace middleware ref is the part worth typing — it is easy to get wrong by hand and invisible until traffic hits it.

Scope — traefik.io only

The Traefik helm chart's crds/ directory also ships hub.traefik.io_* (Traefik Hub, the commercial control plane) and a vendored copy of the Gateway API. Take neither:

  • hub.traefik.io_* is a different product, ~12 kinds, no known consumer.
  • Gateway API is already generated from the upstream repo (GATEWAY_API_CRD_BASE); a second copy would collide.

Take the nine traefik.io_* kinds: IngressRoute, IngressRouteTCP, IngressRouteUDP, Middleware, MiddlewareTCP, ServersTransport, ServersTransportTCP, TLSOption, TLSStore, TraefikService. That is the whole proxy surface and it is bounded — this is the "add the specific kinds a project uses, or scope by resource group; never point at an operator's entire CRD bundle" rule from crd-sources.ts applied literally.

Files to touch

  • lexicons/k8s/src/crd/crd-sources.ts — add a TRAEFIK_CHART_VERSION const, a TRAEFIK_CRD_BASE, a doc comment listing the kinds and the install command, and one CRD_SOURCES entry per traefik.io_* file.
  • lexicons/k8s/src/crd/parser.ts — no override needed. The first-segment rule maps traefik.io → Traefik, which is already what we want (K8s::Traefik::IngressRoute). Confirm rather than assume.

Verified source

https://raw.githubusercontent.com/traefik/traefik-helm-chart/v34.1.0/traefik/crds/traefik.io_ingressroutes.yaml returns 200; the sibling traefik.io_*.yaml files are in the same directory.

Chart v34.1.0 is verified above; latest is v41.1.0. Pin deliberately and record which Traefik minor it corresponds to — the chart version and the proxy version are not the same number, which is a footgun worth a comment.

Steps

  1. Add the version const + base URL with the doc comment.
  2. Add the nine entries to CRD_SOURCES.
  3. From lexicons/k8s/: npm run generate, then npm run build -w @intentius/chant-lexicon-k8s.

Definition of done

  • K8s::Traefik::IngressRoute and ::Middleware import from the generated barrel and serialize to valid YAML.
  • Fountain's k8s/ingressroute.yaml — both routes, the tls.secretName, and the cross-namespace middleware ref — is reproducible from typed chant source.
  • Chart version recorded in crd-sources.ts with the install command.
  • npm run generate && npm run build -w @intentius/chant-lexicon-k8s clean; codegen tests pass.

Notes

  • fix(k8s): CRD-generated classes have no metadata when the schema declares only spec #1309 does not block this. IngressRoute and Middleware declare metadata at the top level of their schemas (verified).
  • The match field is a Traefik matcher expression in a string. Typing it as a string is spec-true and correct; a parser for the matcher grammar would be a separate, much larger conversation.
  • src/generated/** is generator output — never hand-edit.

Activity

  1. added
    enhancement
    needs-review
    on Aug 2, 2026
  2. lex00 commented on Aug 3, 2026

    @lex00
    ContributorAuthor

    Pin decided: traefik-helm-chart v37.1.2 (verified 200). Traefik v3 CRDs.

    Scope stays the nine traefik.io_* kinds. Not hub.traefik.io_* (different product, commercial) and not the chart's vendored Gateway API copy — that group is already generated from upstream and a second copy would collide.

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

    enhancementneeds-review

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions