def main(): with Diagram("Home Network", show=False, filename="output/home_network", outformat="png"): internet = Internet("internet") with Cluster("192.168.0.1/24"): router = Router("Synology RT2600ac") # SynologyRouter switch = Switch("Netgear R7000") raspberrypi = Server("Raspberry Pi 4 8GB") # raspberrypi raspberrypi_docker = Docker("Docker") devices = Client("Devices") internet >> router internet << router router >> raspberrypi router >> switch router >> devices switch >> devices with Cluster("10.0.0.0/28"): service_nginx_proxy = Nginx("nginx-proxy") service_grafana = Grafana("Grafana") service_pi_hole = DNS("Pi-hole") service_portainer = LinuxGeneral("Portainer") service_telegraf = LinuxGeneral("Telegraf") service_prometheus = Prometheus("Prometheus") service_loki = Loki("Loki") service_promtail = Loki("Promtail") raspberrypi >> raspberrypi_docker raspberrypi_docker >> service_nginx_proxy service_nginx_proxy >> service_grafana service_nginx_proxy >> service_pi_hole service_nginx_proxy >> service_portainer service_nginx_proxy >> service_telegraf service_nginx_proxy >> service_prometheus service_nginx_proxy >> service_loki service_nginx_proxy >> service_promtail service_prometheus >> Edge(label="collect metrics", color="firebrick", style="dashed") >> service_telegraf service_promtail >> Edge(label="push logs", color="firebrick", style="dashed") >> service_loki service_grafana >> Edge(label="query", color="firebrick", style="dashed") >> service_prometheus service_grafana >> Edge(label="query", color="firebrick", style="dashed") >> service_loki
def simple_main(): # graph_attr é a lista de parâmetros utilizados na construção do diagrama. graph_attr = {"fontsize": "32", "fontcolor": "#1D3B52", "bgcolor": "white"} # Cria o Diagrama base do nosso mapa with Diagram('fboaventura.dev', direction='LR', filename='simple_fboaventura_dev', outformat='png', graph_attr=graph_attr, show=False) as diag: # Adiciona os nós no mapa ingress = Haproxy('loadbalancer') webserver = Nginx('django') db = Postgresql('database') memcached = Memcached('sessions') # Criamos um cluster para os componentes do Celery, que trabalham em conjunto with Cluster('Celery'): beat = Celery('beat') workers = [Celery('worker1'), Celery('worker2')] flower = Celery('flower') broker = Rabbitmq('broker') logs = Redis('logs') # Montamos o mapa de relacionamentos entre os nós ingress >> webserver webserver >> broker beat >> broker workers >> beat webserver >> db db >> broker webserver >> memcached broker >> logs workers >> logs flower >> beat flower >> workers beat >> logs
from diagrams.onprem.network import Nginx from diagrams.onprem.vcs import Git with Diagram("trial", show=False, outformat="png"): with Cluster("office"): git = Git("GitBucket") developer = Client("developer") with Cluster("on-premises"): on_premises_balancer = Server("balancer") on_premises_deploy_worker = Jenkins("deploy worker") with Cluster("ASP"): on_premises_asp_app = Server("application") on_premises_asp_db = MongoDB("database") on_premises_asp_web_server = Nginx("web server") with Cluster("AWS"): aws_balancer = Server("balancer") aws_jenkins = Jenkins("deploy worker") with Cluster("ASP"): aws_asp_app = Server("application") aws_asp_db = Dynamodb("database") aws_asp_web_server = Nginx("web server") with Cluster("Azure"): azure_balancer = Server("balancer") azure_jenkins = Jenkins("deploy worker") with Cluster("ASP"):
from diagrams import Cluster, Diagram from diagrams.k8s.compute import Pod from diagrams.k8s.network import Service from diagrams.onprem.database import PostgreSQL from diagrams.onprem.network import Nginx from diagrams.programming.framework import React def kube_svc(name, replica_count, db): svc = Service(name) apps = [] for _ in range(replica_count): pod = Pod("pod") apps.append(svc >> pod >> db) return svc with Diagram("Lorem Ipsum Simple", show=True, filename='lorem_ipsum_simple'): ui = React("UI") with Cluster("Lorem Ipsum - Kube"): with Cluster("db") as cluster: db_books = PostgreSQL("books") db_auth = PostgreSQL("auth") net = Nginx("loremipsum.com") net >> kube_svc('books', 2, db_books) net >> kube_svc('auth', 2, db_auth) search_engine = Service("Search Engine") db_books - search_engine ui >> net
local_development = Custom("", "MacOS-Logo.png") with Cluster("GitHub"): github_actions = GithubActions("GitHub Actions") github = Github("GitHub") local_development >> github >> github_actions with Cluster("Digital Ocean", direction="LR"): server = Ubuntu("Ubuntu 18.04") github_actions >> server with Diagram("./custom_resources/Internal Working"): with Cluster("Internet"): users = Users("Site Visitors") with Cluster("Digital Ocean", direction="LR"): server = Ubuntu("Ubuntu 18.04") nginx = Nginx("Nginx") static_assets = Custom("Static", "static.png") with Cluster("Gunicorn Workers", direction="LR"): worker1 = Gunicorn("worker1") worker2 = Gunicorn("worker2") worker3 = Gunicorn("worker3") workers = [worker3, worker2, worker1] with Cluster("Django Stack", direction="LR"): django_app = Django("Django") sqlite = Custom("SQLite", "SQLite.svg") django_app - sqlite workers - django_app nginx - workers static_assets - nginx users << Edge(color="Orange") << nginx
from diagrams.aws.compute import EC2 from diagrams.aws.database import RDS, Database from diagrams.aws.network import ELB from diagrams.oci.monitoring import Queue from diagrams.onprem.database import MySQL from diagrams.onprem.inmemory import Redis from diagrams.onprem.network import Nginx, Apache, Internet from diagrams.onprem.queue import Celery """ https://diagrams.mingrammer.com """ with Diagram("Sample", show=False): user_web = EC2("Web") with Cluster('WEB SERVER'): web_server = [Apache('Web Server'), Nginx('Web Server')] with Cluster('QUEUE'): sever_queue = Redis('Queue Broker') sever_queue - [Celery('Queue Worker')] with Cluster('DATABASE'): db_master = MySQL('Database') # db_master - Database('Database') with Cluster('DATABASE2'): db_slave = MySQL('Database2') # db_slave - Database('Database2') user_web >> web_server >> sever_queue sever_queue >> db_master
from diagrams.onprem.inmemory import Memcached, Redis from diagrams.onprem.queue import Celery, Rabbitmq from diagrams.onprem.network import Nginx, Haproxy graph_attr = { "fontsize": "32", "fontcolor": "#1D3B52", "bgcolor": "white" } # Cria o Diagrama base do nosso mapa with Diagram('fboaventura.dev', direction='LR', filename='simple_fboaventura_dev', outformat='png', graph_attr=graph_attr) as diag: # Adiciona os nós no mapa ingress = Haproxy('loadbalancer') webserver = Nginx('django') db = Postgresql('database') memcached = Memcached('sessions') # Criamos um cluster para os componentes do Celery, que trabalham em conjunto with Cluster('Celery'): beat = Celery('beat') workers = [Celery('worker1'), Celery('worker2')] flower = Celery('flower') broker = Rabbitmq('broker') logs = Redis('logs') # Montamos o mapa de relacionamentos entre os nós ingress >> webserver webserver >> broker beat >> broker
with Diagram("On-prem web application", show=False): dns = onprDns('Round-robin DNS ') users = Users('website/mobile users') nfs = nfs('Shared filesystem') with Cluster("Application Servers"): app_servers = [ onprServer("app_srv1"), onprServer("app_srv2"), onprServer("app_srv3") ] Backbone = Backbone("Network") with Cluster("WebProxy Servers"): web_servers = [Nginx("web_srv1"), Nginx("web_srv2"), Nginx("web_srv3")] with Cluster("Mysql active-active cluster"): db_master = onprMysql("userdb") db_master - [onprMysql("userdb")] users - dns >> web_servers web_servers >> Backbone Backbone >> app_servers app_servers >> db_master app_servers >> nfs with Diagram("AWS web application", show=True): users = Users('website/mobile users') with Cluster("Ingress"):
from diagrams.aws.compute import EC2 from diagrams.aws.general import User from diagrams.gcp.network import DNS from diagrams.onprem.ci import Jenkins from diagrams.onprem.container import Docker from diagrams.onprem.database import MySQL, MongoDB from diagrams.onprem.network import Nginx from diagrams.onprem.vcs import Github from diagrams.programming.framework import Django, Backbone with Diagram("CFO-Architecture", show=False): user = User('User') dns = DNS("DNS") with Cluster('Toast Single Instance'): web_server = Nginx('Nginx') with Cluster('Docker'): was = Docker('Docker Container') was - Django('Django') with Cluster('Database'): database = MySQL('MySQL 8.0') with Cluster('CI/CD'): with Cluster('NHN'): nhn_jenkins = Github('NHN Github') nhn_jenkins - Jenkins('NHN Jenkins') with Cluster('Accommate'): acm_jenkins = Jenkins('Accommate Jenkins')
from diagrams import Diagram, Cluster from diagrams.aws.compute import EC2 from diagrams.onprem.monitoring import Grafana, Prometheus from diagrams.onprem.network import Apache, Nginx from diagrams.onprem.iac import Ansible with Diagram("Project DevOps#1", show=True): with Cluster( 'Project DevOps#1 Infrastructure in vagrant - VirtualBox VMs'): with Cluster('web1'): nginx = Nginx('Nginx') with Cluster('Web2'): apache = Apache('Apache2') with Cluster('Monitoring'): with Cluster('prom1'): prom = Prometheus('Prometheus') ans = Ansible('Ansible control node') with Cluster('graf1'): graf = Grafana('Grafana') prom - graf prom >> nginx prom >> apache
from diagrams import Diagram, Cluster, Edge from diagrams.generic.network import Firewall from diagrams.generic.os import Android, IOS, Windows, LinuxGeneral, Centos from diagrams.oci.connectivity import DNS from diagrams.onprem.database import MySQL from diagrams.onprem.inmemory import Redis from diagrams.onprem.network import Nginx, HAProxy from diagrams.programming.framework import Django NUM_APP_SERVERS = 1 NUM_MYSQL_REPLICAS = 2 NUM_UWSGI_FORKS = 2 NUM_REDIS_REPLICAS = 1 with Diagram('Django HA', show=False, direction='TB'): lb = Nginx('Load Balancer based on NGINX') lb_firewall = Firewall('Firewall of Load Balancer') dns = DNS('Any DNS server') redis_haproxy = HAProxy('HAProxy for Redis Cluster') db_haproxy = HAProxy('HAProxy for MySQL Cluster') with Cluster('Users') as users: with Cluster('Desktop users'): dns << LinuxGeneral() >> lb_firewall >> lb dns << Windows() >> lb_firewall >> lb with Cluster('Mobile users'): dns << IOS() >> lb_firewall >> lb dns << Android() >> lb_firewall >> lb
from diagrams import Cluster, Diagram from diagrams.onprem.analytics import Hadoop from diagrams.onprem.inmemory import Memcached from diagrams.onprem.compute import Server from diagrams.onprem.database import PostgreSQL from diagrams.onprem.inmemory import Redis from diagrams.onprem.logging import Fluentd from diagrams.onprem.monitoring import Grafana, Prometheus from diagrams.onprem.network import Nginx from diagrams.onprem.queue import Kafka with Diagram("Unknown architecture", show=False): nginx = Nginx("nginx") metrics = Prometheus("metric") metrics << Grafana("monitoring") with Cluster("Apps Cluster"): grpcsvc = [Server("node 1"), Server("node 2"), Server("node 3")] cache = Memcached('Cache') grpcsvc >> cache with Cluster("Sessions HA"): master = Redis("session") master - Redis("replica") << metrics grpcsvc >> master with Cluster("Database HA"): master = PostgreSQL("users") master - PostgreSQL("slave") << metrics
"fontsize": "12", "labelfontsize": "10", "height": "200.0", "center": "false" } with Diagram("Event Flows - Service proxy", filename="service-proxy", show=False, graph_attr=graph_attr): with Cluster("Example deployment"): with Cluster("Colony Registry Cluster"): dns = DNS("registry1") dns2 = DNS("registry...") with Cluster("Docker Host ..."): i2 = Nginx("App proxy") with Cluster("Applications"): b1 = [Docker("www"), Docker("api"), Docker("mysql2")] with Cluster("Docker Host 1"): i1 = Nginx("App Proxy") with Cluster("Applications"): a1 = [Docker("www"), Docker("api"), Docker("mysql1")] i1 >> a1 i2 >> b1 dns >> Edge(label="DNS Response A host2 IP") >> i2 dns >> Edge(label="DNS Response A host1 IP") >> i1
graph_attr = {"fontsize": "45", "bgcolor": "white"} with Diagram("Infra as <Code> - Classic Design", filename="diagrama_infra_as_code_classic_design", graph_attr=graph_attr): with Cluster("Web Application"): with Cluster("Frontend Cluster"): frontend = [ Server("fe-server-01"), Server("fe-server-02"), Server("fe-server-03") ] backend_lb = Nginx("Backend-LB") with Cluster("Backend Cluster"): backend = [ Server("be-server-01"), Server("be-server-02"), Server("be-server-03") ] Mysql_db = Mysql("MySQL-DB") with Cluster("Redis Cluster"): master = Redis("Master") master - Redis("Replica") with Cluster("Metrics"):
INGRESSES_CLUSTER = "Ingresses" SVC_CLUSTER = "Services" WORKLOAD_CLUSTER = "Workloads" MQTT = "MQTT Topics Subscribe and publish" STORAGE_CLUSTER = "Storage" _HPA = "Horizontal Pod AutoScaler" MONITORING = "Monitoring" with Diagram( name="One-Green Core Helm Kubernetes Architecture", filename="export/helm_k8s_architecture", show=False ): with Cluster(INGRESSES_CLUSTER): api_ingress = Nginx("API") admin_ui_ingress = Nginx("Admin UI") grafana_ingress = Nginx("Grafana") with Cluster(SVC_CLUSTER): api_svc = SVC("API") admin_ui_svc = SVC("Admin UI") pg_svc = SVC("PostgreSQL") influxdb_svc = SVC("InfluxDB") grafana_svc = SVC("Grafana") redis_svc = SVC("Redis") mqtt_svc = SVC("MQTT") api_ingress >> api_svc admin_ui_ingress >> admin_ui_svc grafana_ingress >> grafana_svc
from diagrams import Cluster, Diagram, Edge from diagrams.onprem.compute import Server from diagrams.onprem.network import Nginx, Gunicorn from diagrams.programming.framework import React, Django from diagrams.programming.language import Python from diagrams.generic.database import SQL from diagrams.generic.storage import Storage with Diagram("Adpkd Service with On-Premise", show=True): with Cluster("Front-End"): frontend = React("React") with Cluster("Web Server"): ingress = Nginx("Nginx") with Cluster("WSGI server"): wsgi = Gunicorn("Gunicorn") with Cluster("Service Cluster"): with Cluster("Application"): grpcsvc = Server("adpkd_service") # grpcsvc - Edge(color="brown", style="dashed") - Django("Django") with Cluster("Database"): master1 = SQL("sqlite3") grpcsvc >> master1 with Cluster("Storage Server"): master2 = Storage("minio") grpcsvc >> master2 with Cluster("Inferencer"):
def main(): graph_attr = {"fontsize": "45", "bgcolor": "white"} with Diagram("Deployment-0", graph_attr=graph_attr, show=False, filename="img/deployment-0", outformat="png", direction="LR"): with Cluster("Backup"): velero = Backup("Velero") with Cluster("Storage"): with Cluster("OpeneEBS"): with Cluster("node from pod"): node = Server("node n") with Cluster("Pod + Volume"): hostpath = Pod("openebs-hostpath") hostpath_pv = PV("LocalPV") hostpath >> PVC("claim") >> hostpath_pv >> Edge( color="darkred") >> node hostpath >> node velero >> Edge(color="darkred", style="dashed") << hostpath_pv with Cluster("Longhorn"): with Cluster("Storage nodes"): nodes = [ Server("node-3"), Server("node-2"), Server("node-1") ] with Cluster("Pod + Volume"): longhorn = Pod("longhorn") longhorn_pv = PV("Replicated") longhorn >> PVC("claim") >> longhorn_pv >> Edge( color="blue") >> nodes velero >> Edge(color="blue", style="dashed") << longhorn_pv with Cluster("Internet"): internet = Internet("HTTP clients") certprovider = Internet("Cert provider") lan = Server("LAN") s3 = S3("S3") s3 >> Edge(color="blue") << velero with Cluster("Ingress"): with Cluster("MetalLB"): metallb1 = LoadBalancing("IP1") metallb2 = LoadBalancing("IP2") certprovider >> Edge(color="darkred") >> metallb1 with Cluster("NGINX"): ingress_ext = Nginx("External") ingress_int = Nginx("Internal") with Cluster("Certificates"): certmanager = CertificateManager("cert-manager") certissuer = CertificateManager("cert-issuer") certmanager >> certissuer ingress_ext >> Edge(color="red", label="acme") >> certmanager ingress_ext << Edge(color="red", label="cert-secret") << certmanager internet >> Edge(color="blue") >> metallb1 >> Edge( color="darkgreen") >> ingress_ext certprovider << Edge(color="red", style="dashed", label="http-01") << certissuer lan >> Edge(color="blue") >> metallb2 >> Edge( color="darkgreen") >> ingress_int
#!/usr/bin/python3 from diagrams import Diagram from diagrams import Cluster, Diagram, Edge from diagrams.onprem.compute import Server from diagrams.onprem.network import Haproxy, Internet from diagrams.onprem.database import Mysql from diagrams.onprem.network import Nginx, Linkerd from diagrams.onprem.client import User graph_attr = {"fontsize": "45", "bgcolor": "white"} with Diagram("Infra as <Code> - Arestas", direction="TB", filename="diagrama_infra_as_code_arestas", outformat="png", graph_attr=graph_attr): with Cluster("Cluster Servidores"): servers_fe = [Server("Server1"), Server("Server2"), Server("Server3")] web_user = User("User") web_lb = Nginx("Nginx") mysql_db = Mysql("MySql-DB") www_net = Internet("Internet") web_user>>Edge(color="black", label="TCP/443")>>www_net >>Edge(color="green", label="TCP/443") >> \ web_lb >> Edge(color="orange", label="TCP/80", style="dotted" ) >> servers_fe >> Edge(color="red", label="TCP/3306" , style="dashed") >> mysql_db
from diagrams.oci.security import IDAccess from diagrams.programming.language import Php, Go from diagrams.onprem.vcs import Gitlab from diagrams.generic.storage import Storage from diagrams.generic.virtualization import Vmware from diagrams.onprem.iac import Terraform from diagrams.onprem.ci import Jenkins from diagrams.generic.os import Ubuntu from diagrams.oci.storage import FileStorage from diagrams.generic.network import Switch with Diagram("infrastructure", show=False): switch = Switch("FM Switch") with Cluster("Platform Controller"): # NGINX proxy = Nginx("NGINX proxy") # IAM with Cluster("IAM"): # OpenLDAP ldap = IDAccess("OpenLDAP") # ldap-user-manager ldap_gui = Php("ldap-user-manager") repo = [Storage("Portainer"), Gitlab("Gitlab"), Storage("Nexus")] # Jenkins ci = Jenkins("Jenkins") # LDAP DEPENDENCY ldap_gui << ldap repo << ldap
from diagrams import Cluster, Diagram from diagrams.onprem.network import Apache from diagrams.gcp.network import VPC from diagrams.onprem.container import Docker from diagrams.onprem.network import Nginx from diagrams.gcp.network import Routes with Diagram("Stack", show=False): with Cluster("GCP"): dns1 = Routes("app1.com.br") dns2 = Routes("app2.com.br") dns3 = Routes("app3.com.br") with Cluster("VPC"): google_vpc = VPC("VPC Google Cloud") nginx = Nginx("Virtualhosts - Proxy_Pass") docker_app1 = Docker("app1") docker_app2 = Docker("app2") docker_app3 = Docker("app3") apache_app1 = Apache("index.html") apache_app2 = Apache("index.html") apache_app3 = Apache("index.html") dns3 >> google_vpc >> nginx >> docker_app1 >> apache_app3 dns2 >> google_vpc >> nginx >> docker_app2 >> apache_app2 dns1 >> google_vpc >> nginx >> docker_app3 >> apache_app1
#!/usr/bin/python3 from diagrams import Cluster, Diagram, Edge from diagrams.onprem.compute import Server from diagrams.onprem.database import Mysql from diagrams.onprem.network import Nginx graph_attr = {"fontsize": "45", "bgcolor": "white"} with Diagram("Infra as <Code> - Cluster TB", direction="TB", filename="diagrama_infra_as_code_cluster_tb", graph_attr=graph_attr): with Cluster("VLAN APP-WEB"): with Cluster("Cluster Servidores"): servers = [Server("Server1"), Server("Server2"), Server("Server3")] with Cluster("VLAN DataBase"): mysqldb = Mysql("MySQL") slb = Nginx("Server-LB") slb >> servers >> mysqldb
from diagrams.onprem.monitoring import Grafana, Prometheus from diagrams.onprem.network import Nginx from diagrams.onprem.queue import Kafka filename = os.path.splitext(os.path.basename(__file__))[0] title = "Architectural nodes design" direction = 'LR' graph_attr = {"pad": "0"} with Diagram(title, filename=filename, graph_attr=graph_attr, outformat='png', direction=direction, show=False): ingress = Nginx("ingress") metrics = Prometheus("metric") metrics << Edge(color="firebrick", style="dashed") << Grafana("monitoring") with Cluster("Service Cluster"): grpcsvc = [Server("grpc1"), Server("grpc2"), Server("grpc3")] with Cluster("Sessions HA"): primary = Redis("session") primary - Edge(color="brown", style="dashed") - Redis("replica") << Edge( label="collect") << metrics grpcsvc >> Edge(color="brown") >> primary with Cluster("Database HA"):
# Volumes with Cluster("Files"): volumeA = FileStorage("/files") volumeDB = Database("/database") # Logging with Cluster("Logging"): logs = FluentBit("logging") s2 >> Edge(label="produces") >> logs # Monitoring with Cluster("Monitoring"): s2 << Edge(label="collect") << Prometheus("metric") << Grafana( "monitoring") httpsProxy = Nginx("HTTPS_PROXY") with Cluster("Cloud APIs"): cAPI_ELB = ELB("Cloud API - ELB") cAPI_Targets = [ECS("Cloud API - Organization(s) A...Z")] cAPI_ELB >> cAPI_Targets s1 >> Edge(label="produces") >> volumeA s2 >> Edge(label="consumes") >> volumeA s2 >> Edge(label="R/W") >> volumeDB # Configuration s2 >> Edge(label="Read/Write") >> configServerP s2 >> Edge(label="POST") >> s3 s2 >> Edge(label="POST") >> cAPI_ELB
} node_attrib = { "fontsize": "15", "fontname": "Helvetica Neue Medium" } edge_attrib = { "style": "bold", "color": "#4a4e52" } with Diagram("Deployments",outformat="svg",filename="deployments_prow",show=True, graph_attr=diagram_attrib,node_attr=node_attrib,edge_attr=edge_attrib,direction="TB"): with Cluster("Deployments",graph_attr={"fontsize": "67"}): ing_chartmuseum = Nginx("Ingress") #ing_deck = Nginx("deck") #ing_hook = Nginx("hook") #ing_crier = Nginx("crier") with Cluster("Registries",graph_attr={"fontsize": "47"}): with Cluster("Nexus"): svc_nexus = custom.Custom("Nexus","assets/img/logos/logo_nexus.png") pod_nexus = Pod("nexus") secret_nexus = Secret("nexus") token_nexus = Secret("default-token") sa_nexus = ServiceAccount("default") data_volume = PVC("nexus-data-volume") config_volume_nexus = PV("nexus") configmap_nexus = ConfigMap("nexus")
_icon = "MuPDF.png" class Peewee(Custom): _icon = "peewee.png" from diagrams import Cluster, Diagram from diagrams.aws.compute import ECS from diagrams.aws.integration import SQS from diagrams.elastic.elasticsearch import Elasticsearch from diagrams.onprem.database import PostgreSQL from diagrams.onprem.network import Nginx with Diagram("Web Service", show=True): with Cluster("Processing"): workers = [ECS("worker1"), ECS("worker2")] with Cluster("Extraction"): with Cluster("PDF"): pdf = Camelot("Table") - MuPDF("Text") with Cluster("database"): orm = Peewee("ORM") postgres = PostgreSQL("storage") queue = SQS("event queue") server = Flask() Nginx("Nginx") >> server >> queue >> workers >> pdf pdf >> orm >> postgres