我已经在一个牧场集群上安装了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的配置映射,标签为: key:grafana_datasource,值为:1。此configmap存储在与kube-prometheus-stack应用程序相同的名称空间中。
在这个grafana-datasource配置映射中,我放入了以下数据:
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配置映射,并且只加载了默认的Grafana数据源:

如何在安装时启用grafana来拾取和应用自定义数据源配置映射?
发布于 2020-11-12 18:46:16
我复制了你的设置,一切都正常工作。
看起来您可能跳过了配置映射文件名的.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-datasourcehttps://stackoverflow.com/questions/64798504
复制相似问题