Represent volumeClaimTemplates of StatefulSet resources as diagram nodes

This commit is contained in:
Philippe Merle
2025-01-21 13:39:24 +01:00
parent df4d1b452b
commit 3b6da7077c
9 changed files with 25 additions and 1 deletions
+18 -1
View File
@@ -254,7 +254,10 @@ class EdgesContext(list):
if volumeClaimTemplates is None:
return
for volumeClaimTemplate in volumeClaimTemplates:
self.add_storage_class("spec.storageClassName", volumeClaimTemplate)
self.append([
f"{volumeClaimTemplate['metadata']['name']}/{self.namespace}/PersistentVolumeClaim/v1",
"REFERENCE"
])
def add_storage_class(self, path, data=None):
if data is None:
@@ -547,6 +550,20 @@ for filename in args.filename:
copy.deepcopy(config.get("clusters", []))
)
cluster.resources[rid] = resource
code_to_exec = get_node_config(resource).get("nodes")
if code_to_exec != None:
nodes = []
try:
exec(code_to_exec)
except Exception as exc:
print("Error:", type(exc), ":", exc.args)
traceback.print_exception(exc)
print("Edges script:\n", code_to_exec)
print("Resource:")
pprint(resource)
raise
for node in nodes:
process_resource(node)
data = yaml.safe_load_all(f) # load YAML file
for resource in data:
+7
View File
@@ -340,6 +340,13 @@ nodes:
StatefulSet/apps/v1:
scoped: Namespaced
diagram_node_classname: diagrams.k8s.compute.STS
nodes: |
for vct in query_path(resource, "spec.volumeClaimTemplates", []):
nodes.append( {
"kind": "PersistentVolumeClaim",
"apiVersion": "v1",
**vct
} )
edges: |
edges.add_all_resources_matching_labels("Pod", "spec.selector.matchLabels")
edges.add_service_account("spec.template.spec")
Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 168 KiB

After

Width:  |  Height:  |  Size: 179 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 300 KiB

After

Width:  |  Height:  |  Size: 308 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 MiB

After

Width:  |  Height:  |  Size: 2.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 322 KiB

After

Width:  |  Height:  |  Size: 290 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 168 KiB

After

Width:  |  Height:  |  Size: 161 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 60 KiB