Skip to content

feat: integration of gateway api - #17

Open
jvlxz wants to merge 24 commits into
stagingfrom
feat/integrates-gw-api
Open

feat: integration of gateway api#17
jvlxz wants to merge 24 commits into
stagingfrom
feat/integrates-gw-api

Conversation

@jvlxz

@jvlxz jvlxz commented Jun 5, 2026

Copy link
Copy Markdown

Summary

Integrates Kubernetes Gateway API support into Yggdrasil.

This adds support for discovering and translating Gateway, HTTPRoute, GatewayClass, and ReferenceGrant resources into Envoy configuration, alongside existing Ingress support. It also introduces a source-agnostic route policy model shared by Ingress annotations, HTTPRoute annotations, and the new YggdrasilPolicy CRD.

Changes

  • Add Gateway API informers when gatewayClasses are configured, and skip them when the Gateway API CRDs are absent (no crash on clusters without them).
  • Convert valid HTTPRoute resources into Yggdrasil ingress-like routing config.
  • Support Gateway listener matching, hostnames, sectionName, and AllowedRoutes namespace policies.
  • Support cross-namespace TLS secret references through ReferenceGrant.
  • Add a shared RoutePolicy model (pkg/policy): Ingress/HTTPRoute annotations and the new YggdrasilPolicy CRD are parsed into one model; Envoy generation consumes RoutePolicy only, never raw annotations.
  • Add the YggdrasilPolicy CRD (yggdrasil.uswitch.com/v1alpha1) to attach policy to an HTTPRoute via targetRef, plus generated clients/informers/listers.
  • Honor HTTPRoute TLS precedence over Ingress, and drop a stale upstream SNI on clusters.
  • Add Gateway API source metadata in metrics with source_kind="HTTPRoute", while preserving the existing source_kind="Ingress" label.
  • Keep existing Ingress behavior unchanged.

Policy sources

Yggdrasil route behavior (timeouts, healthcheck, retry, upstream http version, weight, connection limits, sticky sessions) can come from three sources, all parsed into the shared RoutePolicy:

  • Ingress annotations (yggdrasil.uswitch.com/*) — unchanged legacy behavior.
  • HTTPRoute annotations (yggdrasil.uswitch.com/*) — used as a fallback when no YggdrasilPolicy targets the route.
  • YggdrasilPolicy CRD — preferred for HTTPRoutes. A policy targets a same-namespace HTTPRoute via spec.targetRef (group: gateway.networking.k8s.io, kind: HTTPRoute). When one exists, the HTTPRoute's own annotations are ignored for policy.

Parsing strictness differs by source, on purpose:

  • Annotations: an invalid individual value is skipped with a diagnostic; the rest of the source still applies (historical behavior).
  • YggdrasilPolicy: a malformed spec rejects the whole policy source, so partial application never happens.
  • If multiple YggdrasilPolicy objects target the same HTTPRoute, all are ignored and a diagnostic is emitted.

Policy conflict / precedence behavior

Conflicts are detected per host, per source kind, using a deterministic policy Signature() (weight is excluded — it is upstream weighting, not host policy; empty signatures are skipped).

  • Same source kind on the same host, divergent signatures (Ingress vs Ingress, or HTTPRoute vs HTTPRoute)

    • The conflicting hosts are dropped from those routes and surfaced as Gateway diagnostics ("same source kind policy conflict").
    • This resolution lives in the k8s conversion layer (resolvePolicyConflicts); Envoy translation does not duplicate it.
  • Ingress + HTTPRoute on the same host

    • They are merged into the same Envoy host/cluster (not treated as a conflict — different source kinds).
    • HTTPRoute-derived resources are applied after Ingress-derived resources, so HTTPRoute policy (and TLS cert) wins over Ingress on that host.

Note: for a Gateway API route, policy comes from the YggdrasilPolicy targeting the HTTPRoute (or, absent that, from the HTTPRoute's own annotations) — not from the Gateway metadata. A healthcheck-path set on the Gateway has no effect; set it on the YggdrasilPolicy/HTTPRoute instead.

@SoulKyu

SoulKyu commented Jun 8, 2026

Copy link
Copy Markdown
Member

@jvlxz tu peux documenter les nouvelles permissions necessaire pour les gateway api ?

D'autant plus, que yggdrasil crash si pas dispo :

informersSynced = append(informersSynced,
  gatewayClassInformer.HasSynced, gatewayInformer.HasSynced, httpRouteInformer.HasSynced,
  referenceGrantInformer.HasSynced, serviceInformer.HasSynced, namespaceInformer.HasSynced)

@SoulKyu

SoulKyu commented Jun 8, 2026

Copy link
Copy Markdown
Member

ConvertGatewayResources returning an err makes GetIngresses return nil, err — aborting the entire snapshot rebuild, including every healthy Ingress. One bad gateway object could stall reconciliation for everything.

@SoulKyu

SoulKyu commented Jun 8, 2026

Copy link
Copy Markdown
Member

Different source kinds are not treated as conflicting, so both are kept and their upstreams merged; ordering is implicit (sourcePriority sorts Ingress first). Which source's annotations/timeouts win is not explicit.

@SoulKyu

SoulKyu commented Jun 8, 2026

Copy link
Copy Markdown
Member

CertificateRefs[0] only — multi-cert listeners unsupported. Document the limitation.

@Aluxima

Aluxima commented Jun 24, 2026

Copy link
Copy Markdown
Member

Could you add the mention of gateway resources in README? Or possibly all at once in #18 with CRD examples?

@jvlxz
jvlxz force-pushed the feat/integrates-gw-api branch from 4fb7aae to dcf94fc Compare July 2, 2026 13:59
jvlxz and others added 14 commits July 2, 2026 16:48
feat: implement gateway upstream resolution precedence
The Ingress->SourceRoute rename accidentally changed RouteSource.Kind
from "Ingress" to "SourceRoute", altering the source_kind label on the
EnvoyUpstreamInfo gauge and breaking existing dashboards. The value is a
pure metric/log passthrough (only "HTTPRoute" is matched in logic), so
restoring the literal is behavior-neutral.
feat: YggdrasilPolicy CRD and shared RoutePolicy model
fix: skip gateway informers when Gateway API CRDs absent
fix: TLS precedence on shared hosts + upstream SNI regression
Initial OpenWiki init: quickstart plus architecture, routing-and-policy,
kubernetes-integration, envoy-generation, and configuration pages. Adds the
OpenWiki reference section to AGENTS.md.
@SoulKyu
SoulKyu force-pushed the feat/integrates-gw-api branch from 6bf63d7 to 7362f9e Compare July 6, 2026 09:00
docs: add OpenWiki documentation wiki
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants