我想知道如何才能匹配同一端口上的gRPC路由。下面是我希望用我的VirtualService完成的一个例子:
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: istio-ingress
spec:
hosts:
- "*"
gateways:
- istio-gateway
http:
- match:
- uri:
prefix: "/custom.api/stream"
- port: 31400
route:
- destination:
host: stream-handler.default.svc.cluster.local
port:
number: 8444
timeout: 60s
retries:
attempts: 3
perTryTimeout: 2s
- match:
- port: 31400
route:
- destination:
host: api.default.svc.cluster.local
port:
number: 8443
timeout: 60s
retries:
attempts: 3
perTryTimeout: 2s因此,基本上:对于31400中的所有请求,第一个匹配将在"/custom.api/ stream“处查找请求,该请求具有我的流服务器的目的地。
第二条规则作为捕获所有获取进入我的主要API的规则。
我的目标是让所有的连接都通过31400,然后将请求分割成一个专用的内部服务。在未来,我可能会进一步拆分服务(而不仅仅是流)。即。端点的整个组可以由单独的集群处理。
但是,当我部署这个规则时,整个VS似乎失败了,没有任何响应。
发布于 2019-08-27 16:05:51
端口是在Ingressgateway中对外公开的,应该使用Gateway进行内部配置。VirtualService只用于第7层路由(一旦连接到Gateway)。
在您的match配置中,您指定被寻址的主机应该在端口31400中接收请求,而不是在那里侦听服务。来自文献资料
端口:指定正在寻址的主机上的端口。许多服务只公开一个端口或标签端口及其支持的协议,在这些情况下,不需要显式地选择端口。
在您的示例中,您可能希望创建一个新的Gateway来处理公开端口的配置,然后使用VirtualService附加路由部分
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: grpc-gateway
spec:
selector:
istio: ingressgateway
servers:
- port:
number: 31400
name: grpc
protocol: GRPC
hosts:
- "*"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: grpc-virtualservice
spec:
hosts:
- "*"
gateways:
- grcp-gateway
http:
- match:
- uri:
exact: "/custom.api/stream"
route:
- destination:
host: stream-handler.default.svc.cluster.local
port:
number: 8444
timeout: 60s
retries:
attempts: 3
perTryTimeout: 2s
- match:
- uri:
prefix: "/"
route:
- destination:
host: api.default.svc.cluster.local
port:
number: 8443
timeout: 60s
retries:
attempts: 3
perTryTimeout: 2s由于match 不能是空的,除了前面的URI完全匹配之外,您需要为它加上前缀以获取将要出现的任何内容。
发布于 2019-08-30 02:29:55
以下是我的观察:
http.match.port.我认为port在这里的用法不正确。如果这是为了指示侦听传入的请求到端口31400,那么这实际上应该在网关YAML规范istio-gateway中。istio-gateway的规范。基本上,在那里您指定您正在侦听port.number: 31400。VirtualService是您指示要路由或“断开请求”的服务/主机和端口的位置。请检查一下,看看是否有用。
https://stackoverflow.com/questions/57501384
复制相似问题