ConfigHub · Durable config for coding agents
Docs / examples/walkthroughs/story-32-grafana-dashboards-oci.md Source on GitHub →

Mount 20 Grafana Dashboards via Kubernetes 1.36+ OCI Image Volumes (Zero 1 MiB ConfigMap Limit)

Stuffing 20+ Grafana dashboard JSONs as escaped strings inside Helm ConfigMaps is a classic platform-engineering headache: you hit etcd's 1 MiB object ceiling, bloat Helm release secrets, and end up running fragile grafana_dashboard: "1" sidecar watchers with zero atomic rollback. With cub bundle (Zero Hub — no hub or cluster required), you validate every dashboard JSON (and block accidental credentials), pack the entire dashboards/ directory past 1 MiB into one immutable, digest-pinned OCI Config Bundle, and mount it read-only at /var/lib/grafana/dashboards via Kubernetes 1.36+ volumes[].image.

Quick start

You need: the ConfigHub plugin (Zero Hub) and python3 (to generate 20 realistic dashboard JSON files locally if you do not bring your own). (cub bundle ... remains a silent compatibility alias.)

By handAsk your agent
Generate or collect dashboards/*.jsonGenerate 20 Grafana dashboards (> 1 MiB total) in dashboards/ and scaffold .confighub-bundle.yaml (steps 1–2)"Collect our 20 Grafana dashboard JSONs into dashboards/ and scaffold .confighub-bundle.yaml for /var/lib/grafana/dashboards."
Validate all JSON + block secretscub bundle validate (step 3)"Validate every JSON file in dashboards/ and verify no API tokens or credentials leaked into any dashboard."
Build immutable OCI Config Bundle (> 1 MiB)cub bundle build --out dist/grafana-dashboards.oci · cub bundle inspect dist/grafana-dashboards.oci (step 4)"Pack all 20 Grafana dashboards into a single deterministic OCI Config Bundle past etcd's 1 MiB ConfigMap cap."
Mount read-only via K8s 1.36+ volumes[].imagecub bundle podspec --app grafana --ref ghcr.io/acme/grafana-dashboards@sha256:... --mount /var/lib/grafana/dashboards (step 5)"Emit a PSS-hardened Kubernetes 1.36+ volumes[].image PodSpec mounting the digest-pinned bundle read-only at /var/lib/grafana/dashboards."

Without ConfigHub: teams split dashboards across dozens of numbered ConfigMaps to stay under etcd's 1 MiB cap, fight YAML-escaped JSON diffs in Helm PRs, and rely on ConfigMap-polling sidecars that cannot roll back atomically by digest.

Deeper dive

The rest of this page generates 20 Grafana dashboard JSONs totaling over 1 MiB, validates every file while blocking leaked secrets, builds one immutable OCI Config Bundle, and emits a PSS-hardened Kubernetes 1.36+ volumes[].image PodSpec mounting them read-only at /var/lib/grafana/dashboards.

Show the full walkthrough

Human

What you need

The ConfigHub plugin (Zero Hub) and python3. No hub, Kubernetes cluster, Helm chart, or OCI registry account is needed to build and verify the local OCI Image Layout.

Steps

  1. Generate 20 realistic Grafana dashboard JSON files under ~/grafana-oci-demo/dashboards/ totaling over 1.2 MiB (past etcd's 1 MiB ConfigMap limit):
    mkdir -p ~/grafana-oci-demo/dashboards && cd ~/grafana-oci-demo
    python3 - <<'PY'
    import json, pathlib
    out = pathlib.Path("dashboards")
    for i in range(1, 21):
        panels = [
            {"id": p, "type": "timeseries", "title": f"Service {i:02d} Panel {p:02d}",
             "description": "latency p50/p95/p99, error budget, and saturation tracking " * 22,
             "targets": [{"expr": f'rate(http_requests_total{{service="svc-{i:02d}",panel="{p:02d}"}}[5m])'}]}
            for p in range(1, 55)
        ]
        doc = {"uid": f"svc-{i:02d}", "title": f"Service {i:02d} SLOs", "schemaVersion": 39, "panels": panels}
        (out / f"service-{i:02d}.json").write_text(json.dumps(doc, indent=2) + "\n")
    total = sum(p.stat().st_size for p in out.glob("*.json"))
    print(f"wrote 20 dashboards, total {total:,} bytes (> 1 MiB ConfigMap cap)")
    PY
  2. Scaffold .confighub-bundle.yaml targeting /var/lib/grafana/dashboards with a validate_cmd that parses every dashboard JSON so ConfigHub's PostToolUse hook auto-validates every future edit:
    cd ~/grafana-oci-demo
    cub bundle init \
      --dir dashboards \
      --mount /var/lib/grafana/dashboards \
      --validate-cmd "python3 -c 'import glob,json; [json.load(open(f)) for f in sorted(glob.glob(\"dashboards/*.json\"))]'"
    cat .confighub-bundle.yaml
  3. Validate every dashboard JSON and verify cub bundle validate passes syntax checks and blocks accidental datasource tokens or API secrets before packaging:
    cd ~/grafana-oci-demo
    cub bundle validate
  4. Build a single immutable, deterministic OCI Config Bundle (> 1 MiB uncompressed, zero etcd storage footprint) and inspect its file count and reproducible sha256: digest:
    cd ~/grafana-oci-demo
    cub bundle build --out dist/grafana-dashboards.oci
    cub bundle inspect dist/grafana-dashboards.oci
  5. Emit a PSS-hardened Kubernetes 1.36+ volumes[].image PodSpec mounting the digest-pinned OCI Config Bundle read-only at /var/lib/grafana/dashboards:
    cd ~/grafana-oci-demo
    DIGEST=$(cub bundle inspect dist/grafana-dashboards.oci --digest-only)
    cub bundle podspec \
      --app grafana \
      --image grafana/grafana@sha256:example \
      --ref "ghcr.io/acme/grafana-dashboards@${DIGEST}" \
      --mount /var/lib/grafana/dashboards > k8s-grafana-podspec.yaml
    cat k8s-grafana-podspec.yaml

Undo it

Delete ~/grafana-oci-demo. No cluster, Helm release, or OCI registry was modified.

Agent

When packaging Grafana dashboards or other large multi-file config bundles (> 1 MiB):

  • Never cram 20+ dashboard JSONs as escaped strings into Helm ConfigMaps or split them across numbered ConfigMaps to dodge etcd's 1 MiB cap; build a single OCI Config Bundle with cub bundle.
  • Always validate JSON and block secrets first: wire .confighub-bundle.yaml with validate_cmd and run cub bundle validate before building so malformed JSON or hardcoded datasource tokens fail immediately.
  • Mount read-only by digest: emit Kubernetes 1.36+ volumes[].image pinned to @sha256:... (never :latest) mounted readOnly: true at /var/lib/grafana/dashboards, preserving PSS hardening (runAsNonRoot: true, allowPrivilegeEscalation: false, readOnlyRootFilesystem: true, capabilities.drop: [ALL]).

Testing

Generate 20 Grafana dashboard JSON files exceeding 1 MiB total, scaffold .confighub-bundle.yaml, validate all JSON and block secrets with cub bundle validate, build an immutable OCI Config Bundle, and emit a PSS-hardened Kubernetes 1.36+ volumes[].image PodSpec mounting read-only at /var/lib/grafana/dashboards.

This proves: 20+ Grafana dashboards exceeding etcd's 1 MiB ConfigMap cap validate cleanly (JSON syntax + secret guard), pack into a single deterministic OCI Config Bundle via cub bundle, and mount read-only at /var/lib/grafana/dashboards via Kubernetes 1.36+ volumes[].image with atomic digest rollouts and zero sidecar watchers.