Skip to content

feat(chart): Gateway API and ingress guides - #404

Merged
uniqueg merged 5 commits into
devfrom
feat/chart-gateway-api
Oct 22, 2026
Merged

uniqueg merged 5 commits into
devfrom
feat/chart-gateway-api

Conversation

@uniqueg

@uniqueg uniqueg commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes #397.

  • Gateway API: foca-common 0.2.0 renders an optional HTTPRoute (gateway.networking.k8s.io/v1) for hostName via <valuesKey>.httpRoute (enabled, annotations, parentRefs, filters), attached to an existing Gateway, routing all paths to the app's Service (same rule as the Ingress). With httpRoute.httpsRedirect, a second HTTPRoute (<app name>-https-redirect) on the Gateway's HTTP listener redirects to HTTPS (RequestRedirect, 301); rendering fails if its parentRefs may attach to the same listener as the app's route (which would redirect HTTPS requests, too). Value names follow helm create's httpRoute scaffold.
  • Mutual exclusivity: Ingress and HTTPRoute fail together with a clear message; the OpenShift Route is only created without either. The Route gains <valuesKey>.route.annotations (e.g., the router's rate limits).
  • Backwards compatible: existing values and app charts keep working (missing httpRoute/route maps are treated as disabled/empty); app charts add two template files to use the HTTPRoute. ingress-nginx stays supported with the same defaults.
  • Body size: the Gateway API has no standard for it, so the app's config.server.max_content_length stays the enforcing limit; the docs show implementation policies (Envoy Gateway BackendTrafficPolicy, NGINX Gateway Fabric ClientSettingsPolicy, Traefik Middleware via httpRoute.filters).
  • NetworkPolicy: peers were already generic (ingressFrom); the docs list values for ingress-nginx, Traefik (k3s), the OpenShift router, Envoy Gateway (verified in CI) and other Gateway implementations, plus ipBlock for cloud load balancers.
  • Docs: new section "Exposing the app" in docs/helm-chart.md with one subsection per setup (Gateway API, recommended; ingress-nginx, retired, with a migration note incl. ingress2gateway and a no-downtime switch; Traefik; OpenShift; cloud load balancers as pointers), each covering TLS/HTTPS redirect, body size, rate limits, NetworkPolicy peers and keep-alive timeouts (Gunicorn's 75 s vs. Traefik's 90 s and Envoy's 1 h idle timeouts); pointer from docs/deployment.md.
  • Petstore example: templates, values (with comments), NOTES.txt, and ci/gateway-values.yaml.
  • Version: foca-common 0.1.0 → 0.2.0 (minor, new feature); petstore depends on 0.2.0. Not tagged or released.

How it was verified

  • pytest charts/foca-common/tests (Helm v3.22.1, as in CI): 171 passed; new tests cover the HTTPRoute, the redirect (incl. 9 parametrized overlap cases of parentRefs), required values, mutual exclusivity, name collisions, Route annotations, schema rejections, a new snapshot (http-route) and lint with the new CI values.
  • helm lint --strict of the library and of the petstore chart with each ci/*-values.yaml.
  • Rendered HTTPRoutes validated against the OpenAPI schema of the HTTPRoute CRD of Gateway API v1.6.3 (standard-install.yaml; CEL rules not checked locally, but by the API server in CI).
  • ruff check, ruff format --check, mypy, mkdocs build --strict, actionlint.
  • CI kind job (new): installs Envoy Gateway v1.9.2 with a Gateway (HTTP + HTTPS listener, self-signed certificate) and the petstore chart with ci/gateway-values.yaml; checks that HTTP is redirected to HTTPS (301), that the app is reachable via HTTPS through the Gateway (and through its NetworkPolicy, which admits only the Envoy proxies and the test pod), and that a pod outside the peers is blocked.
  • CI result: all checks green. Kind job 4m29s (Envoy Gateway Programmed after ~26 s); the new step logged HTTP: 301 https://petstore-gateway.example.org/pets, HTTPS: 200 and Pod outside the peers: blocked (kindnet enforces NetworkPolicies, so the documented Envoy Gateway peers are verified).

Declined review findings

Two review rounds (adversarial + quality); all high/medium and most low findings fixed (mixed sectionName/port references now count as overlapping, NetworkPolicy step in the migration note, CI retries until the routes are programmed, redirect route documented as having no annotations, comments and wrapping). Declined:

  • Separate test for hostName on the redirect route: the redirect only renders together with the app's HTTPRoute, which requires hostName with the same message (tested).
  • Soften "ListenerSet (Gateway API 1.5 or later)": ListenerSet graduated to the Standard channel in Gateway API v1.5.0 (release notes), and Envoy Gateway v1.9.2 ships it at v1.
  • Order of resources in Chart.yaml's description: cosmetic.
  • httpsRedirect.annotations: not added (documented instead); can be added compatibly later if a Gateway implementation needs it.

Open questions

None.

Release of foca-common 0.2.0 (after merge)

git tag -s chart-v0.2.0 -m "foca-common 0.2.0" <merge commit on dev>
git push origin chart-v0.2.0

🤖 Generated with Claude Code

Summary by Sourcery

Support exposing FOCA applications through Gateway API HTTPRoutes while documenting migration and validating the setup in CI.

New Features:

  • Add optional Gateway API HTTPRoute support with configurable parent references, filters, annotations, and an optional HTTP-to-HTTPS redirect route.
  • Add Route annotations and enforce mutually exclusive exposure through Ingress, HTTPRoute, and OpenShift Route resources.
  • Provide petstore Gateway API configuration and example templates.

Bug Fixes:

  • Prevent HTTPS redirect routes from overlapping the app route's possible listeners and catch resource name collisions during rendering.

Enhancements:

  • Expand Helm chart guidance for Gateway API, ingress-nginx, Traefik, OpenShift, cloud load balancers, TLS, request limits, rate limiting, NetworkPolicy peers, and migration.
  • Preserve compatibility when new route configuration maps are absent and update the common chart to version 0.2.0.

CI:

  • Add an Envoy Gateway kind-based CI deployment that verifies HTTP redirection, HTTPS application access, and NetworkPolicy enforcement.

Documentation:

  • Document app exposure options and Gateway API migration and configuration guidance.

Tests:

  • Add HTTPRoute, redirect, validation, schema, annotation, snapshot, and Gateway-based chart lint coverage.

uniqueg and others added 5 commits October 22, 2026 21:50
foca-common 0.2.0 can expose the app with a Gateway API HTTPRoute
(gateway.networking.k8s.io/v1) attached to an existing Gateway via
<valuesKey>.httpRoute.parentRefs, with optional filters (e.g., an
ExtensionRef for body size or rate limits) and an optional second
HTTPRoute that redirects HTTP to HTTPS on the Gateway's HTTP listener
(httpRoute.httpsRedirect). The Ingress and the HTTPRoute are mutually
exclusive; the OpenShift Route is only created without either. The
Route gets annotations from <valuesKey>.route.annotations (e.g., the
router's rate limits). Existing values keep working.

The petstore example adds the templates, values, NOTES and a CI values
file with an HTTPRoute and the app's NetworkPolicy.

Refs #397

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The kind install job installs Envoy Gateway with a Gateway that has an
HTTP and an HTTPS listener (self-signed certificate), and installs the
petstore chart with ci/gateway-values.yaml. It checks that HTTP is
redirected to HTTPS, that the app is reachable via HTTPS through the
Gateway and its NetworkPolicy, and that the NetworkPolicy blocks pods
outside its peers.

Refs #397

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Helm chart docs describe how to expose FOCA apps via the Gateway
API (recommended for new clusters), ingress-nginx (retired, with a
migration note), Traefik, OpenShift and cloud load balancers: TLS and
HTTPS redirects, body size and rate limits, NetworkPolicy peers and
keep-alive timeouts. The deployment guide points to it.

Closes #397

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A parent reference with only a sectionName and one with only a port on
the same Gateway may select the same listener, so the HTTPS redirect now
fails for them, too. Review follow-ups: comments on the redirect route
(no annotations) and the port number, the migration note adds the
Gateway's NetworkPolicy peers first, and CI retries the redirect check
until Envoy Gateway has programmed the routes.

Refs #397

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The app's HTTPRoute is separate from the redirect, so CI retries the
HTTPS check until Envoy Gateway has programmed it, too. The migration
note is a numbered list now, and the port comment is shorter.

Refs #397

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sourcery-ai

sourcery-ai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

The PR upgrades foca-common to 0.2.0 with opt-in Gateway API HTTPRoute support, including configurable Gateway attachment, filters, and safe HTTPS redirects, while enforcing mutual exclusivity with Ingress and retaining OpenShift compatibility. It updates the Petstore example, schemas, documentation, snapshots, and CI with an Envoy Gateway kind integration test covering routing, TLS redirection, and NetworkPolicy behavior.

Sequence diagram for Gateway HTTPS redirect and app routing

sequenceDiagram
    actor Client
    participant Gateway
    participant Redirect as HTTPSRedirectRoute
    participant AppRoute
    participant Service

    Client->>Gateway: HTTP request
    Gateway->>Redirect: Match HTTP listener
    Redirect-->>Client: 301 https://host/path
    Client->>Gateway: HTTPS request
    Gateway->>AppRoute: Match HTTPS listener
    AppRoute->>Service: Forward request
    Service-->>Client: Application response
Loading

Flow diagram for mutually exclusive exposure resources

flowchart TD
    Values[Exposure values]
    Ingress{Ingress enabled?}
    HTTPRoute{HTTPRoute enabled?}
    Error[Rendering fails: Ingress and HTTPRoute are mutually exclusive]
    Route[Render OpenShift Route]
    Expose[Render selected exposure resource]

    Values --> Ingress
    Ingress -->|yes| HTTPRoute
    HTTPRoute -->|yes| Error
    Ingress -->|no| HTTPRoute
    HTTPRoute -->|yes| Expose
    HTTPRoute -->|no| Route
Loading

File-Level Changes

Change Details Files
Adds optional Gateway API HTTPRoute exposure with HTTPS redirection and validation.
  • Renders an app HTTPRoute targeting the Service through configurable Gateway parent references, annotations, and filters.
  • Adds a separate 301 RequestRedirect route for HTTP-to-HTTPS traffic.
  • Validates required host and parent references, ingress/HTTPRoute exclusivity, route name collisions, and potentially overlapping listeners.
charts/foca-common/templates/_httproute.tpl
charts/foca-common/templates/_helpers.tpl
charts/foca-common/app-values.schema.json
examples/petstore/chart/templates/httproute.yaml
examples/petstore/chart/templates/httproute-https-redirect.yaml
Updates exposure behavior and values for OpenShift Routes and preserves compatibility.
  • Suppresses OpenShift Route creation when either Ingress or HTTPRoute is enabled.
  • Passes configurable Route annotations through to the rendered resource.
  • Treats absent httpRoute and route maps as disabled or empty and updates the library version to 0.2.0.
charts/foca-common/templates/_route.tpl
charts/foca-common/Chart.yaml
examples/petstore/chart/Chart.yaml
examples/petstore/chart/Chart.lock
examples/petstore/chart/values.yaml
examples/petstore/chart/values.schema.json
Provides comprehensive chart documentation and a Gateway-enabled Petstore example.
  • Documents Gateway API, ingress-nginx migration, Traefik, OpenShift, and cloud load-balancer exposure, including TLS, limits, rate limiting, NetworkPolicy peers, and keep-alive settings.
  • Adds commented Gateway API values and CI-specific routing and NetworkPolicy configuration to the Petstore chart.
  • Updates chart notes and deployment pointers for selecting an exposure method.
docs/helm-chart.md
docs/deployment.md
examples/petstore/chart/templates/NOTES.txt
examples/petstore/chart/ci/gateway-values.yaml
Extends automated tests and CI with Gateway API integration coverage.
  • Adds unit tests and a rendering snapshot for HTTPRoutes, redirects, schema validation, exclusivity, collisions, annotations, and listener-overlap cases.
  • Installs Envoy Gateway in kind, provisions a Gateway and certificate, and verifies 301 redirects, HTTPS reachability, and NetworkPolicy blocking.
  • Adds Gateway resources and diagnostics to the chart workflow.
charts/foca-common/tests/test_templates.py
charts/foca-common/tests/test_snapshots.py
charts/foca-common/tests/__snapshots__/http-route.yaml
.github/kind/gateway.yaml
.github/workflows/charts.yml

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov

codecov Bot commented Oct 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (c7b4ce0) to head (97435e7).

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #404   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           27        27           
  Lines         2510      2510           
=========================================
  Hits          2510      2510           
Flag Coverage Δ
test_unit 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@uniqueg
uniqueg marked this pull request as ready for review October 22, 2026 20:18

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@uniqueg
uniqueg merged commit 96d5794 into dev Oct 22, 2026
15 checks passed
@uniqueg
uniqueg deleted the feat/chart-gateway-api branch October 22, 2026 20:21
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.

1 participant