1
votes

I have installed an instance of kube-prometheus-stack (https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack) onto a Rancher cluster and utilised a custom values.yaml to add Grafana configuration.

Grafana section of values.yaml:

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

I have also stored a configmap into Rancher prior to installation called grafana-datasource and has the label: key: grafana_datasource with value: 1. This configmap is stored in the same namespace as the kube-prometheus-stack app.

In this grafana-datasource configmap, I have put the following data:

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

I have verified that my datasource exists and am able to log into it and add it manually via the Grafana GUI. However, the installation is not picking up my grafana-datasource configmap and only loads the default Grafana datasource: grafana_default_datasource

How can I enable my grafana to pick-up and apply the custom datasource configmap on installation?

1

1 Answers

0
votes

I replicated your setup and everything was working correctly.

It seems that you may have skipped the .yaml/.yml extension for the configmap filename (and since you are not mentioning what name you used, this is the most probable cause). Add the one like following and it should work.

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