Skip to content

Commit 1361c4e

Browse files
feat: support grafanadashboard CRD
1 parent bab1fa4 commit 1361c4e

File tree

3 files changed

+82
-0
lines changed

3 files changed

+82
-0
lines changed

charts/lighthouse/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,14 @@ We do not recommend that you upgrade the application by overriding `image.tag`.
7878
| grafana.dashboards | Enable creation of Grafana dashboards. [Grafana chart](https://github.com/grafana/helm-charts/tree/main/charts/grafana#grafana-helm-chart) must be configured to search this namespace, see `sidecar.dashboards.searchNamespace` | bool | `false` |
7979
| grafana.dashboardsConfigMapLabel | Must match `sidecar.dashboards.label` value for the [Grafana chart](https://github.com/grafana/helm-charts/tree/main/charts/grafana#grafana-helm-chart) | string | `"grafana_dashboard"` |
8080
| grafana.dashboardsConfigMapLabelValue | Must match `sidecar.dashboards.labelValue` value for the [Grafana chart](https://github.com/grafana/helm-charts/tree/main/charts/grafana#grafana-helm-chart) | string | `"1"` |
81+
| grafana.operatorDashboards | Create GrafanaDashboard CRDs via Grafana Operator from files in `dashboards/` | object | `{"allowCrossNamespaceImport":false,"annotations":{},"enabled":false,"extraSpec":{},"folder":"","folderUID":"","instanceSelector":{"matchLabels":{}},"labels":{},"namespace":"","resyncPeriod":"","suspend":false,"uid":""}` |
82+
| grafana.operatorDashboards.allowCrossNamespaceImport | Allow matching Grafana instances outside current namespace | bool | `false` |
83+
| grafana.operatorDashboards.extraSpec | Additional spec fields to merge into GrafanaDashboard.spec | object | `{}` |
84+
| grafana.operatorDashboards.folder | Optional folder metadata | string | `""` |
85+
| grafana.operatorDashboards.instanceSelector | Selector to match Grafana instances managed by the operator | object | `{"matchLabels":{}}` |
86+
| grafana.operatorDashboards.labels | Extra labels and annotations on the GrafanaDashboard resources | object | `{}` |
87+
| grafana.operatorDashboards.namespace | Optional target namespace for the GrafanaDashboard CRDs (defaults to release namespace) | string | `""` |
88+
| grafana.operatorDashboards.resyncPeriod | Operator sync behavior | string | `""` |
8189
| image.pullPolicy | | string | `"IfNotPresent"` |
8290
| image.repository | Image for lighthouse | string | `"sigp/lighthouse"` |
8391
| image.tag | Overrides the image tag | string | Chart.appVersion |
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{{- $g := $.Values.grafana -}}
2+
{{- if and $g.operatorDashboards $g.operatorDashboards.enabled -}}
3+
{{- $op := $g.operatorDashboards -}}
4+
{{- $files := .Files.Glob "dashboards/*" -}}
5+
{{- range $path, $_ := $files }}
6+
---
7+
apiVersion: grafana.integreatly.org/v1beta1
8+
kind: GrafanaDashboard
9+
metadata:
10+
name: {{ include "lighthouse.fullname" $ }}-{{ base $path | replace "." "-" | trunc 63 | trimSuffix "-" }}
11+
{{- with $op.namespace }}
12+
{{- if . }}
13+
namespace: {{ . }}
14+
{{- end }}
15+
{{- end }}
16+
labels:
17+
{{- include "lighthouse.labels" $ | nindent 4 }}
18+
{{- with $op.labels }}
19+
{{- toYaml . | nindent 4 }}
20+
{{- end }}
21+
{{- with $op.annotations }}
22+
annotations:
23+
{{- toYaml . | nindent 4 }}
24+
{{- end }}
25+
spec:
26+
allowCrossNamespaceImport: {{ default false $op.allowCrossNamespaceImport }}
27+
{{- with $op.instanceSelector }}
28+
instanceSelector:
29+
{{- toYaml . | nindent 4 }}
30+
{{- end }}
31+
{{- with $op.folder }}
32+
folder: {{ . }}
33+
{{- end }}
34+
{{- with $op.folderUID }}
35+
folderUID: {{ . }}
36+
{{- end }}
37+
{{- with $op.uid }}
38+
uid: {{ . }}
39+
{{- end }}
40+
{{- with $op.resyncPeriod }}
41+
resyncPeriod: {{ . }}
42+
{{- end }}
43+
{{- if hasKey $op "suspend" }}
44+
suspend: {{ $op.suspend }}
45+
{{- end }}
46+
{{- with $op.extraSpec }}
47+
{{- toYaml . | nindent 2 }}
48+
{{- end }}
49+
json: |
50+
{{- $.Files.Get $path | nindent 4 }}
51+
{{- end }}
52+
{{- end }}

charts/lighthouse/values.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,28 @@ grafana:
6666
dashboardsConfigMapLabel: grafana_dashboard
6767
# -- Must match `sidecar.dashboards.labelValue` value for the [Grafana chart](https://github.com/grafana/helm-charts/tree/main/charts/grafana#grafana-helm-chart)
6868
dashboardsConfigMapLabelValue: "1"
69+
# -- Create GrafanaDashboard CRDs via Grafana Operator from files in `dashboards/`
70+
operatorDashboards:
71+
enabled: false
72+
# -- Optional target namespace for the GrafanaDashboard CRDs (defaults to release namespace)
73+
namespace: ""
74+
# -- Extra labels and annotations on the GrafanaDashboard resources
75+
labels: {}
76+
annotations: {}
77+
# -- Selector to match Grafana instances managed by the operator
78+
instanceSelector:
79+
matchLabels: {}
80+
# -- Allow matching Grafana instances outside current namespace
81+
allowCrossNamespaceImport: false
82+
# -- Optional folder metadata
83+
folder: ""
84+
folderUID: ""
85+
uid: ""
86+
# -- Operator sync behavior
87+
resyncPeriod: ""
88+
suspend: false
89+
# -- Additional spec fields to merge into GrafanaDashboard.spec
90+
extraSpec: {}
6991

7092
lighthouse:
7193
# -- URL to the Execution Client Engine API. Will use configured JWT to authenticate.

0 commit comments

Comments
 (0)