Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to draw Linked Clusters #707

Closed
mxw-sec opened this issue Jun 6, 2022 · 4 comments
Closed

unable to draw Linked Clusters #707

mxw-sec opened this issue Jun 6, 2022 · 4 comments

Comments

@mxw-sec
Copy link

mxw-sec commented Jun 6, 2022

In my diagram I am trying to create a Clustered Web app Diagram. This Diagram is Edge to multiple nested Clusters..

dns(edge) >> fw_group (cluster1) >> f5_group(cluster2) >> webapp(cluster3) ...... final resource.. However when I create the diagram if I try to graph cluster to cluster I get an error. TypeError: unsupported operand type(s) for >>: 'list' and 'list', if I setup a single point in between it works just fine..

Code Snippet:

`from diagrams import Cluster, Diagram
from diagrams.aws.compute import ECS
from diagrams.aws.database import RDS
from diagrams.aws.network import ELB
from diagrams.aws.general import GenericFirewall
from diagrams.aws.network import Route53

with Diagram("Trial Webapp", show=False):

dns = Route53("dns")
lb = ELB("F5LB01")

with Cluster("Firewalls"):
    fw_group = [GenericFirewall("FWCP1"),
                GenericFirewall("FWCP2"),
                GenericFirewall("FWCP3")] 

with Cluster("F5 Load Balancers"):
    f5_group = [ELB("f5lb01"),
                ELB("f5lb02"),
                ELB("f5lb03")]

with Cluster("Onboarding"):
    webapp = [ECS("WEB8"),
              ECS("WEB10"),
              ECS("WEB11"),
              ECS("WEB08"),
              ECS("WEB18"),
              ECS("WEB19")]

dns >> fw_group >> lb >> webapp` <-- This works

dns >> fw_group >>f5_group >> webapp <-- this does not work..

@mxw-sec mxw-sec changed the title unable to draw nested Clusters unable to draw Linked Clusters Jun 7, 2022
@RyanMillerC
Copy link
Contributor

Linking two Clusters together isn't supported (would be awesome).

What you're trying to do is link two lists of Nodes together. You can take a single Node and >> to a list of Nodes. You can't take a list of Nodes and >> into another list of Nodes.

What you can do instead loop through the first list:

from diagrams import Cluster, Diagram, Edge

from diagrams.k8s.compute import Deployment, Pod

with Diagram("Diagram", show=False):
    app_1_pods = [
        Pod('App 1'),
        Pod('App 1'),
        Pod('App 1')
    ]

    app_2_pods = [
        Pod('App 2'),
        Pod('App 2'),
        Pod('App 2')
    ]

    for pod in app_1_pods:
        pod >> app_2_pods

Warning: this is messy...

image

Setting splines to line makes it slightly better but still messy:

from diagrams import Cluster, Diagram, Edge

from diagrams.k8s.compute import Deployment, Pod

graph_attr = {
    "splines": "line"
}

with Diagram("Diagram", show=False, graph_attr=graph_attr):
    app_1_pods = [
        Pod('App 1'),
        Pod('App 1'),
        Pod('App 1')
    ]

    app_2_pods = [
        Pod('App 2'),
        Pod('App 2'),
        Pod('App 2')
    ]

    for pod in app_1_pods:
        pod >> app_2_pods

image

@clayms
Copy link

clayms commented Jun 13, 2022

See the issue comment below for solutions to "link" clusters.
#17 (comment)

@mxw-sec
Copy link
Author

mxw-sec commented Jun 13, 2022

@RyanMillerC Thanks for the information. I did find #17 later after my post, but I had hoped there was a better way to natively map the clusters versus the "splines:lines" it would be easier to treat the "cluster" item as if it was a single entity with an external edge connection point so that you could easily map cluster to cluster versus the requirement to map node to node.

Thanks for the response. this will drastically improve our technical diagram capabilities once we find a way to natively update the file from our CI/CD Process.

Does the diagram code support nested configuration ingest?

For example for Application 1
`with Diagram("Diagram", show=False, graph_attr=graph_attr):
app_1_pods = [
Pod('App 1'),
Pod('App 1'),
Pod('App 1')
]

app_2_pods = [
    Pod('App 2'),
    Pod('App 2'),
    Pod('App 2')
]

for pod in app_1_pods:
    pod >> app_2_pods

then every time i need to connect to app1 and its dependencies, I just reference the source python file as an include?

so my next app might be 

Front End.py

from app1.py import app1

with Diagram("Front-end to App1", show=False, graph_attr=graph_attr):
frontend =FD()

frontend >> app1`

@RyanMillerC
Copy link
Contributor

I wasn't aware of that workaround. Good to know. 😃

@mxw-esi I tried what you're suggesting and got OSError: Global diagrams context not set up. There might be a way to make it work but I've never used diagrams that way.

(p.s. if you wrap your code with a ``` on a line by itself at the beginning and end of the code block, GitHub will format it)

@mxw-sec mxw-sec closed this as completed May 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants