node-k8s-dot-graph
node.js library to create a dot graph (e.g. graphviz) from kubernetes objects. This lets you create a graph visualization of your kubernetes cluster.
Inputs are the kubernetes object lists from the k8s api endpoints for NodeList, PodList, ServiceList, and IngressList and output is a string in dot format representing the kubernetes cluster.
Example Code
{ const nodeList = await const podList = await const ingressList = await const serviceList = await const dotGraphString = kdg}
Options
makeDotGraph()
accepts the following dot format options with defaults shown:
kdg
Installation
npm install k8s-dot-graph
Example Output
This is an example of a small 2-node, 3-pod cluster. These get much larger.
digraph {sep=6.2;ranksep="2.0 equally";splines="ortho";"svcs:app1" [label="service: app1"][shape=diamond];"svcs:auth" [label="service: auth"][shape=diamond];"svcs:redis-master" [label="service: redis-master"][shape=diamond];"pods:app1-3746604072-3jfn8" [label="app1-3746604072-3jfn8"][shape=oval];"pods:auth-1124301931-8h7fp" [label="auth-1124301931-8h7fp"][shape=oval];"pods:redis-master-853269215-glqjs" [label="redis-master-853269215-glqjs"][shape=oval];"ings:svc" [label="ingress: svc"][shape=invtriangle];"internet" [label="internet"][shape=circle];subgraph "cluster-gke-testcluster-pool-3-0aa49f08-p92k" { label="node: gke-testcluster-pool-3-0aa49f08-p92k";"pods:auth-1124301931-8h7fp";"pods:redis-master-853269215-glqjs";} subgraph "cluster-gke-testcluster-pool-3-cc049887-zsmc" { label="node: gke-testcluster-pool-3-cc049887-zsmc";"pods:app1-3746604072-3jfn8";}"internet" -> "ings:svc";"internet" -> "svcs:app1";"ings:svc" -> "svcs:auth";"svcs:app1" -> "pods:app1-3746604072-3jfn8";"svcs:auth" -> "pods:auth-1124301931-8h7fp";"svcs:redis-master" -> "pods:redis-master-853269215-glqjs";}
Example Visualized
Contributions
Issues/PRs are welcome.