다이어그램 / visio / 비지오 / 그림 그리기 / draw
Diagrams, python code 로 diagram 그리는 툴
아래 예제를 보고 몇번 그려보면 쉽게 할 수 있다. 개인적으로 편리하게 그릴 수 있는 툴이라 생각한다. 문제는 복잡한 diagram 이 되면, 보기가 쉽게 node를 배치하는 것이 어렵다.
from diagrams import Cluster, Diagram, Edge
from diagrams.custom import Custom
from diagrams.onprem.compute import Server
from diagrams.onprem.database import MariaDB
from diagrams.onprem.inmemory import Redis
from diagrams.onprem.aggregator import Fluentd
from diagrams.onprem.monitoring import Grafana, Prometheus
from diagrams.onprem.network import Nginx
from diagrams.onprem.queue import Kafka
from diagrams.aws.compute import EC2Instance
from diagrams.aws.database import RDS
from diagrams.generic.os import Android
from urllib.request import urlretrieve
'''
myserver1 --+
|
V
myserver2 --> db --> telegraf --> kafka --+--> kafka_consumer --> RDS --> myserver3
|
+--> myserver4 --> db
'''
# download the icon image file
telegrafIconUrl = "https://pbs.twimg.com/media/EpU6-f6XcAApdHh?format=png&name=small"
telegrafIcon = "telegraf_small.png"
urlretrieve(telegrafIconUrl, telegrafIcon) # download and save it as 'telegraf_small.png'
springIconUrl = "https://pbs.twimg.com/profile_images/1235868806079057921/fTL08u_H_400x400.png"
springIcon = "spring.png"
urlretrieve(springIconUrl, springIcon)
with Diagram("My Web Service", show=False):
app = Android("app")
wasmyserver2 = Custom("myserver2", springIcon)
wasmyserver1 = Custom("myserver1", springIcon)
with Cluster("DB Cluster"):
dbCluster = [
MariaDB("node1:db1-db2"),
MariaDB("node2:db1-db2"),
MariaDB("node3:db1-db2")]
telegraf = Custom("telegraf", telegrafIcon)
kafka = Kafka("kafka")
wasmyserver2 >> Edge(label="") >> dbCluster
app >> wasmyserver1 >> Edge(label="") >> dbCluster
dbCluster[0] >> telegraf >> kafka \
>> Custom("kafka_consumer", springIcon) \
>> RDS("RDS") \
>> Custom("myserver3", springIcon)
# for edge attributes
# ref: https://graphviz.org/docs/edges/
myserver4 = Custom("myserver4", springIcon)
# kafka >> myserver4 >> Edge(xlabel="to db2", color="red", fontcolor="red") >> dbCluster
kafka >> myserver4
dbCluster << Edge(label="to db2", color="#30638e", fontcolor="#30638e") << myserver4
댓글 없음:
댓글 쓰기