Azure Istio-通过网关公开虚拟服务

Azure Istio-通过网关公开虚拟服务,azure,kubernetes,istio,Azure,Kubernetes,Istio,我已经使用掌舵图设置了Istio,我正在尝试向Istio入口网关公开服务 以下是我决定使用的配置: apiVersion: networking.istio.io/v1alpha3 kind: Gateway metadata: name: grafana-gateway namespace: istio-system spec: selector: istio: ingressgateway servers: - port: number: 31400

我已经使用掌舵图设置了Istio,我正在尝试向Istio入口网关公开服务

以下是我决定使用的配置:

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: grafana-gateway
  namespace: istio-system
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      number: 31400
      name: http
      protocol: HTTP
    hosts:
    - "*"
---
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: kiali-gateway
  namespace: istio-system
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      number: 15029
      name: http
      protocol: HTTP
    hosts:
    - "*"
---
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: prometheus-gateway
  namespace: istio-system
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      number: 15030
      name: http
      protocol: HTTP
    hosts:
    - "*"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: grafana-vts
  namespace: istio-system
spec:
  hosts:
  - "*"
  gateways:
  - grafana-gateway
  http:
  - match:
    - uri:
        prefix: /
    route:
    - destination:
        host: grafana.istio-system.svc.cluster.local
        port: 
          number: 3000
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: kiali-vts
  namespace: istio-system
spec:
  hosts:
  - "*"
  gateways:
  - kiali-gateway
  http:
  - match:
    - uri:
        prefix: /
    route:
    - destination:
        host: kiali.istio-system.svc.cluster.local
        port: 
          number: 20001
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: prometheus-vts
  namespace: istio-system
spec:
  hosts:
  - "*"
  gateways:
  - prometheus-gateway
  http:
  - match:
    - uri:
        prefix: /
    route:
    - destination:
        host: prometheus.istio-system.svc.cluster.local
        port: 
          number: 9090
但是,这只将grafana路由到端口31400、15029和15030,而它应该只为31400路由

如果我只使用一个网关并重写uri,它会抛出一个404错误/告诉我反向代理设置不正确

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: all-gateway
  namespace: istio-system
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "*"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: grafana-vts
  namespace: istio-system
spec:
  hosts:
  - "*"
  gateways:
  - all-gateway
  http:
  - match:
    - uri:
        prefix: "/grafana"
      rewrite:
        uri: /
    route:
    - destination:
        host: grafana.istio-system.svc.cluster.local
        port: 
          number: 3000
and etc...

我对istio有点陌生,我浏览过的例子并没有具体谈到这些。如果你有一个想法,那就太棒了——这是因为我对主机进行了通配符吗?

你的网关和虚拟服务是混合的,因为它们都使用相同的主机(
*
),所以它们的行为在Istio中没有定义。我会分配假主机名,例如,
my grafana.com
my kiali.com
,并在网关和虚拟服务定义中使用它们。我会将这些假主机名添加到
/etc/hosts/
文件中,并使用它们从我的计算机访问Grafana和Kiali。

相当确定它会将所有内容路由到Grafana,因为在第一种情况下是因为hosts值:
*
,不确定第二种情况,但您想做什么?这些仪表盘可以从外面用吗?