A short script that transforms logical service call maps (e.g., A calls B, B calls C) into Kubernetes deployments. Useful for testing out networking and network policies in Kubernetes.
-
Run the script with a demo file:
python gen-graph.py layouts/sample.json
-
Apply the generated YAML to your Kubernetes cluster:
kubectl apply -f layouts/sample.yaml
-
(Optional) Check out the generated call graph using Otterize:
otterize mapper visualize -n demo -o out.png; open out.pngYou can find the installation instructions for the Otterize Network Mapper here.
Given a this file layouts/sample.json:
[
["demo", "a", "demo", "b"],
["demo", "b", "demo", "c"],
["demo", "d", "demo", "e"],
["demo", "e", "demo", "f"],
["demo", "f", "demo", "d"],
["demo", "t", "demo", "t1"],
["demo", "t", "demo", "t2"],
["demo", "t", "demo", "t3"],
["demo", "t3", "demo", "s"],
["demo", "t2", "demo", "s"],
["demo", "t1", "demo", "s"]
]The script will generate a corresponding layouts/sample.yaml file which you can then kubectl apply to your Kubernetes cluster.
Here is an example of the generated call graph:
This image shows the deployments and their interactions as defined in the input file. Each node represents a deployment, and the arrows indicate the calls between them.
It was generating using the Otterize Network Mapper which helps visualizing these relationships, making it easier to understand traffic patterns in Kubernetes clusters and use them to generate network policies using the Otterize Intents Operator.
Visit the docs to read more.
