Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
randmonkey committed Dec 19, 2024
1 parent b260e39 commit 10dc9d5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,32 +1,37 @@
---
title: Combined Services From Different HTTPRoutes
title: Combining Services From Different HTTPRoutes
type: reference
purpose: |
Introduce the feature gate to consolidate {{site.base_gateway}} services by combining rules from different HTTPRoutes
alpha: true
---

As have been done to `Ingress`es, {{site.kic_product_name}} can consolidate rules from different `HTTPRoute`s with the same
As have been done to `Ingress`es, {{site.kic_product_name}} can consolidate rules from different `HTTPRoute`s having the same
combination of backend services and translate them into one {{site.base_gateway}} service to reduce the number of {{site.base_gateway}} services.

## How to Enable the Feature?
The feature is enabled when the feature gate `CombinedServicesFromDifferentHTTPRoutes` is set to `true`.
When the feature is enabled, The rules with the same combination of backend services (combination of namespace, name, port and weight in `backendRefs` of rules)

## 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.

## Changes on Translated {{site.base_gateway}} Service Names
## How the Translation is Done?

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.

### Calculate Service Name
### Compute Service Name

Names of {{site.base_gateway}} services will be calculated from the namespace, name, port and weight(if specified). The pattern of names is
Names of {{site.base_gateway}} services will be 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 calculated from other backend services. Backend services are sorted by the namespace and name.
- `next_backends` are sections computed from other backend services. Backend services are sorted by the namespace and name.

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

```yaml
Expand Down Expand Up @@ -77,11 +82,15 @@ spec:
weight: 25
```
The two rules from the two `HTTPRoute`s `httproute-consolidated-1` and `httproute-consolidated-2` will be translated to one {{site.base_gateway}} service
with name `httproute.default.svc.default.echo-1.80.75.default.echo-2.80.25`.
When the feature is not enabled, the rules in the two `HTTPRoutes` will be translated
to two {{site.base_gateway}} services separately.
The names of the services will be `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` will be translated to one {{site.base_gateway}} service.
The translated service name will computed by the rules above, resulting to the name `httproute.default.svc.default.echo-1.80.75.default.echo-2.80.25`.

### Trimming {{site.base_gateway}} Service Names

Technically, the calculated name from the method in the section above can be too long. So when the calculated name is longer than 512 characters (the limit of service name length in {{site.konnect_short_name}}),
the service name is trimmed to make sure that the translated service name does not exceed 512 characters. The trimmed name will only preserve the information(namespace, name, port, weight) of the first backend service,
then we append the `_combined.<hash>` suffix to the name to make sure that the name is unique. `hash` is the SHA256 hash sum of the calculated service name.
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:
- Trim the name to only preserve the information (`backend_ns`, `backend_name`,`backend_port`, `backend_weight`) of the first backend service,
- Append the `_combined.<hash>` to make sure that the name is unique. Where `hash` is the SHA256 digest of the computed service name.
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ private keys in `Certificate` entities and `Consumer` entities' credentials.

### CombinedServicesFromDifferentHTTPRoutes

When the feature gate `CombinedServicesFromDifferentHTTPRoutes` is enabled, {{site.kic_product_name}} will translate `HTTPRoute` rules
sharing the same set of backends (combination of namespace, name, port and weight) from different `HTTPRoute`s in the same namespace
The `CombinedServicesFromDifferentHTTPRoutes` feature enables translating `HTTPRoute` rules
having the same set of backends (combination of namespace, name, port and weight) from different `HTTPRoute`s in the same namespace
into one {{site.base_gateway}} service. Enabling the feature gate could reduce the number of translated {{site.base_gateway}} services.

The names of {{site.base_gateway}} services will be changed if the feature gate is enabled compared to the names when it is disabled.
The names of {{site.base_gateway}} services will be changed if the feature gate is enabled.
You can refer to the [reference page](/kubernetes-ingress-controller/{{page.release}}/reference/combined-services-from-different-httproutes) to know the details.

0 comments on commit 10dc9d5

Please sign in to comment.