Kong / kubernetes-ingress-controller

:gorilla: Kong for Kubernetes: The official Ingress Controller for Kubernetes.
https://docs.konghq.com/kubernetes-ingress-controller/
Apache License 2.0
2.2k stars 590 forks source link

Combine Gateway Services when using HTTPRoute #5801

Open mheap opened 5 months ago

mheap commented 5 months ago

Is there an existing issue for this?

Does this enhancement require public documentation?

Problem Statement

When using HTTPRoute, multiple Kong services are generated that point to the same backend. This has an impact on functionality (per-service rate limiting) and pricing.

Proposed Solution

Reuse services when HTTPRoute definitions are identical

Additional information

Notes from @czeslavo:

There are Gateway API cases that we need to take into account (allowing multiple backend refs in a single rule is a fundamental one). I think that we could slightly improve by generating fewer Kong Services from HTTPRoutes e.g. by merging Kong Services from different HTTPRoutes if they are using exactly the same target refs (not only Kubernetes Services behind them, but also their weights, and potentially filters if we decide to support them - currently we don’t). But that still won’t work the same way as Ingress does where you may expect almost 1-1 Kong Service - Kubernetes Service mapping (with an exemption of different ports of a single Kubernetes Service generating separate Kong Services). We’d still have to distinguish the Kong Service is generated from HTTPRoute and the httproute in their names is about that.

Acceptance Criteria

jeromeguillaume commented 5 months ago

There is an impact on Konnect - API Product too. Right now if you define, for instance, 3 HTTPRoutes concerning the same Kubernetes Service, you have 3 Gateway Services and consequently 3 API Products. So finally we have 3 entries in the Developer Catalog whereas it's the same API (i.e. same Kubernetes service)

randmonkey commented 5 months ago

A question about naming of translated services: how should we name the translated Kong services, as they can come from different HTTPRoutes:

piotrwielgolaski-tomtom commented 5 months ago

I would love ingress format, but it could be problematic if different filtered are used.

Version relying on index of first route sound risky, as adding new route could change service name

maybe ingress format followed by has of parameters like filters.

piotrwielgolaski-tomtom commented 4 months ago

Also it would be very useful to know k8s service and namespace in access log

randmonkey commented 4 months ago

@mheap I want to discuss what are included in the "target ref" to group Kong services:

Also, should we put this feature behind a feature gate and disable it by default? I think yes (like what we have done for CombinedRoutes and CombinedServices) because it is a significant and user facing change, and there will be pontetial changes happen to the feature itself.