【问题标题】:Grafana pod in kube-prometheus-stack app unable to detect configmap for datasourceskube-prometheus-stack 应用程序中的 Grafana pod 无法检测数据源的 configmap
【发布时间】:2021-02-24 03:19:38
【问题描述】:

我已经在 Rancher 集群上安装了一个 kube-prometheus-stack (https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack) 实例,并使用自定义 values.yaml 来添加 Grafana 配置。

values.yaml 的 Grafana 部分:

grafana:
  enabled: true
  ingress:
    enabled: disabled
  service:
    type: ClusterIP
    port: 3000
    targetPort: 3000
    annotations: {}
    labels: {}
    portName: service
  sidecar:
    image:
      repository: kiwigrid/k8s-sidecar
      tag: 1.1.0
      sha: ""
    imagePullPolicy: IfNotPresent
    skipTlsVerify: true
    enableUniqueFilenames: false
    dashboards:
      enabled: true
      SCProvider: true
      label: grafana_dashboard
      folder: /tmp/dashboards
      defaultFolderName: null
      searchNamespace: ALL
      folderAnnotation: null
      provider:
        name: sidecarProvider
        orgid: 1
        folder: ''
        type: file
        disableDelete: false
        allowUiUpdates: true
        foldersFromFilesStructure: false
    datasources:
      enabled: true
      label: grafana_datasource
      searchNamespace: ALL

在安装之前,我还在 Rancher 中存储了一个名为 grafana-datasource 的配置映射,标签为:键:grafana_datasource,值:1。此 configmap 存储在与 kube-prometheus-stack 应用相同的命名空间中。

在这个grafana-datasource configmap 中,我放了以下数据:

apiVersion: 1
datasources:
- name: Test-Prometheus
  type: prometheus
  url: https://prometheus.test.net/
  access: proxy
  isDefault: false
  basicAuth: true
  basicAuthUser: admin
  basicAuthPassword: password
  withCredentials: false
  isDefault: false
  version: 1
  editable: true

我已验证我的数据源存在并且能够登录到它并通过 Grafana GUI 手动添加它。但是,安装没有选择我的grafana-datasource configmap,只加载默认的 Grafana 数据源:

如何让我的 grafana 在安装时获取并应用自定义数据源配置映射?

【问题讨论】:

    标签: kubernetes prometheus grafana rancher configmap


    【解决方案1】:

    我复制了您的设置,一切正常。

    您似乎跳过了配置映射文件名的.yaml/.yml 扩展名(并且由于您没有提及您使用的名称,这是最可能的原因)。添加如下所示,它应该可以工作。

    apiVersion: v1
    data:
      custom.yaml: |
        apiVersion: 1
        datasources:
        - name: Test-Prometheus
          type: prometheus
          url: https://prometheus.test.net/
          access: proxy
          isDefault: false
          basicAuth: true
          basicAuthUser: admin
          basicAuthPassword: password
          withCredentials: false
          isDefault: false
          version: 1
          editable: true
    kind: ConfigMap
    metadata:
      creationTimestamp: null
      name: grafana-datasource
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-13
      • 2022-08-05
      • 1970-01-01
      • 2021-03-20
      • 1970-01-01
      • 2021-04-30
      相关资源
      最近更新 更多