rancher-partner-charts/charts/kubecost/cost-analyzer/1.107.0/templates/grafana-datasource-template...

57 lines
1.8 KiB
YAML

{{- if .Values.grafana -}}
{{- if .Values.grafana.sidecar -}}
{{- if .Values.grafana.sidecar.datasources -}}
{{- if .Values.grafana.sidecar.datasources.enabled -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: grafana-datasource
{{- if $.Values.grafana.namespace_datasources }}
namespace: {{ $.Values.grafana.namespace_datasources }}
{{- end }}
labels:
{{- include "cost-analyzer.commonLabels" . | nindent 4 }}
{{- if $.Values.grafana.sidecar.datasources.label }}
{{ $.Values.grafana.sidecar.datasources.label }}: "1"
{{- else }}
{{- if .Values.global.grafana.enabled }}
kubecost_grafana_datasource: "1"
{{- else }}
grafana_datasource: "1"
{{- end }}
{{- end }}
data:
{{ default "datasource.yaml" .Values.grafana.sidecar.datasources.dataSourceFilename }}: |-
apiVersion: 1
datasources:
- access: proxy
name: default-kubecost
type: prometheus
{{- if .Values.grafana.sidecar.datasources.defaultDatasourceEnabled }}
isDefault: true
{{- else }}
isDefault: false
{{- end }}
{{- if .Values.global.thanos }}
{{- if .Values.global.thanos.enabled }}
{{- if .Values.global.prometheus.enabled }}
url: http://{{ .Release.Name }}-thanos-query-http.{{ .Release.Namespace }}:{{ .Values.thanos.query.http.port }}
{{- else }}
url: {{ .Values.global.thanos.queryService }}
{{- end }}
- access: proxy
name: {{ default "Prometheus" .Values.grafana.sidecar.datasources.dataSourceName}}
isDefault: false
type: prometheus
{{- end }}
{{- if .Values.global.prometheus.enabled }}
url: http://{{ template "cost-analyzer.prometheus.server.name" . }}.{{ .Release.Namespace }}
{{- else }}
url: {{ .Values.global.prometheus.fqdn }}
{{- end }}
{{- end }}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}