gpt4 book ai didi

kubernetes - 通过值配置数据源

转载 作者:行者123 更新时间:2023-12-02 12:18:04 25 4
gpt4 key购买 nike

如标题所示,我正在尝试使用helmfile和通过值的数据源设置grafana。

我可以找到here文档,但不幸的是我的知识太有限,无法正常工作。

我的 Helm 文件的相关部分在这里

releases:
...
- name: grafana
namespace: grafana
chart: stable/grafana
values:
- datasources:
- name: Prometheus
type: prometheus
url: http://prometheus-server.prometheus.svc.cluster.local

我偶然发现了 this,看来我也可以通过环境变量来做到这一点,但似乎找不到在helmfile中设置此类的简单方法。

如果对Helmfile,json和其他方面有更好理解的人能够向我展示或指导我正确的方向,将不胜感激。

更新:感谢@WindyFields,我的最终解决方案如下
releases:
...
- name: grafana
namespace: grafana
chart: stable/grafana
values:
- datasources:
datasources.yaml:
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
access: proxy
url: http://prometheus-server.prometheus.svc.cluster.local
isDefault: true

最佳答案

回答

只需将以下片段直接添加到values.yaml中:

datasources:
datasources.yaml:
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
url: http://prometheus-server.prometheus.svc.cluster.local

详细信息

在Helm渲染模板之后,将生成以下configmap:
# Source: grafana/templates/configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: RELEASE-NAME-grafana
labels:
app: grafana
chart: grafana-1.20.0
release: RELEASE-NAME
heritage: Tiller
data:
grafana.ini: |
...
datasources.yaml: |
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
url: http://prometheus-server.prometheus.svc.cluster.local

在Helms安装图表之后,k8s将从 datatsources.yaml中获取数据源配置 config.yaml并通过以下路径 /etc/grafana/provisioning/datasources/datasources.yaml进行安装,Grafana应用程序将在其中下载它。

参见Grafana datasources provisioning doc

提示:以查看渲染的Helm模板使用 helm template <path_to_chart>

关于kubernetes - 通过值配置数据源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54158218/

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