Crawl a Kubernetes cluster and produce structured operational knowledge
Project description
kube2docs
Reverse-engineer a Kubernetes cluster: crawl every workload, discover what it does at runtime, build a dependency graph, and generate operational documentation.
Two-step pipeline:
scan— crawls the cluster, execs into pods, builds a structured JSON knowledge basegenerate— turns that knowledge base into Markdown docs (uses an LLM)
Optimized for non-production clusters where you need to document what's running but can't rely on live traffic to map dependencies.
Install
# From PyPI (coming soon)
pip install kube2docs
# From source
uv venv && uv pip install -e ".[dev]"
Quickstart
# Scan the cluster
kube2docs scan --kubeconfig ~/.kube/config --output ./kb/
# Generate docs
export OPENROUTER_API_KEY=...
kube2docs generate --input ./kb/ --output ./docs/ \
--model openrouter/anthropic/claude-haiku-4-5 --recommendations
How scanning works
Scanning always starts with a read-only inventory via the Kubernetes API: every Deployment, StatefulSet, Service, ConfigMap, etc. is catalogued. Then for each workload, kube2docs picks one running pod and execs into it to discover runtime state — what processes are running, which ports are open, what config files exist, where outbound connections go.
You pick how that runtime discovery happens:
| Mode | Flag | Cost | Best for |
|---|---|---|---|
| Inventory only | --depth survey |
Free | Quick listing — no pod exec |
| Deterministic (default) | — | Free | Regulated envs, CI drift detection, nightly rescans |
| Agentic | --agentic |
~$0.003/workload | Distroless containers, dependency discovery, initial exploration |
Deterministic runs a fixed set of commands (ps, ss, cat known config paths) in every container and parses output with regex. Reproducible, data stays local.
Agentic hands the inventory data to an LLM, which iteratively chooses commands to exec based on what it learns from each step. Works on distroless containers (by reading image metadata when there's no shell), and discovers ~5x more dependencies in testing because it actually reads and understands config files. Non-deterministic; sends exec output (with secrets redacted) to the LLM provider.
# Preview what would be scanned and estimated cost
kube2docs scan --output ./kb/ --agentic \
--model openrouter/moonshotai/kimi-k2.5 --dry-run
# Run the agentic scan
kube2docs scan --output ./kb/ --agentic \
--model openrouter/moonshotai/kimi-k2.5 --api-key $OPENROUTER_API_KEY
Output
The scan command writes to --output:
kb/
├── cluster-overview.json # Cluster summary + dependency list
├── dependency-graph.json # Edges between workloads (internal + external)
├── topology.mmd # Mermaid diagram, auto-embedded in generated docs
├── services.json # All K8s Services
├── nodes.json # Node info
├── events.json # Recent cluster events (last 24h)
├── kube2docs-status.json # Scan progress
└── <namespace>/
├── <workload>.profile.json # Structured workload record
└── <workload>.raw/ # Raw exec outputs, config files
└── agentic/ # LLM conversation artifacts (if --agentic)
The JSON is the source of truth. Designed to be consumed by AI agents, RAG pipelines, or read directly.
What agentic scan won't do
Agentic mode runs LLM-chosen commands inside your pods. The safety filter blocks:
- Writes (
rm,chmod,chown,mv,sed -i,> /path) - Process control (
kill,systemctl stop,shutdown) - Outbound network to non-localhost (prevents data exfiltration)
- Cluster API access (
kubectl,helm, service account token reads) - Package installation (
apt/yum/apk/pip/npm install)
Reads are broad: cat, find, grep, ps, ss, strings, etc. — the LLM has whatever filesystem access the pod's user already has. Secret patterns (JWTs, AWS keys, PEM private keys, URI credentials) are detected and hashed before leaving the local process.
Important: agentic scan sends exec output to the LLM provider you configured. Use --agentic only on clusters where that's acceptable.
Incremental scanning
Re-running scan on the same --output directory skips unchanged workloads by comparing image digests and config versions. Use --force-rescan to override.
Documentation
See CLAUDE.md for architecture details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kube2docs-0.1.0.tar.gz.
File metadata
- Download URL: kube2docs-0.1.0.tar.gz
- Upload date:
- Size: 51.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64f73a0a9f05495195e7576ae061be8876c2e5f1c575a53793f15b4cbb360327
|
|
| MD5 |
063d0409f6c10589fb66ad9678cb15da
|
|
| BLAKE2b-256 |
7bacf10b8fa495537c23e86848e0aa0b4a4df0c946637cd6593bc4bef625c522
|
Provenance
The following attestation bundles were made for kube2docs-0.1.0.tar.gz:
Publisher:
publish.yml on matt-szymczyk/kube2docs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kube2docs-0.1.0.tar.gz -
Subject digest:
64f73a0a9f05495195e7576ae061be8876c2e5f1c575a53793f15b4cbb360327 - Sigstore transparency entry: 1264795028
- Sigstore integration time:
-
Permalink:
matt-szymczyk/kube2docs@1af2867961bea014a43f30c137dd3408ef812592 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/matt-szymczyk
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1af2867961bea014a43f30c137dd3408ef812592 -
Trigger Event:
release
-
Statement type:
File details
Details for the file kube2docs-0.1.0-py3-none-any.whl.
File metadata
- Download URL: kube2docs-0.1.0-py3-none-any.whl
- Upload date:
- Size: 52.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dac69191217937d41b49449f4215d7c243f133f99e6b64231409b4e0a02882a3
|
|
| MD5 |
e727e348c41f60739c2dc4f13eaacd69
|
|
| BLAKE2b-256 |
2ca8061f722d22c416c69a12e18a1edf5124994b0692a00253926e16dd679cb8
|
Provenance
The following attestation bundles were made for kube2docs-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on matt-szymczyk/kube2docs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kube2docs-0.1.0-py3-none-any.whl -
Subject digest:
dac69191217937d41b49449f4215d7c243f133f99e6b64231409b4e0a02882a3 - Sigstore transparency entry: 1264795099
- Sigstore integration time:
-
Permalink:
matt-szymczyk/kube2docs@1af2867961bea014a43f30c137dd3408ef812592 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/matt-szymczyk
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1af2867961bea014a43f30c137dd3408ef812592 -
Trigger Event:
release
-
Statement type: