我正在尝试公开用.NETCORE3.0
编写并打包为Linux docker映像的gRPC后端服务。我在localhost中测试了该服务,并且一切正常。但是,我无法使用istio从GKE进行访问(我已将GKE集群更新为2019年7月27日的最新版本)。我正在将gRPC-Web
与react.js
结合使用。每次尝试访问时,我都遇到503
错误。查看女服务生的日志,我看到与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
---
这是Dockerfile 从mcr.microsoft.com/dotnet/core/aspnet:3.0-buster-slim AS基础 WORKDIR / app 展览80 展览443
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"]
答案 0 :(得分:0)
您可以像这样在服务端口名称中写入“ grpc-web”。
console.log(results.length)
Istio /协议选择: https://istio.io/docs/ops/configuration/traffic-management/protocol-selection/