22title : Gateway API
33content_type : concept
44description : >-
5- 网关( Gateway) API 是一组 API 类别,可提供动态基础设施配置和高级流量路由 。
5+ Gateway API 是一组 API 类别,可提供动态基础设施制备和高级流量路由 。
66weight : 55
77---
8-
98<!--
109title: Gateway API
1110content_type: concept
1211description: >-
1312 Gateway API is a family of API kinds that provide dynamic infrastructure provisioning
1413 and advanced traffic routing.
1514weight: 55
16- -->
15+ -->
1716
1817<!-- overview -->
1918
@@ -53,7 +52,8 @@ Gateway API 的设计和架构遵从以下原则:
5352* ** 角色导向:** Gateway API 类别是基于负责管理 Kubernetes 服务网络的组织角色建模的:
5453 * ** 基础设施提供者:** 管理使用多个独立集群为多个租户提供服务的基础设施,例如,云提供商。
5554 * ** 集群操作员:** 管理集群,通常关注策略、网络访问、应用程序权限等。
56- * ** 应用程序开发人员:** 管理在集群中运行的应用程序,通常关注应用程序级配置和 [ Service] ( /zh-cn/docs/concepts/services-networking/service/ ) 组合。
55+ * ** 应用程序开发人员:** 管理在集群中运行的应用程序,通常关注应用程序级配置和
56+ [ Service] ( /zh-cn/docs/concepts/services-networking/service/ ) 组合。
5757
5858<!--
5959* __Portable:__ Gateway API specifications are defined as [custom resources](/docs/concepts/extend-kubernetes/api-extension/custom-resources)
@@ -73,11 +73,11 @@ Gateway API 的设计和架构遵从以下原则:
7373<!--
7474## Resource model
7575
76- Gateway API has three stable API kinds:
76+ Gateway API has four stable API kinds:
7777-->
7878## 资源模型 {#resource-model}
7979
80- Gateway API 具有三种稳定的 API 类别:
80+ Gateway API 具有四种稳定的 API 类别:
8181
8282<!--
8383* __GatewayClass:__ Defines a set of gateways with common configuration and managed by a controller
@@ -93,7 +93,15 @@ Gateway API 具有三种稳定的 API 类别:
9393
9494* ** Gateway:** 定义流量处理基础设施(例如云负载均衡器)的一个实例。
9595
96- * ** HTTPRoute:** 定义特定于 HTTP 的规则,用于将流量从网关监听器映射到后端网络端点的表示。
96+ * ** HTTPRoute:** 定义特定于 HTTP 的规则,用于将流量从 Gateway 监听器映射到后端网络端点的某种呈现。
97+ 这些端点通常表示为 {{<glossary_tooltip text="Service" term_id="service">}}。
98+
99+ <!--
100+ * __GRPCRoute:__ Defines gRPC-specific rules for mapping traffic from a Gateway listener to a
101+ representation of backend network endpoints. These endpoints are often represented as a
102+ {{<glossary_tooltip text="Service" term_id="service">}}.
103+ -->
104+ * ** GRPCRoute:** 定义特定于 gRPC 的规则,用于将流量从 Gateway 监听器映射到后端网络端点的某种呈现。
97105 这些端点通常表示为 {{<glossary_tooltip text="Service" term_id="service">}}。
98106
99107<!--
@@ -108,7 +116,6 @@ Gateway API 被组织成不同的 API 类别,这些 API 类别具有相互依
108116各个(可以是多个)路由类别(例如 HTTPRoute)可以关联到此 Gateway 对象。
109117Gateway 可以对能够挂接到其 ` listeners ` 的路由进行过滤,从而与路由形成双向信任模型。
110118
111-
112119<!--
113120The following figure illustrates the relationships of the three stable Gateway API kinds:
114121
@@ -252,12 +259,100 @@ See the [HTTPRoute](https://gateway-api.sigs.k8s.io/references/spec/#gateway.net
252259reference for a full definition of this API kind.
253260-->
254261在此示例中,来自 Gateway `example-gateway` 的 HTTP 流量,
255- 如果 Host 的标头设置为 `www.example.com` 且请求路径指定为 `/login`,
262+ 如果 ` Host:` 的标头设置为 `www.example.com` 且请求路径指定为 `/login`,
256263将被路由到 Service `example-svc` 的 `8080` 端口。
257264
258265有关此类 API 的完整定义,请参阅
259266[HTTPRoute](https://gateway-api.sigs.k8s.io/references/spec/#gateway.networking.k8s.io/v1.HTTPRoute)。
260267
268+ # ## GRPCRoute {#api-kind-grpcroute}
269+
270+ <!--
271+ The GRPCRoute kind specifies routing behavior of gRPC requests from a Gateway listener to backend network
272+ endpoints. For a Service backend, an implementation may represent the backend network endpoint as a Service
273+ IP or the backing EndpointSlices of the Service. A GRPCRoute represents configuration that is applied to the
274+ underlying Gateway implementation. For example, defining a new GRPCRoute may result in configuring additional
275+ traffic routes in a cloud load balancer or in-cluster proxy server.
276+ -->
277+ GRPCRoute 类别给出将 gRPC 请求从 Gateway 监听器转发到后端网络端点的路由行为。
278+ 对于 Service 后端,其中一种实现方式可以将后端网络端点表示为 Service IP,
279+ 或支撑此 Service 的若干 EndpointSlice。GRPCRoute 表示的是一些要应用于底层 Gateway 实现的配置。
280+ 例如,定义一个新的 GRPCRoute 的操作可能会意味着要在云负载均衡器或集群内代理服务器中配置额外的流量路由。
281+
282+ <!--
283+ Gateways supporting GRPCRoute are required to support HTTP/2 without an initial upgrade from HTTP/1,
284+ so gRPC traffic is guaranteed to flow properly.
285+
286+ A minimal GRPCRoute example :
287+ -->
288+ 支持 GRPCRoute 的 Gateway 必须支持 HTTP/2,且无需从 HTTP/1 升级,以确保 gRPC 流量能够正常传输。
289+
290+ 以下是一个精简的 GRPCRoute 示例:
291+
292+ ` ` ` yaml
293+ apiVersion: gateway.networking.k8s.io/v1
294+ kind: GRPCRoute
295+ metadata:
296+ name: example-grpcroute
297+ spec:
298+ parentRefs:
299+ - name: example-gateway
300+ hostnames:
301+ - "svc.example.com"
302+ rules:
303+ - backendRefs:
304+ - name: example-svc
305+ port: 50051
306+ ` ` `
307+
308+ <!--
309+ In this example, gRPC traffic from Gateway `example-gateway` with the host set to `svc.example.com`
310+ will be directed to the service `example-svc` on port `50051` from the same namespace.
311+
312+ GRPCRoute allows matching specific gRPC services, as per the following example :
313+ -->
314+ 在此示例中,来自 Gateway `example-gateway` 且主机设置为 `svc.example.com` 的 gRPC
315+ 流量将被定向到同一名字空间中 `example-svc` 服务的 `50051` 端口上。
316+
317+ GRPCRoute 允许匹配特定的 gRPC 服务,如下所示:
318+
319+ ` ` ` yaml
320+ apiVersion: gateway.networking.k8s.io/v1
321+ kind: GRPCRoute
322+ metadata:
323+ name: example-grpcroute
324+ spec:
325+ parentRefs:
326+ - name: example-gateway
327+ hostnames:
328+ - "svc.example.com"
329+ rules:
330+ - matches:
331+ - method:
332+ service: com.example
333+ method: Login
334+ backendRefs:
335+ - name: foo-svc
336+ port: 50051
337+ ` ` `
338+
339+ <!--
340+ In this case, the GRPCRoute will match any traffic for svc.example.com and apply its routing rules
341+ to forward the traffic to the correct backend. Since there is only one match specified,only requests
342+ for the com.example.User.Login method to svc.example.com will be forwarded.
343+ RPCs of any other method` will not be matched by this Route.
344+
345+ See the [GRPCRoute](https://gateway-api.sigs.k8s.io/reference/spec/#grpcroute)
346+ reference for a full definition of this API kind.
347+ -->
348+ 在这种情况下,GRPCRoute 将匹配发往 `svc.example.com` 的所有流量,
349+ 并应用其路由规则将流量转发到正确的后端。由于仅指定了一个匹配条件,只有发往
350+ ` svc.example.com` 的 `com.example.User.Login` 方法请求会被转发。
351+ 其他请求方法的 RPC 调用都不会被此路由匹配。
352+
353+ 有关这种 API 类别的完整定义,请参阅
354+ [GRPCRoute](https://gateway-api.sigs.k8s.io/reference/spec/#grpcroute) 参考文档。
355+
261356<!--
262357# # Request flow
263358
@@ -288,9 +383,9 @@ In this example, the request flow for a Gateway implemented as a reverse proxy i
288383 based on filter rules of the HTTPRoute.
2893846. Lastly, the reverse proxy forwards the request to one or more backends.
290385-->
291- 1. 客户端开始准备 URL 为 `http://www.example.com` 的 HTTP 请求
386+ 1. 客户端开始准备 URL 为 `http://www.example.com` 的 HTTP 请求。
2923872. 客户端的 DNS 解析器查询目标名称并了解与 Gateway 关联的一个或多个 IP 地址的映射。
293- 3. 客户端向 Gateway IP 地址发送请求;反向代理接收 HTTP 请求并使用 Host :
388+ 3. 客户端向 Gateway IP 地址发送请求;反向代理接收 HTTP 请求并使用 ` Host:`
294389 标头来匹配基于 Gateway 和附加的 HTTPRoute 所获得的配置。
2953904. 可选的,反向代理可以根据 HTTPRoute 的匹配规则进行请求头和(或)路径匹配。
2963915. 可选地,反向代理可以修改请求;例如,根据 HTTPRoute 的过滤规则添加或删除标头。
0 commit comments