gateway impl to expose raw deployer functions#3945
Conversation
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
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.
| 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 | ||
| } |
| // The effective value always lands on f; explicitly-empty flags are rejected in Validate. | ||
| f.Deploy.Expose = c.Expose |
There was a problem hiding this comment.
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.
| if err := writeRouteHostnameAnnotation(ctx, clientset, namespace, f.Name, hostname); err != nil { | ||
| return "", err | ||
| } | ||
|
|
||
| return fmt.Sprintf("http://%s", hostname), nil | ||
| } |
Codecov Report❌ Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
493a9a1 to
129b06c
Compare
129b06c to
0cb2bc1
Compare
|
@gauron99 take a look at https://github.com/knative/func/pull/3944/files |
| 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 |
There was a problem hiding this comment.
I think this should be done really early on, otherwise there would be race where creating other resources.
new gateway POC
raw deployercan be exposed (and is by default) via gateway + httprouteThe
func deployalso deploys ahttproute(Gateway API resource) per function attached to Gateway which is owned by some gateway operator (like contour).func deploy --exposeoption - works only with raw deployer, others ignore the field (planned to be extended tokedadeployer as well -- targetting the keda http-addon interceptor as followup PR)/kind enhancement
still to-do (possible followups)