Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google cloud platform 在Anthos上配置云运行以转发HTTP2_Google Cloud Platform_Grpc_Http2_Google Cloud Run_Google Anthos - Fatal编程技术网

Google cloud platform 在Anthos上配置云运行以转发HTTP2

Google cloud platform 在Anthos上配置云运行以转发HTTP2,google-cloud-platform,grpc,http2,google-cloud-run,google-anthos,Google Cloud Platform,Grpc,Http2,Google Cloud Run,Google Anthos,如何使Anthos的Cloud Run将传入的HTTP2请求作为HTTP2而不是HTTP/1.1转发到云运行服务 我正在使用GCP with Cloud Run for Anthos部署一个运行GRPC服务器的Java应用程序。云运行应用程序已公开。我还使用SSL证书为Anthos配置了Cloud Run。当我尝试使用GRPC客户端调用我的服务时,客户端通过HTTP2发送请求,负载平衡器接受该请求,但当该请求被转发到我的Cloud Run服务(运行GRPC服务器的Java应用程序)时,它以HTT

如何使Anthos的Cloud Run将传入的HTTP2请求作为HTTP2而不是HTTP/1.1转发到云运行服务

我正在使用GCP with Cloud Run for Anthos部署一个运行GRPC服务器的Java应用程序。云运行应用程序已公开。我还使用SSL证书为Anthos配置了Cloud Run。当我尝试使用GRPC客户端调用我的服务时,客户端通过HTTP2发送请求,负载平衡器接受该请求,但当该请求被转发到我的Cloud Run服务(运行GRPC服务器的Java应用程序)时,它以HTTP/1.1的形式出现,并被GRPC服务器拒绝。我假设在k8负载平衡器和我的k8 pod之间的某个地方,请求被作为HTTP/1.1转发,但我不知道如何解决这个问题。


描述如何配置命名端口以使HTTP/2工作

将@whlee的答案和他非常重要的后续评论结合起来,下面就是我要做的工作


必须使用gcloud cli进行部署才能更改命名端口。UI不允许您配置端口名。从服务yaml部署目前是一个测试版功能。要部署,请运行:
gcloud测试版运行services replace/path/To/service.yaml

在我的例子中,我的服务最初是使用GCP云控制台UI部署的,下面是我导出和替换的步骤

  • 将我的现有服务(名为hermes grpc)导出到yaml文件:
  • 编辑我的导出yaml并进行以下编辑:
  • 取代:

            ports:
            - containerPort: 6565
    
    与:

    删除以下行:

              tcpSocket:
                port: 0
    
    从节中删除了
    名称:

    spec:
      template:
        metadata:
    ...
          name:
    
  • 最后,从编辑的yaml重新部署服务:
  • 最后,我编辑的服务yaml如下所示:

    apiVersion: serving.knative.dev/v1alpha1
    kind: Service
    metadata:
      annotations:
        client.knative.dev/user-image: interledger4j/hermes-server:latest
        run.googleapis.com/client-name: cloud-console
      creationTimestamp: '2020-01-09T00:02:29Z'
      generation: 3
      name: hermes-grpc
      namespace: default
      selfLink: /apis/serving.knative.dev/v1alpha1/namespaces/default/services/hermes-grpc
    spec:
      template:
        metadata:
          annotations:
            autoscaling.knative.dev/maxScale: '2'
            autoscaling.knative.dev/minScale: '1'
            run.googleapis.com/client-name: cloud-console
        spec:
          containerConcurrency: 80
          containers:
            image: interledger4j/hermes-server:latest
            name: user-container
            ports:
              - name: h2c
                containerPort: 6565
            readinessProbe:
              successThreshold: 1
            resources:
              limits:
                cpu: 500m
                memory: 384Mi
          timeoutSeconds: 300
      traffic:
      - latestRevision: true
        percent: 100
    

    这并没有描述如何在云上运行,甚至在GCP上使用负载均衡器。Anthos上的Cloud Run会生成所有K8部署内容,您无法手动编辑。由@wlhee链接的示例有一个示例YAML文件,您可以在其中使用
    名称:h2c
    编辑
    端口
    部分。另一个例子是:你们不明白。cloudrun生成k8文件。没有编辑k8 yaml文件。甚至不可能。这个问题是专门关于云运行的。你是说没有办法用yank文件部署到云运行吗?云运行Anthos和完全管理都接受yaml specgcloud测试运行服务
    spec:
      template:
        metadata:
    ...
          name:
    
    gcloud beta run services replace hermes-grpc.yaml
    
    apiVersion: serving.knative.dev/v1alpha1
    kind: Service
    metadata:
      annotations:
        client.knative.dev/user-image: interledger4j/hermes-server:latest
        run.googleapis.com/client-name: cloud-console
      creationTimestamp: '2020-01-09T00:02:29Z'
      generation: 3
      name: hermes-grpc
      namespace: default
      selfLink: /apis/serving.knative.dev/v1alpha1/namespaces/default/services/hermes-grpc
    spec:
      template:
        metadata:
          annotations:
            autoscaling.knative.dev/maxScale: '2'
            autoscaling.knative.dev/minScale: '1'
            run.googleapis.com/client-name: cloud-console
        spec:
          containerConcurrency: 80
          containers:
            image: interledger4j/hermes-server:latest
            name: user-container
            ports:
              - name: h2c
                containerPort: 6565
            readinessProbe:
              successThreshold: 1
            resources:
              limits:
                cpu: 500m
                memory: 384Mi
          timeoutSeconds: 300
      traffic:
      - latestRevision: true
        percent: 100