GRPCRoute policy attachment
Beginning with Connectivity Link 1.4.0, GRPCRoute policy attachment is supported.
You can now use GRPCRoute custom resources (CRs) for your Remote Procedure Call (gRPC)-native applications and services in all of your Connectivity Link policies except TokenRateLimitPolicy CRs. You can migrate existing policies after you create your GRPCRoute CRs.
|
Important
|
|
Connectivity Link policies can now target GRPCRoute resources with the targetRef parameter. Specifically, AuthPolicy and RateLimitPolicy accept GRPCRoute as a valid target kind. The following well-known attributes are also available for Common Expression Language (CEL) expressions:
-
request.grpc.service: Represents the exact service being called. -
request.grpc.method: Represents the exact function being executed.
Using a GRPCRoute CR instead of an HTTPRoute CR when you already have a gRPC service can be an advantage in the following scenarios:
-
Native
serviceormethodmatching in routing rules instead of raw path patterns. -
Clearer intent. The route type declares that this is a gRPC service, making the topology more readable.
-
Gateway API validation.
GRPCMethodMatchenforces validserviceormethodstructure rather than free-form path strings.
The following CRs support GRPCRoute CRs in their targetRef fields:
-
AuthPolicy CRs
-
RateLimitPolicy CRs
DNSPolicy and TLSPolicy policies cover attached GRPCRoute CRs automatically.
Telemetry works with GRPCRoute CRs with no updates required. Although telemetry objects target the Gateway object, telemetry captures and reports on gRPC traffic matched by attached GRPCRoute CRs. You have the same level of observability for gRPC traffic as you currently do for traffic routed through HTTPRoute CRs.
|
Important
|
Ensure that there is not a mismatch between your Envoy proxy layer and upstream application layers in performing URL normalization. Envoy serves raw request paths to the However, your application receives the requests. That upstream service can strip redundant slashes or decode URL-encoded values. This means it bypasses your configuration, serving the protected route. Make sure that you configure your upstream service so that you do not unintentionally bypass your own security. For more information, see "Customize your system on path normalization" in the Istio documentation. |
Create a GRPCRoute custom resource
You can implement policy attachments based on qualified service and method names by using GRPCRoute policy attachment support. First, you must create a GRPCRoute custom resource (CR).
|
Important
|
|
-
You installed OpenShift Container Platform.
-
You installed OpenShift CLI (
oc). -
You installed the MCP gateway Operator.
-
You created a
Gatewayobject.
-
Create a
GRPCRouteYAML by using the following example:Example GRPCRoute CRapiVersion: gateway.networking.k8s.io/v1 kind: GRPCRoute metadata: name: <grpcstore> spec: parentRefs: - name: <kuadrant_ingressgateway> namespace: <gateway_system> hostnames: [<"grpc.example.com">] rules: - matches: - method: service: <"talker.TalkerService"> method: <"Echo"> backendRefs: - name: grpcstore port: 9000See the "GRPCRoute custom resource parameters" reference information for details about parameters.
ImportantIf you include a
spec.rules.matches.methodblock, you must specify aservicename, amethodname, or both. Omitting the method block entirely matches all gRPC traffic. -
Apply your
GRPCRouteCR by running the following command:$ oc apply -f <grpcstore_route.yaml>Replace
<grpcstore_route.yaml>with the name of your gRPC YAML.Example outputgrpcroute.gateway.networking.k8s.io/grpcstore-route createdThe output indicates that the route to the object exists.
-
Create your policies with
targetRefvalues that reference yourGRPCRouteCR. -
If you are migrating
HTTPRouteCRs toGRPCRouteCRs, update existing policies to reference yourGRPCRouteCR.
GRPCRoute custom resource parameters
You can use the following information about parameters and their values to create a GRPCRoute custom resource (CR) for Connectivity Link.
| Parameter | Definition and Details |
|---|---|
|
The gRPC route name. Replaceable value. |
|
The name of the |
|
List of your public DNS entries. Define this to match the DNS records pointing to your cluster. |
|
Use this parameter value if your |
|
The fully qualified name of the gRPC service from your |
|
Use if you want a highly precise filter to isolate a specific function. You must specify at least one value for the |
|
Point to your application pod. Replace the example values with the name of the service that is running your gRPC application and the port that your application service is listening on. |
Migrate policies to GRPCRoute support
|
Important
|
|
When you want to replace your HTTPRoute custom resources (CRs) with GRPCRoute CRs, you must update your policies to reference a GRPCRoute CR. You must also configure other parameters in those policies as required for your use case.
|
Important
|
A |
-
You installed OpenShift Container Platform.
-
You installed OpenShift CLI (
oc). -
You installed the MCP gateway Operator.
-
You created a Gateway object.
-
You have an existing
HTTPRouteCR routing traffic to a gRPC service.
-
Delete your
HTTPRouteCRs. You must remove theHTTPRouteCR must before you can use theGRPCRouteCR on the same hostname. -
Update the
spec.targetRef.kindparameter value in yourAuthPolicyandRateLimitPolicyCRs toGRPCRouteby using the following example:ExampleAuthPolicyCR updated to gRPC#... spec: targetRef: group: gateway.networking.k8s.io kind: GRPCRoute name: grpcstore #...