Skip to content

gateway impl to expose raw deployer functions#3945

Draft
gauron99 wants to merge 2 commits into
knative:mainfrom
gauron99:push-vsovkklqqmnr
Draft

gateway impl to expose raw deployer functions#3945
gauron99 wants to merge 2 commits into
knative:mainfrom
gauron99:push-vsovkklqqmnr

Conversation

@gauron99

@gauron99 gauron99 commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

new gateway POC

  • 🎁 raw deployer can be exposed (and is by default) via gateway + httproute
    The func deploy also deploys a httproute (Gateway API resource) per function attached to Gateway which is owned by some gateway operator (like contour).
  • func never creates the gateway
  • 🎁 func deploy --expose option - works only with raw deployer, others ignore the field (planned to be extended to keda deployer as well -- targetting the keda http-addon interceptor as followup PR)
  • Includes gateway tests + 2 specific e2e tests

/kind enhancement

still to-do (possible followups)

  • delete the resource when re-deploying with different function
  • split e2e tests out of the "Core" run because github action has limited cpu resources
Function deployed via --deployer=raw (bare k8s deployment) can be exposed externally (outside of cluster) via pre-configured Gateway API. func will create the HttpRoute if it has gateway to connect to

@knative-prow knative-prow Bot added the kind/enhancement Feature additions or improvements to existing label Jul 12, 2026
@knative-prow knative-prow Bot requested review from dsimansk and jrangelramos July 12, 2026 20:36
@knative-prow

knative-prow Bot commented Jul 12, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gauron99

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow Bot added the approved 🤖 PR has been approved by an approver from all required OWNERS files. label Jul 12, 2026
@gauron99 gauron99 marked this pull request as draft July 12, 2026 20:37
@knative-prow knative-prow Bot added the do-not-merge/work-in-progress 🤖 PR should not merge because it is a work in progress. label Jul 12, 2026
@gauron99 gauron99 requested review from Copilot and removed request for dsimansk and jrangelramos July 12, 2026 20:37
@knative-prow knative-prow Bot added the size/XXL 🤖 PR changes 1000+ lines, ignoring generated files. label Jul 12, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds Gateway API–based external exposure for functions deployed with the raw deployer by creating/managing an HTTPRoute (without provisioning a Gateway), plus CLI/config support and new unit/e2e coverage. This integrates into the existing deploy flow by reconciling exposure after Service/Deployment creation and by persisting derived exposure state on the Service for later list/describe output.

Changes:

  • Introduces deploy.expose (--expose) for raw deployer Gateway API exposure and validation/error handling for invalid values.
  • Implements Gateway discovery, hostname derivation, HTTPRoute create/update/delete, and acceptance waiting in the raw deployer.
  • Extends result messaging (DeploymentResult.Exposed) and adds substantial unit + e2e test coverage and cluster provisioning updates for Gateway API.

Reviewed changes

Copilot reviewed 36 out of 37 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
schema/func_yaml-schema.json Adds deploy.expose to func.yaml schema output
pkg/mock/deployer.go Sets mock deploy result status to Deployed on success
pkg/knative/deployer.go Marks Knative deploy results as Exposed
pkg/keda/deployer.go Disables raw exposure path for embedded keda deployer; sets Exposed=false
pkg/k8s/lister.go Uses Service annotation to surface external URL when exposed
pkg/k8s/httproute.go New Gateway API helpers (gateway resolve, hostname mint, HTTPRoute lifecycle, acceptance wait)
pkg/k8s/httproute_test.go Unit tests for HTTPRoute generation and ensure/update conflict behavior
pkg/k8s/gateway_test.go Unit tests for gateway discovery, admission, hostname minting, route acceptance, and managed-route deletion
pkg/k8s/exposure_test.go Unit tests for raw exposure reconciliation, annotation lifecycle, and forbidden semantics
pkg/k8s/describer.go Surfaces external+internal routes based on Service annotation
pkg/k8s/deployer.go Raw deployer reconciles Gateway exposure; records exposure state; returns Exposed flag
pkg/k8s/deployer_test.go Adds option test for WithDeployerExposureDisabled
pkg/functions/function.go Adds DeploySpec.Expose and validation hook
pkg/functions/function_expose.go Adds ParseExpose + validation helper
pkg/functions/function_expose_unit_test.go Unit tests for expose parsing/validation and typed error wrapping
pkg/functions/errors.go Adds sentinel ErrInvalidExpose
pkg/functions/client.go Adds DeploymentResult.Exposed and deploy success message matrix
pkg/functions/client_test.go Verifies deploy output uses the new message formatter
pkg/functions/client_message_unit_test.go Unit tests for deploy success message matrix
pkg/deployer/testing/integration_test_helper.go Forces expose=none for raw/keda integration fixtures where Gateway isn’t available
pkg/cluster/versions.go Pins Gateway API CRD bundle version and shared Gateway name/namespace
pkg/cluster/serving.go Installs Gateway API CRDs and provisions a shared Gateway/GatewayClass in cluster setup
Makefile Adds/uses schema generation/check targets and includes Gateway e2e in test-e2e
hack/component-versions.sh Adds gateway API version pin
hack/component-versions.json Adds gateway API version pin
hack/cmd/components/main.go Propagates gateway API version into generated component version script
hack/cluster.sh Installs Gateway API CRDs and shared Gateway for local clusters
go.sum Updates gateway-api module checksum to v1.5.1
go.mod Adds direct dependency on sigs.k8s.io/gateway-api v1.5.1
e2e/e2e_trigger_sync_test.go Forces --expose none for raw deployer in existing e2e tests
e2e/e2e_metadata_test.go Forces --expose none for raw deployer in existing e2e tests
e2e/e2e_gateway_test.go New e2e tests for raw Gateway API exposure and custom domain flow
docs/reference/func_deploy.md Documents --expose flag semantics
cmd/errors.go Adds typed CLI error wrapper for invalid --expose values
cmd/deploy.go Adds --expose flag, completion, validation, and cross-deployer warning behavior
cmd/deploy_test.go Tests expose persistence/clearing, invalid value typed error, and warning behavior
cmd/completion_util.go Adds shell completion for --expose

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/k8s/httproute.go
Comment on lines +380 to +389
func hostnameIntersects(listenerHostname, candidate string) bool {
if listenerHostname == candidate {
return true
}
if strings.HasPrefix(listenerHostname, "*.") {
base := listenerHostname[2:]
return candidate == base || strings.HasSuffix(candidate, "."+base)
}
return false
}
Comment thread schema/func_yaml-schema.json
Comment thread cmd/deploy.go
Comment on lines +637 to +638
// The effective value always lands on f; explicitly-empty flags are rejected in Validate.
f.Deploy.Expose = c.Expose

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Confirmed — stale comment from an earlier design iteration. Explicitly-empty --expose is deliberately allowed and clears the persisted key (see the flag help and TestDeploy_ExposeExplicitEmptyClears). Comment fix incoming.

Comment thread pkg/knative/deployer.go
Comment thread pkg/knative/deployer.go
Comment thread pkg/k8s/deployer.go
Comment on lines +418 to +423
if err := writeRouteHostnameAnnotation(ctx, clientset, namespace, f.Name, hostname); err != nil {
return "", err
}

return fmt.Sprintf("http://%s", hostname), nil
}
@codecov

codecov Bot commented Jul 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 64.35644% with 288 lines in your changes missing coverage. Please review.
✅ Project coverage is 52.68%. Comparing base (0b69c13) to head (0cb2bc1).

Files with missing lines Patch % Lines
pkg/cluster/serving.go 0.00% 88 Missing ⚠️
pkg/k8s/deployer.go 54.22% 47 Missing and 18 partials ⚠️
pkg/k8s/httproute.go 84.19% 46 Missing and 18 partials ⚠️
pkg/deployer/testing/integration_test_helper.go 0.00% 26 Missing ⚠️
cmd/completion_util.go 0.00% 15 Missing ⚠️
cmd/deploy.go 86.95% 4 Missing and 2 partials ⚠️
pkg/k8s/describer.go 61.53% 5 Missing ⚠️
pkg/k8s/lister.go 0.00% 5 Missing ⚠️
pkg/keda/deployer.go 0.00% 5 Missing ⚠️
pkg/cluster/tekton.go 0.00% 4 Missing ⚠️
... and 2 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3945      +/-   ##
==========================================
- Coverage   53.17%   52.68%   -0.49%     
==========================================
  Files         203      205       +2     
  Lines       23807    24594     +787     
==========================================
+ Hits        12660    12958     +298     
- Misses       9914    10439     +525     
+ Partials     1233     1197      -36     
Flag Coverage Δ
e2e 34.18% <26.82%> (+12.65%) ⬆️
e2e go 28.42% <4.09%> (-0.88%) ⬇️
e2e node 24.87% <4.09%> (-0.74%) ⬇️
e2e python 28.76% <4.09%> (-0.89%) ⬇️
e2e quarkus 24.99% <4.09%> (-0.76%) ⬇️
e2e rust 24.45% <4.09%> (-0.74%) ⬇️
e2e springboot 23.18% <4.09%> (-0.70%) ⬇️
e2e typescript 24.98% <4.09%> (-0.76%) ⬇️
e2e-config-ci 26.05% <4.09%> (-0.81%) ⬇️
integration ?
unit macos-14 44.27% <64.25%> (+0.94%) ⬆️
unit macos-latest 44.27% <64.25%> (+0.94%) ⬆️
unit ubuntu-24.04-arm 44.46% <62.00%> (+0.84%) ⬆️
unit ubuntu-latest 45.09% <64.25%> (+0.91%) ⬆️
unit windows-latest 44.31% <64.25%> (+0.94%) ⬆️

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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gauron99 gauron99 changed the title Push vsovkklqqmnr gateway impl to expose raw deployer functions Jul 13, 2026
@gauron99 gauron99 force-pushed the push-vsovkklqqmnr branch 2 times, most recently from 493a9a1 to 129b06c Compare July 13, 2026 06:20
@gauron99 gauron99 force-pushed the push-vsovkklqqmnr branch from 129b06c to 0cb2bc1 Compare July 13, 2026 07:59
@matejvasek

Copy link
Copy Markdown
Contributor

Comment thread hack/cluster.sh
Comment on lines +258 to +272
echo "Installing Gateway API CRDs."
# experimental-install.yaml, not standard: Contour's gatewayRef mode
# crashes at startup without it - it unconditionally informers on
# TLSRoute (gateway.networking.k8s.io/v1alpha2), which only the
# experimental channel provides, even though our own code only uses the
# four standard CRDs waited on below.
$KUBECTL apply --server-side -f "https://github.com/kubernetes-sigs/gateway-api/releases/download/${gateway_api_version}/experimental-install.yaml"
# Waited on by name (the four CRDs the raw deployer's exposure path
# actually uses - see pkg/k8s/httproute.go) rather than "--all crd", so a
# failure names exactly which one didn't Establish.
$KUBECTL wait --for=condition=Established --timeout=5m \
crd/gatewayclasses.gateway.networking.k8s.io \
crd/gateways.gateway.networking.k8s.io \
crd/httproutes.gateway.networking.k8s.io \
crd/referencegrants.gateway.networking.k8s.io

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this should be done really early on, otherwise there would be race where creating other resources.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved 🤖 PR has been approved by an approver from all required OWNERS files. do-not-merge/work-in-progress 🤖 PR should not merge because it is a work in progress. kind/enhancement Feature additions or improvements to existing size/XXL 🤖 PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants