fix(grafana): add folder annotations to dashboard ConfigMaps
The Grafana sidecar supports grafana_folder annotations to place dashboards in specific folders. Without this, all provisioned dashboards land in the General folder. Add Foxhunt/Infrastructure/CI-CD folder mapping to both CI pipeline and import.sh. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1483,6 +1483,11 @@ deploy:
|
||||
[grafana-dashboards-infra]="cluster-overview.json gpu-overview.json foxhunt-gpu-training.json foxhunt-infrastructure.json"
|
||||
[grafana-dashboards-cicd]="foxhunt-ci-pipelines.json gitlab-services.json"
|
||||
)
|
||||
declare -A FOLDERS=(
|
||||
[grafana-dashboards-foxhunt]="Foxhunt"
|
||||
[grafana-dashboards-infra]="Infrastructure"
|
||||
[grafana-dashboards-cicd]="CI/CD"
|
||||
)
|
||||
for cm_name in "${!GROUPS[@]}"; do
|
||||
args=""
|
||||
for df in ${GROUPS[$cm_name]}; do
|
||||
@@ -1492,8 +1497,9 @@ deploy:
|
||||
kubectl create configmap "$cm_name" -n foxhunt $args \
|
||||
--dry-run=client -o yaml | \
|
||||
kubectl label -f - --dry-run=client -o yaml --local grafana_dashboard=1 | \
|
||||
kubectl annotate -f - --dry-run=client -o yaml --local grafana_folder="${FOLDERS[$cm_name]}" | \
|
||||
kubectl apply -f -
|
||||
echo " Applied ConfigMap: $cm_name"
|
||||
echo " Applied ConfigMap: $cm_name (folder: ${FOLDERS[$cm_name]})"
|
||||
fi
|
||||
done
|
||||
rm -rf "$TMP_DIR"
|
||||
|
||||
@@ -128,6 +128,13 @@ declare -A CONFIGMAP_GROUPS=(
|
||||
[grafana-dashboards-cicd]="foxhunt-ci-pipelines.json gitlab-services.json"
|
||||
)
|
||||
|
||||
# Folder mapping: ConfigMap name -> Grafana folder name (used by sidecar annotation)
|
||||
declare -A CONFIGMAP_FOLDERS=(
|
||||
[grafana-dashboards-foxhunt]="Foxhunt"
|
||||
[grafana-dashboards-infra]="Infrastructure"
|
||||
[grafana-dashboards-cicd]="CI/CD"
|
||||
)
|
||||
|
||||
deploy_configmaps() {
|
||||
echo ""
|
||||
echo "Deploying dashboard ConfigMaps..."
|
||||
@@ -148,13 +155,14 @@ import json, os
|
||||
tmp = '${tmp_dir}'
|
||||
ns = '${KUBE_NAMESPACE}'
|
||||
groups = ${CONFIGMAP_GROUPS_JSON}
|
||||
folders = ${CONFIGMAP_FOLDERS_JSON}
|
||||
|
||||
items = []
|
||||
for name, files in groups.items():
|
||||
cm = {
|
||||
'apiVersion': 'v1',
|
||||
'kind': 'ConfigMap',
|
||||
'metadata': {'name': name, 'namespace': ns, 'labels': {'grafana_dashboard': '1'}},
|
||||
'metadata': {'name': name, 'namespace': ns, 'labels': {'grafana_dashboard': '1'}, 'annotations': {'grafana_folder': folders.get(name, '')}},
|
||||
'data': {}
|
||||
}
|
||||
for f in files:
|
||||
@@ -187,6 +195,17 @@ done
|
||||
CONFIGMAP_GROUPS_JSON+='}'
|
||||
export CONFIGMAP_GROUPS_JSON
|
||||
|
||||
# Export folders as JSON for python
|
||||
CONFIGMAP_FOLDERS_JSON='{'
|
||||
first=true
|
||||
for name in "${!CONFIGMAP_FOLDERS[@]}"; do
|
||||
$first || CONFIGMAP_FOLDERS_JSON+=','
|
||||
CONFIGMAP_FOLDERS_JSON+="\"${name}\":\"${CONFIGMAP_FOLDERS[${name}]}\""
|
||||
first=false
|
||||
done
|
||||
CONFIGMAP_FOLDERS_JSON+='}'
|
||||
export CONFIGMAP_FOLDERS_JSON
|
||||
|
||||
# --- Deploy ---
|
||||
|
||||
failed=0
|
||||
|
||||
Reference in New Issue
Block a user