gpt4 book ai didi

kubernetes - 使用 istio 公开暴露 grafana

转载 作者:行者123 更新时间:2023-12-02 11:30:33 27 4
gpt4 key购买 nike

我们正在使用 Prometheus 运算符,我们需要使用 istio 公开(外部)公开 Grafana,
https://github.com/helm/charts/tree/master/stable/prometheus-operator
通常,当我有需要通过 istio 公开公开的应用程序时,我会在我的微服务 中添加如下内容它有效并暴露在外面。
服务.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---
并添加一个虚拟服务
虚拟服务.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 等数据(在常规应用程序中,我从 deployment.yaml 中获取“名称”字段)作为服务引用 Grafana 应用程序的 grafana
此外,在 virutalservice.yaml有一个引用 service (主持人:po-svc)

My question is: How should I fill those two values and be able toexpose Grafana using istio ?


顺便说一句,如果我更改 values from the chartLoadBalancer如下所示,我获得了一个可以在外部访问的公共(public) 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服务定义

最佳答案

istio 有一个工作示例,版本为 1.7.0

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 中更改了这些。
格拉法纳 Service .
service:
portName: http-service
port: 3000
targetPort: 3000
格拉法纳 host .
hosts:
- grafana.domain.com
3.我已经创建了po命名空间并安装了prometheus operator
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,使用了 grafana 服务名称,即 prometheus-operator-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版本有问题。

关于kubernetes - 使用 istio 公开暴露 grafana,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63689505/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com