使用Sidecar为仪表板导入带有Helm的仪表板

时间:2019-08-27 13:03:58

标签: grafana kubernetes-helm

我已经导出了Grafana仪表板(输出是json文件),现在我想在安装Grafana时将其导入(全部自动,带有Helm和Kubernetes)

我只用红色的this帖子介绍了如何添加使用datasource设置的sidecar。简而言之,您需要使用

创建一个values.yaml
sidecar:
  image: xuxinkun/k8s-sidecar:0.0.7
  imagePullPolicy: IfNotPresent
  datasources:
    enabled: true
    label: grafana_datasource

以及与该标签匹配的ConfigMap

apiVersion: v1
kind: ConfigMap
metadata:
  name: prometheus-grafana-datasource
  labels:
    grafana_datasource: '1'
data:
  datasource.yaml: |-
    apiVersion: 1
    datasources:
    - name: Prometheus
      type: prometheus
      access: proxy
      orgId: 1
      url: http://source-prometheus-server

好的,这行得通,所以我尝试对仪表板做类似的事情,所以我更新了values.yaml

sidecar:
  image: xuxinkun/k8s-sidecar:0.0.7
  imagePullPolicy: IfNotPresent
  dashboards:
    enabled: false
    # label that the configmaps with dashboards are marked with
    label: grafana_dashboard
  datasources:
    enabled: true
    label: grafana_datasource

还有ConfigMap

apiVersion: v1
kind: ConfigMap
metadata:
  name: prometheus-grafana-dashboards
  labels:
    grafana_dashboard: '1'
data:
  custom-dashboards.json: |-
    {
      "annotations": {
        "list": [
          {
    ...

但是,当我这次安装grafana并登录时,没有仪表板 有什么建议我在这里做错了吗?

1 个答案:

答案 0 :(得分:1)

sidecar:
  image: xuxinkun/k8s-sidecar:0.0.7
  imagePullPolicy: IfNotPresent
  dashboards:
    enabled: false
    # label that the configmaps with dashboards are marked with
    label: grafana_dashboard
  datasources:
    enabled: true
    label: grafana_datasource

在上面的代码中,应该有dashboard.enabled: true才能启用仪表板。