このページは、まだ日本語ではご利用いただけません。翻訳中です。
Combining Services From Different HTTPRoutes
この機能はtech preview(アルファ品質)としてリリースされており、本番環境では依存すべきではありません。
Similar to the consolidation behavior implemented for Ingress resources, Kong Ingress Controller now supports the consolidation of rules from different HTTPRoute resources. When multiple HTTPRoutes specify the same combination of backend services, they will be translated into a single Kong Gateway service, effectively reducing the total number of Kong 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 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 HTTPRoutes within the same namespace will be translated to one Kong Gateway service.
How is the Translation Done?
The names of the translated Kong Gateway service will be changed when the feature is enabled. Instead of generating names from source HTTPRoute
and rules, the Kong Gateway service names will be generated from the consolidated backends.
Compute Service Name
Names of Kong 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:
-
namespaceis the namespace of theHTTPRoutes. -
backend_nsis the namespace of the first backend service. -
backend_nameis the name of the first backend service. -
backend_portis the port number of the first backend service. -
backend_weightis the weight of the first backend service if specified. -
next_backendsare sections computed from other backend services. Backend services are sorted by the namespace and name.
In addition, When the computed name from the method above is longer than 512 characters (the limit of service name length in Konnect), the service name is trimmed using the following rules:
- Only use
backend_ns,backend_name,backend_port,backend_weight, - Append the
_combined.<hash>to make sure that the name is unique. Wherehashis the SHA256 digest of the computed service name.
For example, the following two HTTPRoutes with rules pointing to the same backends with the same ports and weights:
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 Kong 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 HTTPRoutes httproute-consolidated-1 and httproute-consolidated-2 result in a single Kong Gateway service named httproute.default.svc.default.echo-1.80.75.default.echo-2.80.25.