How philippemerle/kubediagrams works
Purpose and Entry Points
KubeDiagrams generates Kubernetes architecture diagrams from manifest streams/files, rendered Helm/Helmfile output, and cluster state. The primary CLI is bin/kube-diagrams; wrappers expose Helm and kubectl-oriented workflows through bin/helm-diagrams and bin/kubectl-diagrams. Distribution surfaces include the Python package (setup.py), container (Dockerfile), and GitHub Action (action.yml).
Core Diagram Generation Pipeline
bin/kube-diagrams is the central orchestration boundary: it accepts YAML input, options for output format, namespace filtering, and custom configuration, then produces graphical or textual diagram artifacts. Its input is intentionally normalized Kubernetes YAML, allowing upstream tools such as kubectl, Kustomize, Helm, and Helmfile to remain outside the core renderer.
• bin/kube-diagrams
• bin/kube-diagrams.yaml
• setup.py
Semantic Model and Extensibility
The default configuration encodes the architecture vocabulary: supported resource mappings/icons, relationship styles, and clustering rules. Resources are represented as visual nodes; direct references, selectors, ownership, and network-policy communication become typed edges. Namespace is the primary cluster boundary, with label/annotation-driven subclusters. Users can override or extend this model for CRDs, custom icons, clusters, edges, and declarative additions through .kd/.kdc and YAML configuration inputs.
• bin/kube-diagrams.yaml
• examples/argo/KubeDiagrams.yaml
• examples/wordpress/custom_diagram.kd
Input Adapters and External CLI Boundaries
Helm support is a shell-level adapter: bin/helm-diagrams renders a chart through the external helm command and passes the resulting Kubernetes manifests to the core CLI. Cluster-state visualization similarly depends on users or callers providing kubectl get ... -o yaml output; bin/kubectl-diagrams provides the kubectl plugin façade. Thus Helm, Helmfile, Kustomize, and Kubernetes API connectivity are upstream concerns rather than embedded services.
• bin/helm-diagrams
• bin/kubectl-diagrams
• bin/kube-diagrams
Rendering and Consumption Formats
The generator supports raster/vector and graph-description outputs, including DOT, JSON-formatted DOT, SVG, PNG, PDF, D2, Mermaid, and draw.io. Graphviz (dot) is a material runtime dependency; Python dependencies include PyYAML, Diagrams, and graphviz2drawio. dot_json is the interchange boundary for the standalone interactive viewer, while draw.io/D2/Mermaid exports allow downstream editing or rendering.
• interactive_viewer/index.html
• interactive_viewer/script/main.js
• Dockerfile
Web Application
webapp packages the generator as a browser-facing system. The React/Vite frontend provides separate manifest, Helm, Helmfile, cluster, and interactive-viewer tabs; reusable hooks coordinate submission, history, SVG rendering, and API access. The Python backend exposes route groups for each input mode and delegates processing to corresponding services, separating HTTP validation/file handling from generation execution.
• webapp/frontend/src/App.jsx
• webapp/frontend/src/hooks/useDiagramGeneration.js
• webapp/backend/app.py
• webapp/backend/routes/manifest.py
• webapp/backend/services/manifestService.py
Deployment and Delivery
The web frontend and backend have independent Dockerfiles and are composed locally with Docker Compose; Kubernetes deployment assets package the webapp plus a diagram-generation script/configuration. Root-level containerization targets CLI use. GitHub Actions build container images, run lint/tests, release artifacts, and update generated examples; Docker Hub, PyPI, GitHub Actions, and the public online service are the main external delivery/service channels.
• webapp/docker-compose.yml
• webapp/kubernetes/kube-diagrams-webapp.yaml
• webapp/backend/Dockerfile
• .github/workflows/docker-image.yml
• .github/workflows/release.yml
Main entry points: kube-diagrams kube-diagrams CLI · app.py Python web backend · App.jsx React/Vite frontend · docker-compose.yml Web Compose stack
Components 23
CLI generation
Core manifest-to-diagram pipeline.
- kube-diagrams CLI · Normalizes Kubernetes YAML into requested diagram artifacts.
bin/kube-diagrams - Default diagram model · Defines resource mappings, relationships, and cluster rules.
bin/kube-diagrams.yaml - Custom YAML model · Extends icons, clusters, edges, and CRD mappings.
examples/argo/KubeDiagrams.yaml - Declarative additions · Adds custom diagram content.
examples/wordpress/custom_diagram.kd - Resource graph model · Builds visual nodes and typed Kubernetes relationships.
- Format renderers · Emits Graphviz and editable graph formats.
- Diagram artifacts · DOT, SVG, PNG, PDF, D2, Mermaid, and draw.io outputs.
- DOT JSON interchange · Feeds the standalone interactive viewer.
Input adapters
Shell facades that normalize external tool output.
- helm-diagrams · Renders charts with Helm before invoking the core CLI.
bin/helm-diagrams - kubectl-diagrams · Provides a cluster-state visualization facade.
bin/kubectl-diagrams
Web application
Browser UI and HTTP generation service.
- Interactive viewer · Visualizes DOT JSON in the browser.
interactive_viewer/index.html - React/Vite frontend · Offers manifest, Helm, Helmfile, cluster, and viewer workflows.
webapp/frontend/src/App.jsx - Generation hook · Coordinates submission, history, rendering, and API access.
webapp/frontend/src/hooks/useDiagramGeneration.js - Python web backend · Routes input modes to generation services.
webapp/backend/app.py - Manifest route · Validates manifest requests and file handling.
webapp/backend/routes/manifest.py - Manifest service · Delegates manifest generation execution.
webapp/backend/services/manifestService.py
Delivery
Container, package, and deployment surfaces.
- Python package
setup.py - CLI container · Bundles runtime dependencies including Graphviz.
Dockerfile - Web Compose stack · Composes independent frontend and backend containers.
webapp/docker-compose.yml - Web Kubernetes deployment · Packages the webapp with diagram configuration.
webapp/kubernetes/kube-diagrams-webapp.yaml - Backend container
webapp/backend/Dockerfile - Image CI workflow · Builds container images and runs checks.
.github/workflows/docker-image.yml - Release workflow · Publishes release artifacts.
.github/workflows/release.yml
Connections 24
- helm-diagrams → kube-diagrams CLI: rendered manifests
- kubectl-diagrams → kube-diagrams CLI: cluster YAML
- Default diagram model → kube-diagrams CLI: default rules
- Custom YAML model → kube-diagrams CLI: override rules
- Declarative additions → kube-diagrams CLI: custom additions
- kube-diagrams CLI → Resource graph model: parse and relate
- Resource graph model → Format renderers: graph
- Format renderers → Diagram artifacts: render
- Format renderers → DOT JSON interchange: DOT JSON
- DOT JSON interchange → Interactive viewer: load graph
- React/Vite frontend → Generation hook: uses
- Generation hook → Python web backend: generation API
- Python web backend → Manifest route: routes
- Manifest route → Manifest service: validated input
- Manifest service → kube-diagrams CLI: generation execution
- Python package → kube-diagrams CLI: distributes
- CLI container → kube-diagrams CLI: packages
- Web Compose stack → React/Vite frontend: runs
- Web Compose stack → Python web backend: runs
- Backend container → Python web backend: packages
- Web Kubernetes deployment → React/Vite frontend: deploys
- Web Kubernetes deployment → Python web backend: deploys
- Image CI workflow → CLI container: builds
- Release workflow → Python package: publishes