Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Kubernetes 通过值配置数据源_Kubernetes_Grafana_Helmfile - Fatal编程技术网

Kubernetes 通过值配置数据源

Kubernetes 通过值配置数据源,kubernetes,grafana,helmfile,Kubernetes,Grafana,Helmfile,正如标题所示,我正试图通过值使用数据源的helmfile设置grafana 我可以找到文件,但遗憾的是,我的知识太有限,无法让它工作 我文件的相关部分在这里 releases: ... - name: grafana namespace: grafana chart: stable/grafana values: - datasources: - name: Prometheus type: prometheus

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

我可以找到文件,但遗憾的是,我的知识太有限,无法让它工作

我文件的相关部分在这里

releases:
...
  - name: grafana
    namespace: grafana
    chart: stable/grafana
    values:
      - datasources:
        - name: Prometheus
          type: prometheus
          url: http://prometheus-server.prometheus.svc.cluster.local
我偶然发现,似乎我也可以通过一个环境变量来实现,但我似乎找不到一个简单的方法在我的文件中设置它

如果有人对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

回答

只需将以下截取的值直接添加到
值中即可。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应用程序将从中获取它

见格拉法纳

提示:要查看渲染的头盔模板,请使用
头盔模板