@@ -39,7 +39,7 @@ The following principles shaped the design and architecture of Gateway API:
39
39
40
40
## Resource model
41
41
42
- Gateway API has three stable API kinds:
42
+ Gateway API has four stable API kinds:
43
43
44
44
* __ GatewayClass:__ Defines a set of gateways with common configuration and managed by a controller
45
45
that implements the class.
@@ -50,6 +50,10 @@ Gateway API has three stable API kinds:
50
50
representation of backend network endpoints. These endpoints are often represented as a
51
51
{{<glossary_tooltip text="Service" term_id="service">}}.
52
52
53
+ * __ GRPCRoute:__ Defines gRPC-specific rules for mapping traffic from a Gateway listener to a
54
+ representation of backend network endpoints. These endpoints are often represented as a
55
+ {{<glossary_tooltip text="Service" term_id="service">}}.
56
+
53
57
Gateway API is organized into different API kinds that have interdependent relationships to support
54
58
the role-oriented nature of organizations. A Gateway object is associated with exactly one GatewayClass;
55
59
the GatewayClass describes the gateway controller responsible for managing Gateways of this class.
@@ -150,6 +154,69 @@ and the request path specified as `/login` will be routed to Service `example-sv
150
154
See the [HTTPRoute](https://gateway-api.sigs.k8s.io/references/spec/#gateway.networking.k8s.io/v1.HTTPRoute)
151
155
reference for a full definition of this API kind.
152
156
157
+
158
+ # ## GRPCRoute {#api-kind-grpcroute}
159
+
160
+ The GRPCRoute kind specifies routing behavior of gRPC requests from a Gateway listener to backend network
161
+ endpoints. For a Service backend, an implementation may represent the backend network endpoint as a Service
162
+ IP or the backing EndpointSlices of the Service. A GRPCRoute represents configuration that is applied to the
163
+ underlying Gateway implementation. For example, defining a new GRPCRoute may result in configuring additional
164
+ traffic routes in a cloud load balancer or in-cluster proxy server.
165
+
166
+ Gateways supporting GRPCRoute are required to support HTTP/2 without an initial upgrade from HTTP/1,
167
+ so gRPC traffic is guaranteed to flow properly.
168
+
169
+ A minimal GRPCRoute example :
170
+
171
+ ` ` ` yaml
172
+ apiVersion: gateway.networking.k8s.io/v1
173
+ kind: GRPCRoute
174
+ metadata:
175
+ name: example-grpcroute
176
+ spec:
177
+ parentRefs:
178
+ - name: example-gateway
179
+ hostnames:
180
+ - "svc.example.com"
181
+ rules:
182
+ - backendRefs:
183
+ - name: example-svc
184
+ port: 50051
185
+ ` ` `
186
+
187
+ In this example, gRPC traffic from Gateway `example-gateway` with the host set to `svc.example.com`
188
+ will be directed to the service `example-svc` on port `50051` from the same namespace.
189
+
190
+ GRPCRoute allows matching specific gRPC services, as per the following example :
191
+
192
+ ` ` ` yaml
193
+ apiVersion: gateway.networking.k8s.io/v1
194
+ kind: GRPCRoute
195
+ metadata:
196
+ name: example-grpcroute
197
+ spec:
198
+ parentRefs:
199
+ - name: example-gateway
200
+ hostnames:
201
+ - "svc.example.com"
202
+ rules:
203
+ - matches:
204
+ - method:
205
+ service: com.example
206
+ method: Login
207
+ backendRefs:
208
+ - name: foo-svc
209
+ port: 50051
210
+ ` ` `
211
+
212
+ In this case, the GRPCRoute will match any traffic for svc.example.com and apply its routing rules
213
+ to forward the traffic to the correct backend. Since there is only one match specified,only requests
214
+ for the com.example.User.Login method to svc.example.com will be forwarded.
215
+ RPCs of any other method` will not be matched by this Route.
216
+
217
+ See the [GRPCRoute](https://gateway-api.sigs.k8s.io/reference/spec/#grpcroute)
218
+ reference for a full definition of this API kind.
219
+
153
220
# # Request flow
154
221
155
222
Here is a simple example of HTTP traffic being routed to a Service by using a Gateway and an HTTPRoute :
0 commit comments