Skip to main content

Creates a preview diagram of Kubernetes Resources without the need to apply them.

Project description

K8s Diagram Previewer

This project exists to help developers take some of the guesswork out of deploying Kubernetes definitions by providing a preview of what will actually be deployed with a set of YAML definitions.

Installation

Clone the repo and run pip install -r requirements.txt

You will also need to install graphviz.

Running

This script takes one argument, a path to a folder containing K8s YAML definitions and outputs a PNG diagram at kubernetes.png representing those definitions, as well as a python file at create_diagram.py if you would like to extend the diagram with other infrastructure surrounding your project. To automatically open the image upon completion, add the --show flag.

python app.py <path_to_folder>

To try out the example, run python3 diagram.py ./example_yaml

For Helm Charts, simply run with the --helm flag and your chart will be templated and placed into /tmp/helm_preview_yaml/chart.yaml before the script runs.

You can also pass in a context from kubeconfig with the --cluster-context flag to pull in all supported resources from the target context prior to diagram generation.

Run python diagram.py -h to see other available options.

usage: diagram.py [-h] [-s] [-f {png,jpg,pdf,svg}] [-p] [-n] [--helm] [--helm-args HELM_ARGS] Folder Path

Create preview diagram of K8s YAML

positional arguments:
  Folder Path           Path to the target definitions

optional arguments:
  -h, --help            show this help message and exit
  -s, --show            Show the diagram when finished
  -f {png,jpg,pdf,svg}, --image-format {png,jpg,pdf,svg}
                        Output diagram as png, jpg, svg or pdf.
  -p, --diagram-py      Save a python script at create_diagram.py that can be edited to add more to the diagram.
  -n, --networking-only
                        Only draw diagram edges to display networking, ignore storage links, etc.
  --helm                Indicates that the path given is a helm chart that needs to be templated.
  --helm-args HELM_ARGS
                        String of arguments to use with helm template. Ex: "--set ingress.enabled=true"

Support

This tool currently supports the following Kubernetes resource types:

  • Deployment
  • Service
  • Ingress
  • Pod
  • CronJob
  • Job
  • DaemonSet
  • StatefulSet
  • ConfigMap
  • Secret
  • PersistentVolumeClaim

There is partial support for all node types listed at https://diagrams.mingrammer.com/docs/nodes/k8s but links will not be formed.

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

k8s-diagram-0.1.0.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

k8s_diagram-0.1.0-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file k8s-diagram-0.1.0.tar.gz.

File metadata

  • Download URL: k8s-diagram-0.1.0.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.7 CPython/3.9.5 Darwin/21.0.0

File hashes

Hashes for k8s-diagram-0.1.0.tar.gz
Algorithm Hash digest
SHA256 53e4d7be363a6a788c5376ff07b62f24e4b88b210d0460e6a4f63b999df1b91a
MD5 2780dacc617dfacc6898289b5d771f57
BLAKE2b-256 68a14596d8600b2e5f8bf5e1668673015bc0007bed95210b032ccbf5b3b42a1d

See more details on using hashes here.

File details

Details for the file k8s_diagram-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: k8s_diagram-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.7 CPython/3.9.5 Darwin/21.0.0

File hashes

Hashes for k8s_diagram-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8483330eabd92799a8d3ae35a9d363ce1b33f15504d7757cdc010565f7d69a94
MD5 16953389ea482b8ab14bf900a1205ac1
BLAKE2b-256 8ad1047404fd50f46984ec3bde5a88c89dd7ff329c02a634510cc5df4eeb3bd0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page