Istio 1.0.2 在浏览器上访问grafana

Istio 1.0.2 access grafana on Browser

我已经使用以下命令在 GKE 上部署了 istio:

 helm template istio-1.0.2/install/kubernetes/helm/istio --name istio --namespace istio-system --set global.mtls.enabled=true --set tracing.enabled=true --set servicegraph.enabled=true --set grafana.enabled=true --set telemetry-gateway.grafanaEnabled=true > istio.yaml

但我只是不知道如何在浏览器上访问 grafana。 而且我不想使用端口转发.. 这不是现实世界的解决方案。 我使用了以下网关和虚拟服务定义。 但是我无法在浏览器上访问 Grafana UI。非常感谢任何帮助

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: grafana-gateway
spec:
  selector:
    istio: ingressgateway # use Istio default gateway implementation
  servers:
  - port:
      number: 15031
      name: http-grafana
      protocol: HTTP
    hosts:
    - "*"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: grafana
spec:
  hosts:
  - "grafana-test"
  gateways:
  - grafana-gateway
  #- mesh
  http:
  - route:
    - destination:
        host: "grafana.istio-system.svc.cluster.local"
        port:
          number: 3000

您必须根据@Vadim Eisenberg 的建议,通过将 hosts 更改为值 "*" 来调整 Istio VirtualService

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: grafana
spec:
  hosts:
  - "*"
  gateways:
  - grafana-gateway
  #- mesh
  http:
  - route:
    - destination:
        host: "grafana.istio-system.svc.cluster.local"
        port:
          number: 3000

我检查了我的 GKE 环境,它按预期工作:

$ export INGRESS_HOST=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}')

$ curl -I -H "Host:grafana.istio-system.svc.cluster.local" http://$INGRESS_HOST:15031

HTTP/1.1 200 OK content-type: text/html; charset=UTF-8 set-cookie: grafana_sess=3b7c8eda239f6bb2; Path=/; HttpOnly date: Mon, 29 Oct 2018 13:48:14 GMT x-envoy-upstream-service-time: 6 server: envoy transfer-encoding: chunked