使用istio公开揭露Grafana [英] Expose grafana publicly using istio

查看:17
本文介绍了使用istio公开揭露Grafana的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用普罗米修斯运算符,我们需要使用istio公开(外部)Grafana, https://github.com/helm/charts/tree/master/stable/prometheus-operator

正常情况下,当我有需要用istio公开的应用程序时,我会在我的微服务中添加一些类似于关注的东西,它可以工作并在外面公开。

service.yaml

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---

并添加虚拟服务

Viralservice.yaml

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

然后我能够公开访问我的应用程序

现在我想从普罗米修斯运算表中为Grafana执行同样的操作

values.yaml中有服务条目

https://github.com/helm/charts/blob/master/stable/prometheus-operator/values.yaml#L576 但是,不确定它是否应该取代service.yaml,如果是,如何将app: myapp这样的数据(在常规应用程序中我从部署.yaml的`name‘字段中获取)填充为服务引用Grafana应用程序的Grafana

此外,virutalservice.yaml中还引用了service(host:Po-svc)

我的问题是:我应该如何填充这两个并能够 使用istio?暴露Grafana?

顺便说一句,如果我像下面这样将values from the chart更改为LoadBalancer,我会获取一个公共URL以供外部访问,但我想通过istio公开它。

  service:
    portName: service
    type: LoadBalancer

更新

我已创建以下虚拟服务

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

并按如下方式更新values.yaml

  service:
    portName: service
    port: 3000
    targetPort: 3000

现在,当我在浏览器中点击应用程序URL(po.eu.trial.appos.cloud.mvn)时,收到错误

upstream connect error or disconnect/reset before headers. reset reason: connection termination 您知道问题出在哪里吗?我应该如何跟踪此问题?

我认为(不是100%)我可能在chart中的服务配置上遗漏了一些东西,但不确定是什么...

我发现这篇帖子有类似的错误:(但不确定我们有相同的问题)

https://github.com/istio/istio/issues/19966

但是,我不确定应该如何将名称端口添加到chart yaml服务定义

推荐答案

1.7.0版的istio有一个工作示例

istioctl version
client version: 1.7.0
control plane version: 1.7.0
data plane version: 1.7.0 (1 proxies)

1.我已使用helm fetch获取普罗米修斯运算符。

helm fetch stable/prometheus-operator --untar

2.我在values.yaml中更改了这些设置。

GrafanaService

service:
  portName: http-service
  port: 3000
  targetPort: 3000

Grafanahost

hosts:
  - grafana.domain.com

3.我已创建PO命名空间并安装了普罗米修斯操作符

kubectl create namespace po
helm install prometheus-operator ./prometheus-operator -n po

4.我已使用

检查了grafana服务名称
kubectl get svc -n po
prometheus-operator-grafana                    ClusterIP

5.我对istio使用了以下yamls,并使用prometheus-operator-grafana的grafana服务名作为我的虚拟服务和目标规则主机。

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:
    - "grafana.domain.com"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: grafana-vs
  namespace: po
spec:
  hosts:
  - "grafana.domain.com"
  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

5.使用cURL进行测试,它是302而不是200,因为我们必须登录。

curl -v -H "host: grafana.domain.com" xx.xx.xxx.xxx/

GET / HTTP/1.1
> Host: grafana.domain.com
> User-Agent: curl/7.64.0
> Accept: */*
>
< HTTP/1.1 302 Found

让我知道它是否起作用,或者如果您有任何其他问题。可能您使用的1.4.3版本有问题。

这篇关于使用istio公开揭露Grafana的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆