Engineering Blog

                            

KubeDiagrams: Automatically Generate Stunning Kubernetes Architecture Diagrams from Code and Clusters

In the fast-paced world of Kubernetes, keeping architectural documentation in sync with your actual deployments is a constant challenge. YAML manifests pile up, Helm charts evolve, and live clusters drift—leaving diagrams outdated or, worse, non-existent. Enter KubeDiagrams, an open-source tool that automates the creation of clear, professional architecture diagrams directly from your Kubernetes resources.

Whether you’re working with raw manifests, Helm charts, Kustomize overlays, helmfiles, or even a running cluster, KubeDiagrams turns complex configurations into visually intuitive diagrams with minimal effort.

Key Features That Set KubeDiagrams Apart

  • Broad Input Support: Generate diagrams from Kubernetes YAML manifests, Kustomize files, Helm charts (local or remote), helmfiles, or directly from a live cluster using kubectl.
  • Extensive Resource Coverage: Supports over 47 built-in Kubernetes resource types (Deployments, Services, Ingresses, ConfigMaps, PersistentVolumeClaims, NetworkPolicies, RBAC roles, and more) plus full support for Custom Resources (CRDs).
  • Intelligent Clustering: Automatically groups resources by namespace, labels, or annotations. Predefined clusters use common labels like app.kubernetes.io/name for clean, logical organization.
  • Rich Relationships: Visualizes connections with styled edges (e.g., owner references, label selectors, volume mounts, and communication paths) using official Kubernetes icons for instant familiarity.
  • Customization Power: Declaratively define custom clusters, nodes, and edges in YAML for tailored diagrams that highlight your architecture’s unique aspects.
  • Multiple Output Formats: Export to PNG, SVG, PDF, JPEG, GIF, TIFF, or interactive JSON for web-based viewing (with zoom, pan, tooltips, and export capabilities).
  • Seamless Integration: Available as a CLI tool, Python library, Docker image, kubectl plugin, Nix flake, or GitHub Action—perfect for CI/CD pipelines.

How It Works: Simple Yet Powerful

Installation is straightforward via pip, making it easy to integrate into any developer environment:

pip install KubeDiagrams

Once installed, generating a diagram from a local directory of manifests is as simple as a single command:

# Generate a diagram from a folder of YAML files
kubediagrams --input ./manifests/ --output diagram.png

For live clusters, you can pipe your current state directly:

kubectl get all -o yaml | kubediagrams --input - --output live-cluster.png

Why This Matters for Modern DevOps

Manual documentation is where accuracy goes to die. By treating your architecture diagrams as “Diagrams as Code,” KubeDiagrams ensures that:

  • PR Reviews include a visual change log.
  • Security Audits can visually trace NetworkPolicies.
  • Troubleshooting sessions start with a clear map of the blast radius.

Ready to get started?

KubeDiagrams is open-source and ready for your most complex clusters. Whether you’re a solo dev or part of a large platform team, it’s time to stop drawing and start generating.

Follow us for more Updates

Previous Post