Repository navigation
[rds.kubernetes] Add HTTPRoute (Gateway API) target discovery - #1424
Conversation
|
Thank you for this contribution! Support of |
|
Sorry for the delay here. I was waiting for the refactor that I just merged through #1486 before adding more resource types. |
8935628 to
bf90138
Compare
|
Rebased onto
Worth noting the rebase itself was clean and the result compiled and passed tests with the old pattern still in place — the additions never textually overlapped what #1486 rewrote. So nothing would have flagged that this was still a fifth copy; the conversion had to be deliberate. Three things it inherits for free:
One judgment call worth a look. HTTPRoute filters name and labels on the expanded resources rather than on the route object, which is what this PR already did and matches ingresses — derived names and per-resource The subtlety is the fallback resource for a route with no hostnames. It has to be chosen before filtering, otherwise a route whose resources are all filtered out reappears under its bare name. The naive conversion gets this wrong, and this PR's own tests catch it — Also added httproutes to |
Discover Gateway API HTTPRoute objects as targets, expanding each route into one resource per (hostname, path) pair the way ingresses are expanded. Unlike an ingress, an HTTPRoute carries no load balancer IP in its status: the address belongs to the parent Gateway, which is not resolved here. The route hostname is used as the target IP and exposed as the fqdn label, so probes resolve it via DNS and send the right Host header. Built on the generic resourceLister, so the new type is an info struct with metadata() and resources() plus a constructor naming the kind and the gateway.networking.k8s.io API prefix. The URL builder, JSON parsing, refresh loop and filtering are all shared. Note that the fallback resource for a route with no hostnames is chosen before the name and labels filters are applied, so that a route whose resources are all filtered out doesn't reappear under its bare name.
Route hostnames are the only thing we can probe: routes without them inherit hostnames from the Gateway listener, and wildcard hostnames don't name a specific host. Previously these produced targets that could never succeed (no IP, or an IP of "*.example.com").
HTTPRouteRule has no hostnames field in the Gateway API; hostnames exist only at the route level (spec.hostnames). The override logic was dead code, and the test fixture modeled an object the API server never returns.
Use kMetadata.resourceLabels(), as the other kinds do since #1489.
e8dae98 to
bceb1ad
Compare
- Rules that differ only in header or method matches expand to the same (hostname, path) pair; emit that resource once instead of relying on the RDS client to drop duplicates with a warning on every refresh. - Add an http_routes case to Test_parseConfig. - Note that HTTPRoute discovery needs the Gateway API CRDs installed.
- RegularExpression path matches don't name a specific URL, so probing them literally always fails. Skip them. - If the route has its own relative_url label, every resource would probe that URL, so emit one resource per hostname instead of one per path. - Reflow the Target Labels paragraph.
a26bc9d to
83dc70d
Compare
Adds Kubernetes target discovery for Gateway API
HTTPRouteresources, analogous to the existingIngresssupport. Closes #1409.What it does
http_routesresource type for thek8stargets provider.HTTPRouteis expanded into one RDS resource per (hostname x match path), mirroring how ingresses are expanded:name:<route>_<host>_<path>fqdnlabel: hostnamerelative_urllabel: match path (/for rules without a path match)namespacelabel, as for the other kinds ([rds.kubernetes] Add a namespace label to discovered resources #1489)spec.hostnames(Gateway API has no rule-level hostnames).*.example.com) produce no resources, since there is no specific host to probe.RegularExpressionpath matches are skipped, as they don't name a specific URL.relative_urllabel, paths are not expanded: one resource per hostname, named<route>_<host>.Note on the target IP
Unlike
Ingress, anHTTPRoutedoes not carry a load balancer IP in its status (the address lives on the parentGateway). This change uses the route hostname as the target IP; the probe resolves it via DNS, and thefqdnlabel drives the Host header / SNI. Resolving the parentGateway.status.addressesfor a real IP is a possible follow-up, as is using the route's status conditions as a readiness signal.Requires the Gateway API CRDs to be installed in the cluster.
Config
Tests
httproutes_test.go+testdata/httproutes.jsoncover parsing, listing, and name/label/namespace filtering, skipping of hostname-less and wildcard routes and regex paths, therelative_urllabel override, and deduplication of identical (hostname, path) pairs.targets/k8s_test.gocovers thehttp_routesconfig.