Docker 如何在一个Istio服务网格中承载多个应用程序?

Docker 如何在一个Istio服务网格中承载多个应用程序?,docker,kubernetes,graphql,istio,hasura,Docker,Kubernetes,Graphql,Istio,Hasura,我正在设置一个Istio服务网格,其中包含两个运行Graphql引擎的服务。我打算把它们放在两个不同的子路径上。如何在VirtualService上设置重定向 我已经尝试过使用这个VirtualService配置 apiVersion: networking.istio.io/v1alpha3 kind: VirtualService metadata: name: hasura-1 spec: hosts: - "*" gateways: - hasura-gateway

我正在设置一个Istio服务网格,其中包含两个运行Graphql引擎的服务。我打算把它们放在两个不同的子路径上。如何在VirtualService上设置重定向

我已经尝试过使用这个VirtualService配置

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: hasura-1
spec:
  hosts:
  - "*"
  gateways:
  - hasura-gateway
  http:
  - match:
    - uri:
        prefix: /hasura1
    route:
    - destination:
        host: hasura-1
        port:
          number: 80
  - match:
    - uri:
        prefix: /hasura2
    route:
    - destination:
        host: hasura-2
        port:
          number: 80
但每当我尝试访问这些前缀时,我总是会遇到404错误

编辑:我已经更新了我的虚拟服务,加入了
rewrite.uri
。每当我尝试访问任何一个前缀时,我都会被重定向到
/
,它会给出一个错误404。这是我更新的网关和VirtualService清单

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: hasura-gateway
spec:
  selector:
    istio: ingressgateway # use istio default controller
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "*"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: hasura-1
spec:
  hosts:
  - "*"
  gateways:
  - hasura-gateway
  http:
  - match:
    - uri:
        exact: /hasura1
    rewrite:
      uri: /
    route:
    - destination:
        host: hasura-1
        port:
          number: 80
  - match:
    - uri:
        exact: /hasura2
    rewrite:
      uri: /
    route:
    - destination:
        host: hasura-2
        port:
          number: 80
---

在什么路径上配置Hasura的GraphQL端点

按照
VirtualService
的配置方式,对网关的请求将如下所示:

my.host.com/hasura1
-->
hasura-1/hasura1

my.host.com/hasura1/anotherpath
-->
hasura-1/hasura1/anotherpath

my.host.com/hasura2
-->
hasura-2/hasura2

可能您缺少从请求中删除路径的
rewrite.uri
规则。

e、 g:根据这条规则:

http:
- match:
  - uri:
      prefix: /hasura1
  rewrite:
    uri: /
  route:
  - destination:
      host: hasura-1
      port:
        number: 80
您的Hasura容器应在根路径上接收请求:

my.host.com/hasura1
-->
hasura-1/


my.host.com/hasura1/anotherpath
-->
hasura-1/anotherpath

显然,您的
VirtualService
还可以。您能否提供用于创建hasura网关的清单?Kubernetes服务的
hasura-1
hasura-2
清单也会很有用。@eduardo baitello我在编辑的帖子中添加了
hasura网关的清单。对于
hasura-1
hasura-2
的清单,我只是将
deployment.yaml
service.yaml
组合在一起,它们在hasura的GKE教程中找到,并在服务清单中删除了
type.uri
。你好。哼哼……网关看起来没问题。您能否模拟请求并从
istio入口
hasura-x
服务下的容器中检索日志?我们需要知道是谁还了404。嗨,基恩。这方面有什么更新吗?
hasura-1
hasura-2
是同一名称空间中的服务吗?如果不是,它应该是
destination
字段中它们的完全限定名(.)那么(.)你是对的,我计划在
/hasura1
/hasura2
配置我的GraphQL端点。我试着像这样设置
rewrite.uri
,但在两个前缀中,我都被重定向到
/
,它给出了一个错误404。我认为它能够在通过
/console
重定向时访问图像,但它在错误404处停止。取而代之的是:
my.host.com/hasura1
-->
hasura-1/
它是这样运行的:
my.host.com/hasura1
-->
my.host.com/
我编辑了我的帖子来更新虚拟服务,还有网关清单,问题是,用于服务的映像不接受除
/console
以外的任何路由,这就是它发出错误404的原因。我们真的不需要将其他吊舱作为一条路线暴露出来,这就是为什么我们只有一个吊舱在网关内服务。为了让它访问其他播客,我应用了@Anna Slastnikova comment,现在它可以工作了。