This is a cache of https://docs.openshift.com/serverless/1.32/knative-serving/external-ingress-routing/using-http2-gRPC.html. It is a snapshot of the page at 2024-11-22T16:47:20.070+0000.
Using HTTP2 and gRPC - External and <strong>ingress</strong> routing | Serving | Red Hat OpenShift Serverless 1.32
×

OpenShift Serverless supports only insecure or edge-terminated routes. Insecure or edge-terminated routes do not support HTTP2 on OpenShift Container Platform. These routes also do not support gRPC because gRPC is transported by HTTP2. If you use these protocols in your application, you must call the application using the ingress gateway directly. To do this you must find the ingress gateway’s public address and the application’s specific host.

Interacting with a serverless application using HTTP2 and gRPC

This method applies to OpenShift Container Platform 4.10 and later. For older versions, see the following section.

Prerequisites
  • Install OpenShift Serverless Operator and Knative Serving on your cluster.

  • Install the OpenShift CLI (oc).

  • Create a Knative service.

  • Upgrade OpenShift Container Platform 4.10 or later.

  • Enable HTTP/2 on OpenShift ingress controller.

Procedure
  1. Add the serverless.openshift.io/default-enable-http2=true annotation to the KnativeServing Custom Resource:

    $ oc annotate knativeserving <your_knative_CR> -n knative-serving serverless.openshift.io/default-enable-http2=true
  2. After the annotation is added, you can verify that the appProtocol value of the Kourier service is h2c:

    $ oc get svc -n knative-serving-ingress kourier -o jsonpath="{.spec.ports[0].appProtocol}"
    Example output
    h2c
  3. Now you can use the gRPC framework over the HTTP/2 protocol for external traffic, for example:

    import "google.golang.org/grpc"
    
    grpc.Dial(
       YOUR_URL, (1)
       grpc.WithTransportCredentials(insecure.NewCredentials())), (2)
    )
    1 Your ksvc URL.
    2 Your certificate.