Visualize the dependency graph with `kix graph`
Use kix graph to inspect dependencies in the rendered cluster. The graph
includes references carried by resource manifests and explicit requires or
extraDeps edges. It does not need access to Kubernetes.
Print the tree
Section titled “Print the tree”Tree output is the quickest way to inspect ordering in a terminal:
❱ kix graph 08-namespace-deps --format tree Show output
CustomResourceDefinition/activations.kix.run
└── Activation/08-namespace-deps-8zzrakfr54y8
CustomResourceDefinition/packageinstances.kix.run
├── PackageInstance/backend@platform
│ └── Activation/08-namespace-deps-8zzrakfr54y8
├── PackageInstance/platform-dns@kube-system (import)
│ ├── Activation/08-namespace-deps-8zzrakfr54y8
│ └── Deployment/gateway@app
│ └── Service/gateway@app
│ └── PackageInstance/gateway@app
│ └── Activation/08-namespace-deps-8zzrakfr54y8
└── PackageInstance/gateway@app
└── Activation/08-namespace-deps-8zzrakfr54y8
Namespace/app
├── Service/gateway@app
│ └── PackageInstance/gateway@app
│ └── Activation/08-namespace-deps-8zzrakfr54y8
├── ConfigMap/gateway@app
│ └── Deployment/gateway@app
│ └── Service/gateway@app
│ └── PackageInstance/gateway@app
│ └── Activation/08-namespace-deps-8zzrakfr54y8
├── PackageInstance/gateway@app
│ └── Activation/08-namespace-deps-8zzrakfr54y8
└── Deployment/gateway@app
└── Service/gateway@app
└── PackageInstance/gateway@app
└── Activation/08-namespace-deps-8zzrakfr54y8
Namespace/kube-system
└── PackageInstance/platform-dns@kube-system (import)
├── Activation/08-namespace-deps-8zzrakfr54y8
└── Deployment/gateway@app
└── Service/gateway@app
└── PackageInstance/gateway@app
└── Activation/08-namespace-deps-8zzrakfr54y8
Namespace/platform
├── Service/backend@platform
│ ├── ConfigMap/gateway@app
│ │ └── Deployment/gateway@app
│ │ └── Service/gateway@app
│ │ └── PackageInstance/gateway@app
│ │ └── Activation/08-namespace-deps-8zzrakfr54y8
│ └── PackageInstance/backend@platform
│ └── Activation/08-namespace-deps-8zzrakfr54y8
├── ConfigMap/backend@platform
│ └── Deployment/backend@platform
│ └── Service/backend@platform
│ ├── ConfigMap/gateway@app
│ │ └── Deployment/gateway@app
│ │ └── Service/gateway@app
│ │ └── PackageInstance/gateway@app
│ │ └── Activation/08-namespace-deps-8zzrakfr54y8
│ └── PackageInstance/backend@platform
│ └── Activation/08-namespace-deps-8zzrakfr54y8
├── PackageInstance/backend@platform
│ └── Activation/08-namespace-deps-8zzrakfr54y8
└── Deployment/backend@platform
└── Service/backend@platform
├── ConfigMap/gateway@app
│ └── Deployment/gateway@app
│ └── Service/gateway@app
│ └── PackageInstance/gateway@app
│ └── Activation/08-namespace-deps-8zzrakfr54y8
└── PackageInstance/backend@platform
└── Activation/08-namespace-deps-8zzrakfr54y8
15 resources, 24 dependencies The tree starts with resources that have no dependencies. Each indented entry
depends on the resource above it. In this example, the gateway ConfigMap
appears beneath Service/backend@platform, showing the edge across the
namespace boundary.
If an expected edge is missing, check that the consumer reads a value from the
dependency, such as backend.out.url { } or backend.out.name. That reference
creates the edge. If there is no value to read, add the dependency to
requires or extraDeps.
deps alone does not create an edge. It binds a package build argument to a
provider. An edge appears only when the rendered resource uses a value from
that provider.
Write a DOT graph
Section titled “Write a DOT graph”Use DOT output for Graphviz or another graph viewer:
❱ kix graph 08-namespace-deps --format dot Show output
digraph kix {
rankdir=LR;
node [shape=box];
"0" [label="CustomResourceDefinition/activations.kix.run"];
"1" [label="CustomResourceDefinition/packageinstances.kix.run"];
"2" [label="Deployment/gateway@app"];
"3" [label="Deployment/backend@platform"];
"4" [label="Activation/08-namespace-deps-8zzrakfr54y8"];
"5" [label="PackageInstance/gateway@app"];
"6" [label="PackageInstance/platform-dns@kube-system (import)" style=dashed color=gray];
"7" [label="PackageInstance/backend@platform"];
"8" [label="ConfigMap/gateway@app"];
"9" [label="ConfigMap/backend@platform"];
"10" [label="Namespace/app"];
"11" [label="Namespace/kube-system"];
"12" [label="Namespace/platform"];
"13" [label="Service/gateway@app"];
"14" [label="Service/backend@platform"];
"2" -> "8";
"2" -> "10";
"2" -> "6";
"3" -> "9";
"3" -> "12";
"4" -> "5";
"4" -> "6";
"4" -> "7";
"4" -> "0";
"5" -> "13";
"5" -> "10";
"5" -> "1";
"6" -> "11";
"6" -> "1";
"7" -> "14";
"7" -> "12";
"7" -> "1";
"8" -> "14";
"8" -> "10";
"9" -> "12";
"13" -> "2";
"13" -> "10";
"14" -> "3";
"14" -> "12";
}
15 resources, 24 dependencies Redirect it into a file and render it with Graphviz:
❱ kix graph 08-namespace-deps --format dot > kix-graph.dot❱ dot -Tsvg kix-graph.dot > kix-graph.svg The second command requires Graphviz. The generated SVG is useful when a tree is too deep to scan comfortably.
Write graph data as JSON
Section titled “Write graph data as JSON”Use JSON when another tool will inspect the nodes and edges:
❱ kix graph 08-namespace-deps --format json
{
"nodes": 15,
"edges": 24,
"sample": {
"id": "CustomResourceDefinition/activations.kix.run",
"identityHash": "gvrlspcfgh9a2qnsx5kqxw9f4l3x52jj",
"isImport": false,
"kind": "CustomResourceDefinition",
"name": "activations.kix.run",
"namespace": "_cluster"
}
}
15 resources, 24 dependencies The excerpt above counts the nodes and edges and shows one node. Every node carries its kind, name, namespace, and identity hash, so another tool can join the graph to the rendered manifests.
Choose JSON for automation, not as the default way to read the graph by hand.