-
Notifications
You must be signed in to change notification settings - Fork 11
/
apply-grafana-dashboards.sh
executable file
·33 lines (30 loc) · 1.55 KB
/
apply-grafana-dashboards.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
#
# apply-grafana-dashboards.sh updates the grafana-dashboard-provisioning and
# grafana-dashboards configmaps using configuration data from
# config/fedefation/grafana. This script assumes the target cluster credentials
# are already available.
# Create provisioning configuration for grafana dashboards.
kubectl create configmap grafana-dashboard-provisioning \
--from-file=config/federation/grafana/provisioning/dashboards \
--dry-run="client" -o json | kubectl apply -f -
# Minify the JSON dashboards to help get around the limitation that ConfigMaps
# cannot be larger than 1MB. Like below, this is just a stopgap until even the
# minified JSON concatenated into a single ConfigMap exceeds the limit.
mkdir -p config/federation/grafana/dashboards-minified
pushd config/federation/grafana/dashboards
for d in $(ls *.json); do
jq -c . < $d > ../dashboards-minified/$d
done
popd
# Create conigmap for actual grafana dashboards.
#
# NOTE: We are piping the configmap data to `kubectl replace` here (instead of
# `kubectl create`) due to a limitation of the size of metadata.annotations in
# k8s. When using `create` we hit an error complaining about metadata.annotation
# exceeding 262144 characters. Using `replace` apparently overwrites old
# metadata allowing room for the new. We will still have a problem when the
# total size of the JSON files exceeds the maximium size for a ConfigMap (1MB).
kubectl create configmap grafana-dashboards \
--from-file=config/federation/grafana/dashboards-minified \
--dry-run="client" -o json | kubectl replace -f -