Skip to content

Adding Route Delegation Details for each HTTPRoute Capability #1300

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions site-src/geps/gep-1058.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# GEP-1058: Route Inclusion and Delegation

- Issue: [#1058](https://github.com/kubernetes-sigs/gateway-api/issues/1058)
- Status: Provisional

## TLDR

Add support for a 2-tier hierarchy of route configuration to allow partial
delegation of route settings and, provide more flexibility in how route
configurations are organized and managed.

## HTTPRoute Delegation Capabilities

### Matching
| Capability | Importance for Delegation | Complexity | Implementation Details |
|---|---|---|---|
| Hostnames | ? | Moderate | A three way intersection between Gateway, Parent Route, and Child Route hostnames |
| Prefix Path on Parent, Prefix or Exact on Child | High | Low | Prefix path match of parent is prepended to child path match, child can support exact or prefix path matching |
| Exact Path on Parent | Low | Moderate | Would require only "/" matches on child route |
| Exact Path on Child | High | Low | Prefix path match of parent is prepended to child path match, child can support exact or prefix path matching |
| Regex Path on Parent or Child | Low | Impossible | Maybe some complex merging is possible here, but I can't think of a good solution |
Copy link
Contributor

Choose a reason for hiding this comment

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

What about delegating something like a /accounts/[id] pattern? This feels like it may be not a not-uncommon need - could something like excluding a parent PathPrefix make this possible? RegEx parent path feels like it could be harder and lower-value though, maybe split these cases apart?

| Exact Header on Parent and Child | Moderate | Low | Merge header matches, when duplicate keys appear, treat identically to duplicate match keys in same route |
| Regex Header on Parent and Child | Low | Low | Merge header matches, when duplicate keys appear, treat identically to duplicate match keys in same route |
| Exact Query Param on Parent and Child | Moderate | Low | Merge query param matches, when duplicate keys appear, treat identically to duplicate match keys in same route |
| Regex Query Param on Parent and Child | Low | Low | Merge query param matches, when duplicate keys appear, treat identically to duplicate match keys in same route |
| Method on Parent and Child | Low | Low | If methods don't overlap, no requests match, potentially surface in status |

### Filters

| Capability | Importance for Delegation | Complexity | Implementation Details |
|---|---|---|---|
| RequestHeaderModifier on Parent and Child | Moderate | High | The order of operations becomes the most important factor here. If we can confirm that all implementations can support an arbitary order of operations for Add, Set, and Remove operations, we could simply specify that configuration on child routes would be applied after parent routes. |
| RequestMirror on Parent and Child | Low | High | Many implementations can only support mirroring a request to one destination. We could support Parent _or_ child, or state that one overrode the other |
| RequestRedirect on Parent | Low | Impossible | Redirects simply don't make sense on parents that are delegating. |
| RequestRedirect on Child | Moderate | Low | Redirects should be possible if they are only configured on child Route rules. |
| URLRewrite on Parent and Child | Low | Impossible | It would be very difficult, maybe impossible, to merge this configuration. |
| URLRewrite on Parent or Child | Low | Moderate | Rewrite configuration should be possible on either the parent or child, but not both at the same time. |


## Open Questions

### How do we handle multiple matches?

Parent Route:

```yaml
matches:
- path:
- prefix: /foo
- path:
- prefix: /bar
delegateToNamespace: foo
```

Child Route:

```yaml
matches:
- path:
- prefix: /baz
```

* Does the child route match `/foo/bar` and `/bar/baz`?
* Would it be preferable to require the child route to specify the full path?
* How does this interact with potential matching conflicts for headers or query params?
Comment on lines +63 to +65
Copy link
Contributor

Choose a reason for hiding this comment

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

I think matching both makes sense, and it's preferable to not specify the full path, as it would make config more brittle if the upstream path were to ever change.


Parent Route:

```yaml
matches:
- method: GET
path:
- prefix: /foo
- method: POST
path:
- prefix: /bar
delegateToNamespace: foo
```

Child Route:

```yaml
matches:
- method: GET
path:
- prefix: /baz
```

* Does this only match `GET /foo/baz`?
Copy link
Contributor

Choose a reason for hiding this comment

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

I think yes, it should only match GET /foo/baz (effectively a logical AND evaluation). I think it would make sense to apply the same AND logic to headers and query params, for consistency with the existing intra-match spec https://gateway-api.sigs.k8s.io/v1alpha2/references/spec/#gateway.networking.k8s.io%2fv1alpha2.HTTPRouteMatch