Skip to content

Conversation

pippolo84
Copy link
Member

Refactor the code to generate envoy virtual host routes from HTTPRoutes. The new code is functionally equivalent to the previous one, but relies on some helper functions to improve readability while taking into account every different scenario:

  • HTTPS routes
  • HTTP routes with Direct Response
  • HTTP routes with single backend
  • HTTP routes with multiple load-balanced backend

@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Oct 26, 2022
@pippolo84 pippolo84 force-pushed the pr/pippolo84/refactor-envoy-virtual-host branch from 7fbfd42 to aadf9ac Compare October 26, 2022 20:51
This commit is to leverage controller-runtime library for Gateway API
controllers. operator-sdk CLI is used to create the scaffold structure
and code.

```
operator-sdk create api --group gateway --version v1beta1 --kind GatewayClass --resource --controller --namespaced false
operator-sdk create api --group gateway --version v1beta1 --kind Gateway --resource --controller
operator-sdk create api --group gateway --version v1beta1 --kind HTTPRoute --resource --controller
```

One adjustment is to separate the reconciliation event trigger (e.g.
watch sepecific resource) and the reconciliation logic itself into
different files (e.g. gateway.go and gateway_reconcile.go). This will
create some space for actual implementation later.

Signed-off-by: Tam Mach <tam.mach@cilium.io>
This commit is doing nothing but just add a flag for enabling Gateway API
support. The permission for operator clusterrole is updated as required.

Signed-off-by: Tam Mach <tam.mach@cilium.io>
This is just to add a simple reconciliation loop, which will just check
controller name and update the status accordingly.

Currently, there is no support of GatewayClass configuration from either
custom resource or configmap (preferred), hence the Accepted condition
will be just updated to True. Future improvement can be done with different
set of configuration parameters (e.g. internal vs external, etc).

Signed-off-by: Tam Mach <tam.mach@cilium.io>
For HTTPRoute resources, the reconciliation should start if any of below
event happens:

- Changes in HTTPRoute itself
- Changes in related backend services
- Changes in parent Gateway spec (e.g. allowedRoutes)

The current reconciliation loop is trying its best to make sure that HTTPRoute
is attachable to Gateway. If all validations are passed, then the Accepted
condition will be updated to True, which signals the reconciliation loop for
parent Gateway resources.

Signed-off-by: Tam Mach <tam.mach@cilium.io>
This commit is to support headers and query params matching, also add
weightage attribute for backends as well.

The goal is to prepare for supporting more options in HTTPRoute from
Gateway API in subsequent changes.

Signed-off-by: Tam Mach <tam.mach@cilium.io>
This commit is just to lift and shift existing shared translator (used in
Ingress) to higher level, so that it can be re-used naturally for both
Ingress and Gateway API.

Signed-off-by: Tam Mach <tam.mach@cilium.io>
This commit is to support multiple TLS secrets, which can be useful for
some use cases in Gateway API.

Signed-off-by: Tam Mach <tam.mach@cilium.io>
This commit is to support hostnames in route level, mainly for the
stricter domain validation compared to listener domain. For example,
listener might have wildcard domain such as *.example.com, but each
route might have its own sub-domains such as route1.example.com or
route2.example.com. If nothing is specified in route level, the
value from listener will be honoured.

Signed-off-by: Tam Mach <tam.mach@cilium.io>
This is to support the scenario, in which no backend is valid or
available.

Signed-off-by: Tam Mach <tam.mach@cilium.io>
@sayboras sayboras force-pushed the ft/master/gateway-api-support branch from 82cefa4 to 174f17e Compare October 27, 2022 03:19
This commit is to support request header add/set/removal operation.

Signed-off-by: Tam Mach <tam.mach@cilium.io>
This commit is to convert gateway api resource to our internal
representation. The logic is pretty simple, just few things to highlight
compared to Ingress:

- Query match, header match are supported.
- Request header filter is supported for operations Set, Add and Remove.

Signed-off-by: Tam Mach <tam.mach@cilium.io>
This commit is to our internal representation to CEC, LB Service and
Endpoints. The logic is exactly the same compared to default translator,
except a few tweaks:

- hostname matching is suffix based
- multiple listeners might have a same port number (e.g. 80 or 443), so
  we need to consider only unique values.

Signed-off-by: Tam Mach <tam.mach@cilium.io>
For gateway resources, the reconciliation should start if any of below
events happens:

- Changes in related GatewayClass
- Changes in any of HTTPRoute status
- Changes in owning LB services status
- Changes in owning CEC (as currently we don't have status subresource)
- Changes in any Secret used in TLS

As we are using the same LB service for all listeners, it's all or
nothing for ListenerStatus.

Signed-off-by: Tam Mach <tam.mach@cilium.io>
This commit is to make sure that any TLS related secret will be synced
to cilium-secrets namespace, so that the agent's permission is scoped
down to single namespace instead of cluster-wide. The same approach is
used in Ingress. However, it's better to keep it separate due to:

- underlying framework is different (e.g. controller-runtime)
- placeholder to support ReferenceGrant API later.

Signed-off-by: Tam Mach <tam.mach@cilium.io>
@sayboras sayboras force-pushed the ft/master/gateway-api-support branch 2 times, most recently from 3f7bba7 to 19b937d Compare October 27, 2022 08:36
This commit is to support ReferenceGrant for cross-namespace resources:

- Secret is referenced in Gateway
- Service is referenced in HTTPRoute

The conformance test is also enabled with ReferenceGrant feature.

Signed-off-by: Tam Mach <tam.mach@cilium.io>
This commit is add gateway api conformance test from upstream. The goal
is to have it running on every PR, so that we can catch any issue due to
regression, refactoring or adding new features.

The upstream conformance, by default, is not configured with query param
matching feature. To reduce the coupling with upstream, the
conformance_test.go is added for flexibility, for example, query param
tests are enabled.

Signed-off-by: Tam Mach <tam.mach@cilium.io>
@sayboras sayboras force-pushed the ft/master/gateway-api-support branch from 19b937d to 839b1bc Compare October 27, 2022 08:51
Refactor the code to generate envoy virtual host routes from HTTPRoutes.
The new code is functionally equivalent to the previous one, but relies
on some helper functions to improve readability while taking into
account every different scenario:

- HTTPS routes
- HTTP routes with Direct Response
- HTTP routes with single backend
- HTTP routes with multiple load-balanced backend

Signed-off-by: Fabio Falzoi <fabio.falzoi@isovalent.com>
@pippolo84 pippolo84 force-pushed the pr/pippolo84/refactor-envoy-virtual-host branch from aadf9ac to 920717f Compare October 27, 2022 10:04
@sayboras sayboras force-pushed the ft/master/gateway-api-support branch 4 times, most recently from 3cbb772 to 497f3d7 Compare October 31, 2022 10:25
@aanm aanm deleted the branch cilium:ft/master/gateway-api-support October 31, 2022 10:26
@aanm aanm closed this Oct 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dont-merge/needs-release-note-label The author needs to describe the release impact of these changes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants