How longhorn/kbench works
Project type and purpose
• KBench is an open-source benchmarking tool focused on storage (local and distributed) and Kubernetes.
• It orchestrates FIO workloads (shell scripts + .fio job definitions), packages them in containers, deploys them as Kubernetes workloads, and exports results via logs and a Prometheus-style metric-exporter.
File structure
Top-level:
• Dockerfile.dapper, Makefile – CI/build orchestration
• deploy/ – Kubernetes YAMLs for single-volume and comparison benchmarks
• fio/ – all FIO job files (.fio), wrapper scripts (run.sh, parse.sh, cmp_run.sh, etc.)
• metric-exporter/ – Go module implementing a HTTP service that collects FIO results and serves Prometheus metrics
• package/ – Dockerfile used to build the final container image
• scripts/ – reusable CI/build/package/validate/versioning scripts
Extract insights from the README
• Describes two primary modes: single-volume and comparison benchmarks.
• Shows usage patterns: local binary, Docker container, or Kubernetes deployment.
• Emphasizes FIO metrics (IOPS, bandwidth, latency, CPU idleness) and how to interpret them.
• Mentions default storage-class usage and configurable parameters (SIZE, CPU_IDLE_PROF, storage class names).
Main components
A. Build & CI subsystem
– Source code (Git repo)
– CI scripts (scripts/ci) invoking Dapper (Dockerfile.dapper) and Makefile
– Result: kbench container image (package/Dockerfile) pushed to registry
B. FIO Runner
– Container entrypoint (scripts/entry or fio/run.sh inside image)
– FIO job files (fio/*.fio) and shell wrappers (fio/run.sh, cmp_run.sh, parse.sh, common-include.fio)
– Mounted test volume (host path, PV/PVC in Kubernetes)
– Produces JSON outputs and summary logs
C. Metric-Exporter Service
– Go HTTP server (metric-exporter/main.go)
– Registry and metrics packages (metric-exporter/registry, metrics, types)
– Scrapes or ingests FIO JSON outputs, exposes Prometheus endpoint
D. Kubernetes Deployment
– deploy/fio.yaml (Job/Pod spec for single-volume)
– deploy/fio-cmp.yaml (for comparison)
– Volume Claims (PVCs) and storage classes (local-path, Longhorn, etc.)
– Pods run kbench container, sidecar or init-container for metric-exporter (if used)
E. External Systems
– Prometheus (scrapes metric-exporter)
– kubectl / user (fetches logs via kubectl logs -l kbench=fio)
– Optional Grafana for dashboards
Relationships and data flows
• CI → Docker registry: build & publish image
• Kubernetes API → deploys FIO Job pods using images
• FIO Runner container → runs FIO jobs against test volume → writes JSON + logs
• Metric-Exporter → reads FIO JSON or listens on a local port → exposes Prometheus metrics
• Prometheus → scrapes metric-exporter → stores time-series data
• User → kubectl logs and/or Grafana dashboards
Important architectural patterns & design principles
• Containerization: each component (FIO runner, metric-exporter) packaged in Docker
• Declarative deploy: Kubernetes manifests define everything from PVCs to Jobs
• Modular scripting: separate job definitions (.fio) and wrappers (shell scripts)
• Micro-service style: metric-exporter is a standalone HTTP service
• CI/CD pipeline: Dapper + Makefile + scripts automate build, validation, versioning