使用 Istio 挂载不同路径的应用

Mounting applications of different paths with Istio

我们已经在 AWS 上的 Kubernetes 集群上安装了 Istio(我们正在使用 EKS)。我们已经部署了几个应用程序,例如:Airflow、Jenkins、Grafana 等,我们可以用 port-forward 访问它们。所以,他们正在按预期工作。

现在,我们想要实现的是在特定路径上安装应用程序的可能性,以便我们可以通过唯一的入口点访问它们。

这里有一个例子来解释我的意思 "unique entrypoint":

我们尝试的是以下

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: apps-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: airflow-virtual-service  
spec:
  hosts:
  - "*"
  gateways:
  - apps-gateway
  http:
  - match:
    - uri:
        prefix: /airflow
    route:
    - destination:
        host: webserver.airflow.svc.cluster.local
        port:
          number: 8080
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: grafana-virtual-service  
spec:
  hosts:
  - "*"
  gateways:
  - apps-gateway
  http:
  - match:
    - uri:
        prefix: /grafana
    route:
    - destination:
        host: grafana.grafana.svc.cluster.local
        port:
          number: 3306
---
and so on

以这种方式,但我一直有 Aiflow 404 = lots of circles 或类似的服务,具体取决于服务。

你知道如何用 Istio 达到这样的效果吗?我们也愿意使用 Nginx 或 Traefik。

所以根据评论:

公开前端和后端的最佳方式是使用通配符域将两者分开,例如 *.domain.com

对于前端:

my-app.domain.com/

对于后端服务,它将始终以子域开头,例如 api:

api.domain.com/foo

对于后端服务,如果您的后端服务不提供路径,您将需要使用 rewrite

rewrite:
  uri: "/"

查看 Istio 文档以获取有关重写的更多信息https://istio.io/docs/reference/config/istio.networking.v1alpha3/#Destination