<p>We are using Prometheus operator and we need to expose Grafana publicly (outside) using istio,
<a href="https://github.com/helm/charts/tree/master/stable/prometheus-operator" rel="nofollow noreferrer">https://github.com/helm/charts/tree/master/stable/prometheus-operator</a></p>
<p>Normally when I have application which I need to expose publicly with istio, I adding something like following to my micro service <strong>and it works</strong> and exposed outside.</p>
<p><strong>service.yaml</strong></p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: po-svc
  namespace: po
spec:
  ports:
    - name: http
      port: 3000
      targetPort: 3000
  selector:
    app: myapp  //I take the name from deployment.yaml --in the chart NOT SURE WHICH VALUE I SHOULD TAKE FROM THE CHART---
</code></pre>
<p>And add a virtual service</p>
<p><strong>virtualservice.yaml</strong></p>
<pre><code>apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: po-virtualservice
  namespace: po
spec:
  gateways:
    - gw-system.svc.cluster.local
  hosts:
    - po.eu.trial.appos.cloud.mvn
  http:
    - route:
        - destination:
            host: po-svc
            port:
              number: 3000
</code></pre>
<p>Then I was able to access to my application <strong>publicly</strong>.</p>
<p>Now I want to the same for Grafana from the prometheus operator chart</p>
<p>in the <code>values.yaml</code> there is service entry</p>
<p><a href="https://github.com/helm/charts/blob/master/stable/prometheus-operator/values.yaml#L576" rel="nofollow noreferrer">https://github.com/helm/charts/blob/master/stable/prometheus-operator/values.yaml#L576</a>
However not sure if it should replace the <code>service.yaml</code> and if yes how to fill the data like  <code>app: myapp</code> (which in regualr application I take from the deployment.yaml the `name' field)  to be the grafana that the service have the reference to Grafana application</p>
<p>in addition, in the <code>virutalservice.yaml</code> there is a reference to the <code>service</code> (host: po-svc)</p>
<blockquote>
<p>My question is: How should I fill those <strong>two values</strong> and be able to
expose Grafana using istio ?</p>
</blockquote>
<p>Btw, if I change the <a href="https://github.com/helm/charts/blob/master/stable/prometheus-operator/values.yaml#L576" rel="nofollow noreferrer">values from the chart</a> to <code>LoadBalancer</code> like below, im getting a public url to access outside, however I want to expose it via istio.</p>
<pre><code>  service:
    portName: service
    type: LoadBalancer
</code></pre>
<p><strong>update</strong></p>
<p>I've created the following virtual service</p>
<pre><code>apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: po-virtualservice
  namespace: po
spec:
  gateways:
    - gw-system.svc.cluster.local
  hosts:
    - po.eu.trial.appos.cloud.mvn
  http:
    - route:
        - destination:
            host: po-grafana. // This is the name of the service that promethues operator created when applying the chart .
            port:
              number: 3000
</code></pre>
<p>and update the <a href="https://github.com/helm/charts/blob/master/stable/prometheus-operator/values.yaml#L576" rel="nofollow noreferrer">values.yaml</a> like following</p>
<pre><code>  service:
    portName: service
    port: 3000
    targetPort: 3000
</code></pre>
<p>Now when I hit the browser for the application url (po.eu.trial.appos.cloud.mvn) I got error</p>
<p><code>upstream connect error or disconnect/reset before headers. reset reason: connection termination </code> any idea what could be the problem? how should I trace this issue ?</p>
<p>I would think(not sure 100%) I may be missing something on the <strong>service config in the</strong> <a href="https://github.com/helm/charts/blob/master/stable/prometheus-operator/values.yaml#L576" rel="nofollow noreferrer">chart</a> but not sure what...</p>
<p>I've found this post which have similar error: (but not sure we have the same issue)</p>
<p><a href="https://github.com/istio/istio/issues/19966" rel="nofollow noreferrer">https://github.com/istio/istio/issues/19966</a></p>
<p>However not sure how should I add the nameport to the <a href="https://github.com/helm/charts/blob/master/stable/prometheus-operator/values.yaml#L576" rel="nofollow noreferrer">chart yaml</a> service definition</p>

<p>There is a working example for istio with version 1.7.0</p>
<pre><code>istioctl version
client version: 1.7.0
control plane version: 1.7.0
data plane version: 1.7.0 (1 proxies)
</code></pre>
<p>1.I have used <a href="https://v2.helm.sh/docs/helm/#helm-fetch" rel="nofollow noreferrer">helm fetch</a> to get prometheus operator.</p>
<pre><code>helm fetch stable/prometheus-operator --untar
</code></pre>
<p>2.I changed these in values.yaml.</p>
<p>Grafana <a href="https://github.com/helm/charts/blob/master/stable/prometheus-operator/values.yaml#L576" rel="nofollow noreferrer">Service</a>.</p>
<pre><code>service:
  portName: http-service
  port: 3000
  targetPort: 3000
</code></pre>
<p>Grafana <a href="https://github.com/helm/charts/blob/master/stable/prometheus-operator/values.yaml#L514" rel="nofollow noreferrer">host</a>.</p>
<pre><code>hosts:
  - grafana.domain.com
</code></pre>
<p>3.I have created po namespace and installed prometheus operator</p>
<pre><code>kubectl create namespace po
helm install prometheus-operator ./prometheus-operator -n po
</code></pre>
<p>4.I have checked the grafana service name with</p>
<pre><code>kubectl get svc -n po
prometheus-operator-grafana                    ClusterIP
</code></pre>
<p>5.I have used below yamls for istio, used grafana service name which is <code>prometheus-operator-grafana</code> as my virtual service and destination rule host.</p>
<pre><code>apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: grafana-gateway
  namespace: po
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      number: 80
      name: http-grafana
      protocol: HTTP
    hosts:
    - &quot;grafana.domain.com&quot;
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: grafana-vs
  namespace: po
spec:
  hosts:
  - &quot;grafana.domain.com&quot;
  gateways:
  - grafana-gateway
  http:
  - route:
    - destination:
        host: prometheus-operator-grafana.po.svc.cluster.local
        port:
          number: 3000
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: grafana
  namespace: po
spec:
  host: prometheus-operator-grafana.po.svc.cluster.local
  trafficPolicy:
    tls:
      mode: DISABLE
</code></pre>
<p>5.Test with curl, it's 302 instead of 200 as we have to login.</p>
<pre><code>curl -v -H &quot;host: grafana.domain.com&quot; xx.xx.xxx.xxx/

GET / HTTP/1.1
&gt; Host: grafana.domain.com
&gt; User-Agent: curl/7.64.0
&gt; Accept: */*
&gt;
&lt; HTTP/1.1 302 Found
</code></pre>
<hr />
<p>Let me know if it worked or if you have any other questions. Maybe there is a problem with the 1.4.3 version you use.</p>
