feat: implement declarative dashboard downloading by ID

This commit is contained in:
itumi
2026-02-11 10:10:29 +02:00
parent 6bbf38c2ae
commit 24090a86e8

View File

@@ -34,6 +34,14 @@ data:
editable: true editable: true
options: options:
path: /var/lib/grafana/dashboards path: /var/lib/grafana/dashboards
- name: 'Auto-Downloaded'
orgId: 1
folder: 'Kubernetes'
type: file
disableDeletion: false
editable: true
options:
path: /etc/grafana/dashboards
--- ---
apiVersion: v1 apiVersion: v1
kind: ConfigMap kind: ConfigMap
@@ -305,6 +313,22 @@ spec:
spec: spec:
securityContext: securityContext:
fsGroup: 472 fsGroup: 472
initContainers:
- name: download-dashboards
image: curlimages/curl:latest
command: ["sh", "-c"]
args:
- |
set -e
mkdir -p /tmp/dashboards
# List of dashboard IDs to download
for id in 15757 15759 15760; do
echo "Downloading dashboard $id..."
curl -sL "https://grafana.com/api/dashboards/${id}/revisions/latest/download" -o "/tmp/dashboards/${id}.json"
done
volumeMounts:
- name: auto-dashboards
mountPath: /tmp/dashboards
containers: containers:
- name: grafana - name: grafana
image: grafana/grafana:latest image: grafana/grafana:latest
@@ -383,6 +407,9 @@ spec:
- name: grafana-dashboards - name: grafana-dashboards
mountPath: /var/lib/grafana/dashboards mountPath: /var/lib/grafana/dashboards
readOnly: true readOnly: true
- name: auto-dashboards
mountPath: /etc/grafana/dashboards
readOnly: true
readinessProbe: readinessProbe:
httpGet: httpGet:
path: /api/health path: /api/health
@@ -402,6 +429,8 @@ spec:
- name: grafana-dashboards - name: grafana-dashboards
configMap: configMap:
name: grafana-dashboards name: grafana-dashboards
- name: auto-dashboards
emptyDir: {}
volumeClaimTemplates: volumeClaimTemplates:
- metadata: - metadata:
name: grafana-storage name: grafana-storage