简体   繁体   English

一条路径的 kubernetes nginx 入口 GRPC

[英]kubernetes nginx ingress GRPC for one path

I am trying to setup an nginx kubernetes ingress .我正在尝试设置nginx kubernetes ingress I am able to serve http and websockets content on different routes at the moment.我目前能够在不同的路线上提供 http 和 websockets 内容。

However I am not able to add GRPC routes on the same host.但是我无法在同一主机上添加 GRPC 路由。 Adding this annotation nginx.ingress.kubernetes.io/backend-protocol: "GRPC" breaks the existing routes.添加此注释nginx.ingress.kubernetes.io/backend-protocol: "GRPC"会破坏现有路由。

My java GRPC client exits with 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我的 java GRPC 客户端退出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 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 According to https://github.com/grpc/grpc-java/issues/2905 this means the request is seen as HTTP 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根据https://github.com/grpc/grpc-java/issues/2905这意味着请求被视为 HTTP

Is there a way to have http/websocket/grpc routes on the same host using the nginx kubernetes ingress?有没有办法使用 nginx kubernetes 入口在同一主机上拥有 http/websocket/grpc 路由? Alternatively, is there another ingress with which this would work?或者,是否有另一个入口可以使用它?

As you want the annotation nginx.ingress.kubernetes.io/backend-protocol: "GRPC" to apply only on certain routes of your host, you could declare two Ingress definitions.由于您希望注释nginx.ingress.kubernetes.io/backend-protocol: "GRPC"仅适用于主机的某些路由,因此您可以声明两个 Ingress 定义。 The first one for all HTTP routes, the second one for GRPC routes.第一个用于所有 HTTP 路由,第二个用于 GRPC 路由。

The Nginx Ingress Controller will pick all the Ingress definitions (with the expected IngressClass ) and will use them to compose the nginx.conf . Nginx Ingress Controller 将选择所有 Ingress 定义(带有预期的IngressClass ),并将使用它们来组成nginx.conf 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.这种行为非常适合具有需要在注释中进行不同调整的路径的可能性,例如重写目标,或者在您的情况下,需要不同的后端协议。

In particular, from the Nginx Controller documentation:特别是,来自 Nginx Controller 文档:

Multiple Ingresses can define different annotations.多个 Ingress 可以定义不同的注解。 These definitions are not shared between Ingresses.这些定义不在 Ingress 之间共享。

You can check all the steps which are used to build the nginx.conf in the docs: https://kubernetes.github.io/ingress-nginx/how-it-works/#building-the-nginx-model您可以在文档中查看用于构建nginx.conf的所有步骤: https://kubernetes.github/#building-the-nginx/how-itworks/#building-the-nginx/how-itworks

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM