<p>I am trying to setup an <a href="https://kubernetes.github.io/ingress-nginx/" rel="nofollow noreferrer">nginx kubernetes ingress</a>. I am able to serve http and websockets content on different routes at the moment.</p>
<p>However I am not able to add GRPC routes on the same host. Adding this annotation <code>nginx.ingress.kubernetes.io/backend-protocol: &quot;GRPC&quot;</code> breaks the existing routes.</p>
<p>My java GRPC client exits with
<code>Caused by: io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2Exception: First received frame was not SETTINGS. Hex dump for first 5 bytes: 485454502f</code>
According to <a href="https://github.com/grpc/grpc-java/issues/2905" rel="nofollow noreferrer">https://github.com/grpc/grpc-java/issues/2905</a> this means the request is seen as HTTP</p>
<p>Is there a way to have http/websocket/grpc routes on the same host using the nginx kubernetes ingress? Alternatively, is there another ingress with which this would work?</p>

nha
<p>As you want the annotation <code>nginx.ingress.kubernetes.io/backend-protocol: &quot;GRPC&quot;</code> to apply only on certain routes of your host, you could declare two Ingress definitions. The first one for all HTTP routes, the second one for GRPC routes.</p>
<p>The Nginx Ingress Controller will pick all the Ingress definitions (with the expected <code>IngressClass</code>) and will use them to compose the <code>nginx.conf</code>. This behaviour is perfect to have the possibility of having paths which requires different tunings in the annotations, like rewrite targets or, in your case, different backend protocols.</p>
<p>In particular, from the Nginx Controller documentation:</p>
<blockquote>
<p>Multiple Ingresses can define different annotations. These definitions
are not shared between Ingresses.</p>
</blockquote>
<p>You can check all the steps which are used to build the <code>nginx.conf</code> in the docs: <a href="https://kubernetes.github.io/ingress-nginx/how-it-works/#building-the-nginx-model" rel="nofollow noreferrer">https://kubernetes.github.io/ingress-nginx/how-it-works/#building-the-nginx-model</a></p>
