<p>Good Morning. I have a GRPC server that I want to serve on Google Kubernetes Engine. My cluster already has the <code>nginx-ingress</code> controller installed, and I'm currently using this to serve http/https traffic. This is the ingress resource I've tried to make to host the GRPC server:</p>

<pre><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: grpc-ingress-nginx
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/backend-protocol: "GRPC"
    cert-manager.io/cluster-issuer: "letsencrypt-prod"
    nginx.ingress.kubernetes.io/grpc-backend: "true"
    nginx.ingress.kubernetes.io/ssl-redirect: "true"
  namespace: default
spec:
  tls:
  - hosts:
    - bar.foo.com
    secretName: reploy-tls
  rules:
  - host: bar.foo.com
    http:
      paths:
      - backend:                                                                                                                                                                                                      
          serviceName: bar-backend-service
          servicePort: 50051
</code></pre>

<p>And here's the service/deployment for the app:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: bar-backend-service
  namespace: default
spec:
  selector:
    app: bar-backend-app
  ports:
  - port: 50051
    targetPort: 50051
    name: grpc
---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: bar-backend
  labels:
    app: bar-backend-app
  namespace: default
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: bar-backend-app
    spec:
      containers:
      - name: bar-backend-image
        image: gcr.io/himank-jay/bar-backend-image:TAG
        ports:
        - containerPort: 50051
          name: grpc
</code></pre>

<p>When I run <code>grpc_cli ls bar.foo.com:443</code> (using <a href="https://github.com/grpc/grpc/blob/master/doc/command_line_tool.md" rel="nofollow noreferrer">grpc_cli</a>), I get the following error: </p>

<pre><code>{"created":"@1580833741.460274000","description":"Error received from peer ipv4:x.x.x.x:x","file":"src/core/lib/surface/call.cc","file_line":1055,"grpc_message":"Socket closed","grpc_status":14}
</code></pre>

<p>And the error from the <code>nginx-controller</code> is as follows:</p>

<pre><code>x.x.x.x - - [04/Feb/2020:16:28:46 +0000] "PRI * HTTP/2.0" 400 157 "-" "-" 0 0.020 [] [] - - - - xxxxx
</code></pre>

<p>Any ideas on what's wrong here? Or any thoughts on how to debug this?</p>

Jay K.
<p>The server is serving HTTP/1.x, not HTTP/2 that's required for gRPC.</p>

<p>You can try adding the following annotation to the <code>Ingress</code> config</p>

<pre><code>nginx.ingress.kubernetes.io/backend-protocol: "GRPC"
</code></pre>

<p>...as explained <a href="https://github.com/kubernetes/ingress-nginx/tree/master/docs/examples/grpc#step-3-the-kubernetes-ingress" rel="nofollow noreferrer">here</a>.</p>

<p>It is also worth checking the <code>use-http2</code> flag in the nginx <a href="https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/#use-http2" rel="nofollow noreferrer">configuration</a> (it should be enabled, <code>true</code>, by default).</p>

<hr>

<p>EDIT, regarding the new error:</p>

<p><code>PRI * HTTP/2.0</code> is the so-called <a href="https://httpwg.org/specs/rfc7540.html#rfc.section.3.5" rel="nofollow noreferrer">HTTP/2 Connection Preface</a> - part of negotiating HTTP/2. It still appears that nginx isn't configured for HTTP/2.</p>
