0

我正在尝试公开一个 gRPC 后端服务,该服务是.NETCORE3.0用 linux docker 映像编写并打包的。我在 localhost 中测试了该服务,一切都按预期工作。但是,我无法使用 istio 从 GKE 访问(我已将我的 GKE 集群更新到 2019 年 7 月 27 日的最新版本)。我正在使用gRPC-Webwith使用服务react.js。每次我503尝试访问时都会出错。查看 istioingress 日志,我看到这一行与503

[2019-07-28 15:18:57.131][22][warning][upstream] [external/envoy/source/common/upstream/original_dst_cluster.cc:110] original_dst_load_balancer: No downstream connection or no original_dst.

我下面的配置有什么问题吗?

apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
  name: grpc-web-filter
spec:
  workloadLabels:
    app: users
  filters:
  - listenerMatch:
      listenerType: SIDECAR_INBOUND
      listenerProtocol: HTTP
    insertPosition:
      index: FIRST
    filterType: HTTP
    filterName: "envoy.grpc_web"
    filterConfig: {}

apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: users
spec:
  host: users
  subsets:
  - name: v1
    labels:
      version: v1
---
###########################################################################
# Ingress resource (gateway)
##########################################################################
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: sf-gateway
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "*"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: usersvs
spec:
  hosts:
  - "*"
  gateways:
  - sf-gateway
  http:
  - match:
    - uri:
        prefix: /xxx.common.users.UserService
    - port: 80
    route:
    - destination:
        host: users.default.svc.cluster.local
        port:
          number: 80
        subset: v1
    corsPolicy:
      allowOrigin:
        - "*"
      allowMethods:
        - POST
        - GET
        - OPTIONS
        - PUT
        - DELETE
      allowHeaders:
        - grpc-timeout
        - content-type
        - keep-alive
        - user-agent
        - cache-control
        - content-type
        - content-transfer-encoding
        - custom-header-1
        - x-accept-content-transfer-encoding
        - x-accept-response-streaming
        - x-user-agent
        - x-grpc-web
      maxAge: 1728s
      exposeHeaders:
        - custom-header-1
        - grpc-status
        - grpc-message
      allowCredentials: true
---

##################################################################################################
# users service
##################################################################################################
apiVersion: v1
kind: Service
metadata:
  name: users
  labels:
    app: users
spec:
  ports:
  - name: grpc-port
    port: 80
  selector:
    app: users
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: users
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: users
        version: v1
    spec:
      containers:
      - name: users
        image: ***
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 80
---

这是来自 mcr.microsoft.com/dotnet/core/aspnet:3.0-buster-slim AS base WORKDIR /app EXPOSE 80 EXPOSE 443 的 Dockerfile

FROM mcr.microsoft.com/dotnet/core/sdk:3.0-buster AS build
WORKDIR /src
COPY ["UserService/XXX.Users.csproj", "UserService/"]
COPY ["ShowFam.Common/ShowFam.Common.csproj", "ShowFam.Common/"]
RUN dotnet restore "UserService/XXX.Users.csproj"
COPY . .
WORKDIR "/src/UserService"
RUN dotnet build "XXX.Users.csproj" -c Release -o /app

FROM build AS publish
RUN dotnet publish "XXX.Users.csproj" -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "XXX.Users.dll"]
4

1 回答 1

1

您可以像这样在服务端口名称中写入“grpc-web”。

apiVersion: v1
kind: Service
metadata:
  name: echo-service
spec:
  type: ClusterIP
  ports:
    - name: grpc-web # istio refers this value as protocol
      port: 80
      targetPort: 9090
  selector:
    app: echo-service-worker

Istio/协议选择: https ://istio.io/docs/ops/configuration/traffic-management/protocol-selection/

于 2020-03-22T07:28:16.497 回答