The following example demonstrates a complete GRPCRoute resource configured with matching conditions for a specific gRPC service, method, and header:
apiVersion: gateway.networking.k8s.io/v1
kind: GRPCRoute
metadata:
name: grpc-match-example
namespace: my-application
spec:
parentRefs:
- name: my-gateway
namespace: openshift-ingress
hostnames:
- "example.com"
rules:
- matches:
- method:
service: helloworld.Greeter
method: SayHello
headers:
- name: x-version
value: v1
backendRefs:
- name: greeter-service
port: 50051
weight: 1
-
parentRefsattaches the route to themy-gatewayGateway. -
methodspecifies that the incoming request must be targeting thehelloworld.Greeterservice and specifically calling theSayHellomethod. -
headersrequires that the request must also include anx-versionheader with a value ofv1. Both the method and header conditions must be met for this rule to apply. -
backendRefsroutes the matching traffic to thegreeter-servicebackend.