feat(grafana): support dashboard deployment
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing

This commit is contained in:
Markus Pesch 2024-12-02 13:10:15 +01:00
parent 2e9eae9888
commit 1e9aeb802d
Signed by: volker.raschek
GPG Key ID: 852BCC170D81A982
6 changed files with 3985 additions and 1777 deletions

View File

@ -188,9 +188,12 @@ replaced:
### Grafana
| Name | Description | Value |
| ------------------------------------ | --------------------------------------------------------- | ------- |
| `grafana.enabled` | Enable integration into Grafana. | `false` |
| `grafana.dashboards.businessMetrics` | Enable deployment of Grafana dashboard `businessMetrics`. | `true` |
| ------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | ----------- |
| `grafana.enabled` | Enable integration into Grafana. Require the Prometheus operator deployment. | `false` |
| `grafana.dashboardDiscoveryLabels` | Labels that Grafana uses to discover resources. The labels may vary depending on the Grafana deployment. | `undefined` |
| `grafana.dashboards.postgresExporter.enabled` | Enable deployment of Grafana dashboard `postgresExporter`. | `true` |
| `grafana.dashboards.postgresExporter.annotations` | Additional configmap annotations. | `{}` |
| `grafana.dashboards.postgresExporter.labels` | Additional configmap labels. | `{}` |
### Ingress

View File

@ -0,0 +1,20 @@
{{/* vim: set filetype=mustache: */}}
{{/* annotations */}}
{{- define "prometheus-postgres-exporter.configMap.grafanaDashboards.postgresExporter.annotations" -}}
{{ include "prometheus-postgres-exporter.annotations" . }}
{{- if .Values.grafana.dashboards.postgresExporter.annotations }}
{{ toYaml .Values.grafana.dashboards.postgresExporter.annotations }}
{{- end }}
{{- end }}
{{/* labels */}}
{{- define "prometheus-postgres-exporter.configMap.grafanaDashboards.postgresExporter.labels" -}}
{{ include "prometheus-postgres-exporter.labels" . }}
{{- if .Values.grafana.dashboards.postgresExporter.labels }}
{{ toYaml .Values.grafana.dashboards.postgresExporter.labels }}
{{- end }}
{{ toYaml .Values.grafana.dashboardDiscoveryLabels }}
{{- end }}

View File

@ -0,0 +1,79 @@
chart:
appVersion: 0.1.0
version: 0.1.0
suite: ConfigMap template (Grafana Dashboard PostgresExporter)
release:
name: prometheus-postgres-exporter-unittest
namespace: testing
templates:
- templates/prometheus-postgres-exporter/configMapGrafanaDashboardPostgresExporter.yaml
tests:
- it: Rendering postgresExporter
asserts:
- hasDocuments:
count: 0
- it: Rendering
set:
grafana.enabled: true
asserts:
- hasDocuments:
count: 1
- containsDocument:
apiVersion: v1
kind: ConfigMap
name: prometheus-postgres-exporter-unittest-grafana-dashboard-postgres-exporter
namespace: testing
- notExists:
path: metadata.annotations
- equal:
path: metadata.labels
value:
app.kubernetes.io/instance: prometheus-postgres-exporter-unittest
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: prometheus-postgres-exporter
app.kubernetes.io/version: 0.1.0
grafana_dashboard: "1"
helm.sh/chart: prometheus-postgres-exporter-0.1.0
- exists:
path: data["postgresExporter.yaml"]
- it: Test custom annotations and labels
set:
grafana.enabled: true
grafana.dashboards.postgresExporter.annotations:
foo: bar
grafana.dashboards.postgresExporter.labels:
bar: foo
asserts:
- equal:
path: metadata.annotations
value:
foo: bar
- equal:
path: metadata.labels
value:
app.kubernetes.io/instance: prometheus-postgres-exporter-unittest
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: prometheus-postgres-exporter
app.kubernetes.io/version: 0.1.0
grafana_dashboard: "1"
helm.sh/chart: prometheus-postgres-exporter-0.1.0
bar: foo
- it: Test custom grafana discovery labels
set:
grafana.enabled: true
grafana.dashboardDiscoveryLabels:
grafana_dashboard: null
my-custom-discovery-label: my-value
asserts:
- equal:
path: metadata.labels
value:
app.kubernetes.io/instance: prometheus-postgres-exporter-unittest
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: prometheus-postgres-exporter
app.kubernetes.io/version: 0.1.0
my-custom-discovery-label: my-value
helm.sh/chart: prometheus-postgres-exporter-0.1.0

File diff suppressed because it is too large Load Diff

View File

@ -248,12 +248,23 @@ deployment:
# secretName: my-secret
## @section Grafana
## @param grafana.enabled Enable integration into Grafana.
## @param grafana.dashboards.businessMetrics Enable deployment of Grafana dashboard `businessMetrics`.
## @param grafana.enabled Enable integration into Grafana. Require the prometheus operator deployment.
grafana:
enabled: false
## @param grafana.dashboardDiscoveryLabels Labels that Grafana uses to discover resources. The labels may vary depending on the Grafana deployment.
## @skip grafana.dashboardDiscoveryLabels
dashboardDiscoveryLabels:
grafana_dashboard: "1"
dashboards:
businessMetrics: true
## @param grafana.dashboards.postgresExporter.enabled Enable deployment of Grafana dashboard `postgresExporter`.
## @param grafana.dashboards.postgresExporter.annotations Additional configmap annotations.
## @param grafana.dashboards.postgresExporter.labels Additional configmap labels.
postgresExporter:
enabled: true
annotations: {}
labels: {}
## @section Ingress
ingress: