istio: Grafana and Prometheus UIs do not work with non-root contextpath

Describe the bug istio installation options include grafana.contextPath, prometheus.contextPath and kiali.contextPath

grafana and prometheus UIs do not work on context path other than ‘/’. kiali UI works with context path “/kiali”

Expected behavior grafana and prometheus UI should work on non-root contextpath

Steps to reproduce the bug Expose grafana and prometheus services to an external IP. One way to do that would be to use nodeport:

kubectl expose deployment grafana --type=Nodeport --name=grafana-test-service  --namespace istio-system
kubectl expose deployment prometheus --type=NodePort --name=prometheus-test-service --namespace istio-system

Access grafana and prometheus UI like this : <$IP-FOR-EXPOSED-SERVICE>/grafana <$IP-FOR-EXPOSED-SERVICE>/prometheus The above URLs will not display the UI properly. However these would work on the context root “/”

The default contextPath values for grafana and prometheus are /grafana and /prometheus respectively.

The kiali UI works on the contextPath ‘/kiali’ properly.

Version istio version: 1.1.0 kubectl version: 1.10.11

Installation Install istio1.1.0 using either option at https://istio.io/docs/setup/kubernetes/install/helm with --set istio-ingressgateway=true --set grafana.enabled=true --set grafana.ingress.enabled=true --set kiali.enabled=true --set kiali.ingress.enabled=true --set prometheus.enabled=true --set prometheus.ingress.enabled=true

Environment

Cluster state

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 28 (10 by maintainers)

Most upvoted comments

I had the same issue and was able to solve it by creating a virtualservice with prefix and by setting two env vars in the grafana deployment template (trailing slash is needed):

          - name: GF_SERVER_ROOT_URL
            value: %(protocol)s://%(domain)s/grafana/
          - name: GF_SERVER_DOMAIN
            value: example.org

I suggest adding something like this to the Grafana deployment template:

{{- range $key, $value := .Values.env }}
          - name: "{{ $key }}"
            value: "{{ $value }}"
{{- end }} 

and in the Grafana values.yaml: env: {} updated 08/08/19: Istio virtualservice:

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: "istio-dashboard-app"
spec:
  hosts:
    - "mydomain.com"
  gateways:
    - default-gateway
  http:
    - match:
      - uri:
          prefix: "/grafana/"
      rewrite:
        uri: /
      route:
        - destination:
            host: grafana.istio-system.svc.cluster.local
            port:
              number: 3000

Grafana is highly customizable via env vars and this allows adding any desired amount of them. I can open a PR if necessary.

@arjav-desai @mklettner try this virtualservice match rule:

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: "istio-dashboard-app"
spec:
  hosts:
    - "mydomain.com"
  gateways:
    - default-gateway
  http:
    - match:
      - uri:
        prefix: /grafana/
      - uri:
        prefix: /grafana
      rewrite:
        uri: /
      route:
        - destination:
            host: grafana.istio-system.svc.cluster.local
            port:
              number: 3000

adding two uri match rule with and without trailing slash works fine on my env.

@rafik8 I can’t assign you. You aren’t a choice – this happens with new people. I assigned myself but you can do the work and submit the PR, which I will mark as ok-to-test.