【问题标题】:Configure datasource via values通过值配置数据源
【发布时间】:2019-01-12 09:20:12
【问题描述】:

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

我可以找到文档here,但遗憾的是我的知识太有限,无法使其发挥作用。

我的 helmfile 的相关部分在这里

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

【问题讨论】:

    标签: kubernetes grafana helmfile


    【解决方案1】:

    回答

    只需将以下片段直接添加到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 会从config.yaml 获取数据源配置datatsources.yaml 并通过以下路径/etc/grafana/provisioning/datasources/datasources.yaml 进行挂载,Grafana 应用将在该路径中获取它。

    请参阅 Grafana datasources provisioning doc

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

    【讨论】:

      猜你喜欢
      • 2011-07-15
      • 1970-01-01
      • 2016-03-22
      • 2015-03-02
      • 1970-01-01
      • 1970-01-01
      • 2017-06-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多