Kubernetes grpc http 2error

问题描述 投票:1回答:1

我在eks上部署了grpc服务,并使用ingress公开了该服务。我部署了一个演示https应用程序,它可以正常工作。但是,grpc应用程序有问题。该服务正在运行,但是当我登录该服务时出现错误。 grpc请求甚至不会发送到服务器。日志如下

level = info msg =“ grpc:Server.Serve无法创建ServerTransport:连接错误:desc = \“传输:http2Server.HandleStreams收到来自客户端的虚假问候:\\“ GET / HTTP / 1.1 \\ r \\ n主机:19 \\“ \”“ system = system

似乎它应该收到http2,但是它只有HTTP/1.1 ??

我尝试过的入口

    alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}, {"HTTPS":443}]'
    alb.ingress.kubernetes.io/actions.ssl-redirect: '{"Type": "redirect", "RedirectConfig": { "Protocol": "HTTPS", "Port": "443", "StatusCode": "HTTP_301"}}'
    alb.ingress.kubernetes.io/certificate-arn: arn:aws:acm:xxxx
    alb.ingress.kubernetes.io/load-balancer-attributes: 'routing.http2.enabled=true'

for service.yml

  annotations:
    service.alpha.kubernetes.io/app-protocols: '{"grpc":"HTTP2", "http": "HTTP2"}'

对于已部署的服务,看起来不错。一旦部署了Ingress,它始终会出现上述错误。

kubernetes grpc http2 aws-load-balancer
1个回答
0
投票

不确定Ingress是否支持HTTP2 / gRPC。如果您使用的是GKE,则可以尝试ESP


0
投票

您需要注释Service,以便Ingress负载均衡器将其视为HTTP2服务。将注释cloud.google.com/app-protocols: '{<port-name>:"HTTP2"}'添加到您的服务中。

apiVersion: v1
kind: Service
metadata:
  annotations:
    cloud.google.com/app-protocols: '{"http2-port":"HTTP2"}'
  name: myapp
  labels:
    app: myapp
spec:
  type: NodePort
  ports:
  - port: 443
    protocol: TCP
    name: http2-port
  selector:
    app: myapp

请参见HTTP/2 for load balancing with Ingress

© www.soinside.com 2019 - 2024. All rights reserved.