Skip to content
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

KIC: feat: add introduction about combined service from different httproutes #8270

Merged
merged 5 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 2 additions & 0 deletions app/_data/docs_nav_kic_3.4.x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -221,3 +221,5 @@ items:
url: /reference/required-permissions
- text: Categories of Failures
url: /reference/failure-modes
- text: Combining Services From Different HTTPRoutes
url: /reference/combined-services-from-different-httproutes
lahabana marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
title: Combining Services From Different HTTPRoutes
type: reference
randmonkey marked this conversation as resolved.
Show resolved Hide resolved
purpose: |
Introduce the feature gate to consolidate {{site.base_gateway}} services by combining rules from different HTTPRoutes
alpha: true
---

Similar to the consolidation behavior implemented for `Ingress` resources, {{ site.kic_product_name }} now supports the consolidation of rules from different `HTTPRoute` resources. When multiple `HTTPRoute`s specify the same combination of backend services, they will be translated into a single {{ site.base_gateway }} service, effectively reducing the total number of {{ site.base_gateway }} services required.

## How to Enable the Feature?
The feature is enabled when the feature gate `CombinedServicesFromDifferentHTTPRoutes` is set to `true`. You can refer to the [feature gate reference](/kubernetes-ingress-controller/{{page.release}}/reference/feature-gates) to know more about the feature gates.

## What Does the Feature Gate Do?
When the feature is enabled, The rules having the same combination of backend services (combination of namespace, name, port and weight in `backendRefs` of rules)
in all `HTTPRoute`s within the same namespace will be translated to one {{site.base_gateway}} service.
randmonkey marked this conversation as resolved.
Show resolved Hide resolved

## How the Translation is Done?
randmonkey marked this conversation as resolved.
Show resolved Hide resolved

The names of the translated {{site.base_gateway}} service will be changed when the feature is enabled. Instead of generating names from source `HTTPRoute`
and rules, the {{site.base_gateway}} service names will be generated from the consolidated backends.

### Compute Service Name

Names of {{site.base_gateway}} services are computed from the namespace, name, port and weight(if specified). The pattern of names is
`httproute.<namespace>.svc.<backend_ns>.<backend_name>.<backend_port>.[backend_weight]_[next_backends]...` where:
- `namespace` is the namespace of the `HTTPRoute`s.
- `backend_ns` is the namespace of the first backend service.
- `backend_name` is the name of the first backend service.
- `backend_port` is the port number of the first backend service.
- `backend_weight` is the weight of the first backend service if specified.
- `next_backends` are sections computed from other backend services. Backend services are sorted by the namespace and name.
randmonkey marked this conversation as resolved.
Show resolved Hide resolved

In addition, When the computed name from the method above is longer than 512 characters (the limit of service name length in {{site.konnect_short_name}}), the service name is trimmed using the following rules:
- Only use `backend_ns`, `backend_name`,`backend_port`, `backend_weight` of the first backend service,
randmonkey marked this conversation as resolved.
Show resolved Hide resolved
- Append the `_combined.<hash>` to make sure that the name is unique. Where `hash` is the SHA256 digest of the computed service name.

For example, the following two `HTTPRoute`s with rules pointing to the same backends with the same ports and weights:

```yaml
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: httproute-consolidated-1
namespace: default
spec:
parentRefs:
- name: kong
rules:
- matches:
- path:
type: PathPrefix
value: /httproute-testing
backendRefs:
- name: echo-1
kind: Service
port: 80
weight: 75
- name: echo-2
kind: Service
port: 8080
weight: 25
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: httproute-consolidated-2
namespace: default
spec:
parentRefs:
- name: kong
rules:
- matches:
- path:
type: PathPrefix
value: /httproute-testing
backendRefs:
- name: echo-1
kind: Service
port: 80
weight: 75
- name: echo-2
kind: Service
port: 8080
weight: 25
```

When the feature is disabled (which is default), the rules in the two `HTTPRoutes` are translated to two distinct {{site.base_gateway}} services:
`httproute.default.httproute-consolidated-1.0` and `httproute.default.httproute-consolidated-2.0`.

When the feature is enabled, The two rules from the two `HTTPRoute`s `httproute-consolidated-1` and `httproute-consolidated-2` result in a single {{site.base_gateway}} service named `httproute.default.svc.default.echo-1.80.75.default.echo-2.80.25`.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ The same definitions of `feature gates` and `feature stages` from upstream Kuber
| KongCustomEntity | `true` | Beta | 3.3.0 | 3.4.0 |
| KongCustomEntity | `true` | GA | 3.4.0 | TBD |
{% endif_version %}
{% if_version gte:3.4.x %}
| CombinedServicesFromDifferentHTTPRoutes | `false` | Alpha | 3.4.0 | TBD |
{% endif_version %}

## Using feature gates

Expand Down Expand Up @@ -91,3 +94,14 @@ private keys in `Certificate` entities and `Consumer` entities' credentials.
> **Warning:** `KongPlugin`'s and `KongClusterPlugin`'s `config` fields are not sanitized. If you have sensitive information
> in your `KongPlugin`'s `config` field, it will be sent to Konnect as is. To avoid that, please consider using
> [KongVault](/kubernetes-ingress-controller/{{page.release}}/reference/custom-resources/#kongvault).

{% if_version gte:3.4.x %}
### CombinedServicesFromDifferentHTTPRoutes
randmonkey marked this conversation as resolved.
Show resolved Hide resolved

The `CombinedServicesFromDifferentHTTPRoutes` feature enables translating `HTTPRoute` rules
randmonkey marked this conversation as resolved.
Show resolved Hide resolved
with the same set of backends (combination of namespace, name, port and weight) from different `HTTPRoute`s in the same namespace
into a single {{site.base_gateway}} service. Enabling the feature gate can reduce the number of translated {{site.base_gateway}} services.

The names of {{site.base_gateway}} services will change if the feature gate is enabled.
You can refer to the [reference page](/kubernetes-ingress-controller/{{page.release}}/reference/combined-services-from-different-httproutes) for further details.
{% endif_version %}
Loading