【问题标题】:GRPC service inside Kubernetes is working but fails with an GRPC protocol error when we use istioKubernetes 中的 GRPC 服务正在运行,但是当我们使用 istio 时出现 GRPC 协议错误而失败
【发布时间】:2022-01-02 05:30:57
【问题描述】:

我有一个服务器到服务器的调用,我使用 GRPC(使用 .net core 5)它在本地工作和测试。

之后,我将所有服务移至 Kubernetes Pod(Docker 桌面),并通过流程进行了测试(使用 swagger post-call),它也可以在那里工作。

现在为了监控,我添加了 ISTIO 并将标签添加到我的命名空间“istio-injection=enabled” 重新启动了我所有的 pod,现在每个 pod 中都有 2 个容器。

我测试了基本服务(再次大摇大摆)并且它正在工作。在测试 GRPC 调用时。呼叫方说呼叫失败

Grpc.Core.RpcException: Status(StatusCode="Unavailable", Detail="upstream connect error or disconnect/reset before headers.reset reason: protocol error")

我检查了 GRPC 服务器端的日志,它没有关于此调用的任何线索,并且服务正在运行。那么我有点认为错误来自调用方,而它无法或无法调用 GRPC 服务器。

错误详情:

Grpc.Core.RpcException: Status(StatusCode="Unavailable", Detail="upstream connect error or disconnect/reset before headers. reset reason: protocol error") 
at Basket.API.GrpcServices.DiscountGrpcService.GetDiscount(String productName) in /src/Services/Basket/Basket.API/GrpcServices/DiscountGrpcService.cs:line 21 
at Basket.API.Controllers.BasketController.UpdateBasket(ShoppingCart basket) in /src/Services/Basket/Basket.API/Controllers/BasketController.cs:line 47 at lambda_method7(Closure , Object ) 
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Obje

再次,我删除了 Istio 并进行了测试,它又开始工作了(没有改变任何东西)我重新添加了 istio,它又开始失败了。所有其他服务都在使用 istio 但不是这个调用(这只是我有的 GRPC 调用)。

【问题讨论】:

  • 你是如何安装 istio 和配置的?是否禁用了 mTLS 和其他协议配置?
  • 尝试检查这个很好的例子,它将注入 istio sidecar 作为 Pilot 而不是 envoy:github.com/istio/istio/tree/master/samples/grpc-echo
  • 太奇怪了。我在istiobyexample.dev/grpc 找到了答案 - 名称:grpc #important!
  • @BrijeshShah 你找到解决方案了吗?如果是这样,请将其作为答案发布并接受。

标签: kubernetes grpc istio grpc-web istio-kiali


【解决方案1】:

我在 https://istiobyexample.dev/grpc/ 找到了一个解决方案,它描述了丢失的项目。

istio 建议使用名称和版本标记作为 Label,但更重要的是,在使用 GRPC 时,暴露 GRPC 的服务需要具有端口名称 GRPC。

我添加了重新启动服务并按预期开始工作。 同样,这不是我解决的问题。所有功劳都归于链接https://istiobyexample.dev/grpc/ 和下面发布的图片。

【讨论】:

    猜你喜欢
    • 2022-01-22
    • 2020-04-28
    • 2021-08-16
    • 2020-02-09
    • 1970-01-01
    • 2020-06-16
    • 2020-07-07
    • 1970-01-01
    • 2017-05-14
    相关资源
    最近更新 更多