【问题标题】:ingress does not work with GRPC gateway. HTTP requests are not being forwarded to GRPC gateway as expected by the ingressingress 不适用于 GRPC 网关。 HTTP 请求没有按照入口的预期转发到 GRPC 网关
【发布时间】:2020-07-14 11:41:00
【问题描述】:

我已经设置了一个 GRPC 网关,其中包含与 HTTP URL 对应的所有方法。例如v1/my-service。这些路径似乎不适用于我设置的入口。我可以通过使用另一个 pod 来间接发送请求,以使用内部集群 IP 将请求路由到此 URL,但是当我尝试直接访问 my-ip/v1/myservice 时,我收到一个几乎没有描述的服务器错误:

Error: Server Error</h1>
<h2>The server encountered a temporary error and could not complete your request.<p>Please try again in 30 seconds.

出现这种情况有什么原因吗?当我知道传入的 URL 格式对应于网关中定义的方法时,我不明白为什么会以这种方式出现服务器错误。我想指出,我的 ingress 确实有效,因为我只是使用这个中间 pod 来路由成功的请求,但我仍然通过 ingress 发送它们。

【问题讨论】:

  • 您能分享一下您的入口规范吗?你使用的是 GKE 入口还是 nginx?

标签: kubernetes google-kubernetes-engine grpc kubernetes-ingress grpc-gateway


【解决方案1】:

您可能需要在 Ingress 资源上添加注释(?):

nginx.ingress.kubernetes.io/backend-protocol: "GRPC"

和 HTTP/2 入口控制器 ConfigMap option(?):

use-http2="true"

另外,检查 Nginx 入口控制器 pod 中的 nginx.conf

kubectl exec -it <nginx-ingress-pod> sh
# cat nginx.conf

您要检查是否在服务器级别配置了类似的内容:

    server {
        listen 80 http2;
 
        access_log logs/access.log main;
 
        location / {
            # Replace localhost:50051 with the address and port of your gRPC server
            # The 'grpc://' prefix is optional; unencrypted gRPC is the default
            grpc_pass grpc://localhost:50051;
        }
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-06-24
    • 2020-05-29
    • 2021-01-10
    • 2017-12-28
    • 2022-11-24
    • 1970-01-01
    • 2019-11-21
    • 2020-01-01
    相关资源
    最近更新 更多