首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在一个Istio服务网格中托管多个应用程序?

如何在一个Istio服务网格中托管多个应用程序?
EN

Stack Overflow用户
提问于 2019-04-04 11:38:54
回答 1查看 1.2K关注 0票数 3

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

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

代码语言:javascript
复制
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。

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

代码语言:javascript
复制
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
---
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-04-04 12:43:27

在哪条路径上配置了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 可能缺少规则,以从请求中删除路径。

例如:根据这一规则:

代码语言:javascript
复制
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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55515081

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档