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 design(self): s = " with Cluster(\"" + self.__service_name + " service\"):" + '\n' with Cluster(self.__service_name + " service"): s = s + "\t\t" + self.__image_name + " = Server(\"" + self.__image_name + "\")\n" img = Server(self.__image_name) self.node = img return s
def cli( graph_attr: dict = GRAPH_ATTR, output_format: str = OUTPUT_FORMAT, output_path: str = OUTPUT_PATH, ) -> str: """ Generates CLI diagrams """ output = f"{output_path}/cli" with Diagram( "CLI", show=False, outformat=output_format, # graph_attr=graph_attr, filename=output, ): cli = Python("CLI") with Cluster("targets"): with Cluster("local resources"): data = Storage("build objects\nassets") layers = Layer("build\nLambda layers") server = Server("media\nlocal build") with Cluster("cloud resources"): db = Dynamodb("create DB\nseed DB") s3 = S3("sync data") lbd = Lambda("resize images\nencode video") sqs = SQS("queue\nmedia generate\ntasks") cli >> data >> cli cli >> s3 cli >> db cli >> lbd cli >> sqs cli >> layers cli >> server return f"{output}.{output_format}"
def create_diagram(*, graph: Graph, name="Web Service", show=True): with Diagram(name, show=show): nodes = {} for name, aa in graph.actors.items(): if "customer" in name: nodes[name] = Client(label=name) else: nodes[name] = Server(label=name) aa: Actor for name, aa in graph.actors.items(): clusters = [Cluster(cluster.name) for cluster in aa.trust_zones] node = nodes[name] for cluster in clusters: cluster.node(node._id, node.label, **node._attrs) # ELB("lb") >> EC2("web") >> RDS("userdb") >> ss ff: Flow for name, ff in graph.flows.items(): nodes[ff.producer.name] >> Edge(label=ff.type.name) >> nodes[ ff.consumer.name ]
from diagrams import Cluster, Diagram, Edge from diagrams.onprem.compute import Server with Diagram("Cluster Map", show=False): with Cluster("Technocore\nSidero master"): technocore = Server("Technocore\nRaspi4 master") with Cluster("Hegira\nK8s cluster"): leela = Server("Leela\nRaspi4\nHegira master") xerxes = Server("Xerxes\nNUC\nHegira worker") SHODAN = Server("SHODAN\nNUC\nHegira worker") tycho = Server("Tycho\nNUC\nHegira worker") leela >> [xerxes, SHODAN, tycho] technocore >> Edge(style="dotted") >> [leela, xerxes, SHODAN, tycho]
from diagrams import Diagram, Cluster from diagrams.onprem.compute import Server from diagrams.onprem.network import Internet from diagrams.oci.network import LoadBalancer from diagrams.onprem.iac import Terraform from diagrams.onprem.client import User with Diagram("Load balanced application on droplets", show=False, direction="LR"): internet = Internet("Internet") internet with Cluster("home"): user = User("you") terraform = Terraform("terraform apply") user >> terraform >> internet with Cluster("DigitalOcean"): pub_lb = LoadBalancer("pub-lb-burrito-prod") web0 = Server("web0-burrito-prod") web1 = Server("web1-burrito-prod") internet >> pub_lb pub_lb >> web0 pub_lb >> web1
from diagrams import Cluster, Edge from diagrams.onprem.compute import Server from diagrams.onprem.client import User, Client from diagrams.oci.monitoring import Event with Cluster('Event clustering', direction="TB"): evclus = Server('evclus') # user = User('user') cluschema = Client('cluschema') cluschema >> evclus # user >> cluschema >> evclus
from diagrams.aws.database import Dynamodb from diagrams.azure.database import CosmosDb from diagrams.onprem.ci import Jenkins from diagrams.onprem.client import Client, Users from diagrams.onprem.compute import Server from diagrams.onprem.database import MongoDB 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")
from diagrams.generic.network import Router from diagrams.generic.database import SQL from diagrams.onprem.monitoring import Splunk #(png, jpg, svg, and pdf) are allowed. with Diagram(name="OCP3_Ingress_Egress", show=False, outformat="png"): #metrics = Prometheus("metric") #metrics << Edge(color="firebrick", style="dashed") << Grafana("monitoring") #helm = Helm("deploy1") #deploy1 = Deploy("deploy1") serverExtA = Server("DB Server") #serverExtB = Server("DB Server") with Cluster("Ingress Router ZONE A"): haproxy_ingressA = Ingress("app1.example.com") #with Cluster("Ingress Router ZONE B"): # haproxy_ingressB = Ingress("haroxy") with Cluster("Egress Router Namespace A"): haproxy_egressA = Ingress("haproxy") #with Cluster("Egress Router Namespace B"): # haproxy_egressB= Ingress("haproxy")
width="4", shape="plaintext", ) workstation = Ansible("homelab.git") with Cluster("Service Node"): ingress = Traefik("ingress") middleware = [Firewall("OAuth middlware")] ingress >> Edge(style="dashed") >> middleware ( ingress >> Edge(color="green") >> [ Server("adguard"), Server("espial"), Server("miniflux"), PostgreSQL("miniflux_db"), Server("firefly"), PostgreSQL("firefly_db"), Server("healthchecks"), Server("n8n"), PostgreSQL("n8n_db"), Prometheus("prometheus"), Grafana("grafana"), Firewall("oauth"), ] ) with Cluster("Media Node"):
from diagrams.onprem.compute import Server from diagrams.onprem.container import Docker from diagrams.aws.compute import EKS, Lambda from diagrams.aws.database import Redshift from diagrams.aws.integration import SQS from diagrams.aws.storage import S3 from diagrams.oci.connectivity import DNS from diagrams.onprem.client import Client graph_attr = { "pad": "0", "fontsize": "10", "labelfontsize": "10", "height": "200.0", "center": "false" } with Diagram("Event Flows - DNS Service Discovery", filename="service-resolution", show=False, graph_attr=graph_attr): with Cluster("Example deployment"): with Cluster("Docker hosts, Applications"): c1 = [Docker("host1"), Docker("...")] with Cluster("Colony Registries"): r1 = Server("registry1") r2 = Server("...") e = Edge(label="DNS Query") c1[0] >> e >> r1 c1[0] >> e >> r2
"fontsize": "20", "bgcolor": "white" #transparent } with Diagram("Application Architecture", graph_attr=graph_attr, outformat="png", filename="application_architecture"): ELB("lb") >> EC2("web") >> RDS("userdb") >> S3("store") ELB("lb") >> EC2("web") >> RDS("userdb") << EC2("stat") (ELB("lb") >> EC2("web")) - EC2("web") >> RDS("userdb") with Cluster("Application Context"): app = EC2("Spring Boot") ELB("lb") >> app metrics = Prometheus("metric") metrics << Edge(color="firebrick", style="dashed") << Grafana("monitoring") Jenkins("CI") client = Client("A") client >> User("B") >> Users("S") client >> PostgreSQL("Database") client >> Internet("Remote API") client >> Docker("Docker") client >> Server("Server") client >> SQS("Sync Books") client >> Spring("Backend") client >> React("React")
from diagrams.azure.compute import FunctionApps from diagrams.azure.database import CosmosDb # Download an image to be used into a Custom Node class #pbi_url = "https://www.rippedorange.co.nz/wp-content/uploads/2019/08/power-bi-icon-15.png" # pbi_icon = "./pbi.png" # urlretrieve(pbi_url) with Diagram("Workflow \n ", show=True): with Cluster("On-premise"): on_premise = [ Server("unix_st server") - Storage("Daily reports (csv/txt) \n from 20+ scratch disks") >> Bash( "Scheduled \n bash script (cron job) \n via azcopy sync \n command" ) ] with Cluster("Azure"): azure = BlobStorage("Blob Storage \n Container") # with Cluster("Power BI Service"): # pbi = Custom("Daily report \n on disk usage", pbi_icon) on_premise >> azure
direction=direction, show=False): with Cluster("Multicloud deployment", graph_attr={ "fontsize": "15" }): # overwrite attributes for the default cluster with ServerContents("chassis 1: Bastion host"): Custom("Chassis", "./resources/ovn.png") Crio("HAproxy") Crio("Nginx") Crio("Registry") Crio("Apache") Crio("Bind") Crio("dnsmasq") with AvailabilityZone("chassis 2"): Custom("Chassis", "./resources/ovn.png") Server("nyctea") with AvailabilityZone("chassis 3"): Server("tyto") Custom("Central", "./resources/ovn.png") with Region("chassis 4", graph_attr={ "pencolor": "#60193C", "bgcolor": "#E587B5" }): # one cluster defined but with overwritten attributes Custom("Chassis", "./resources/ovn.png") Server("strix") with VirtualPrivateCloud(""): with PrivateSubnet("Private"): with SecurityGroup("web sg"): with AutoScalling(""): with EC2Contents("A"):
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"): master3 = Server("adpkd_model_serving") # master3 - Edge(color="brown", style="dashed") - Python("Python") grpcsvc >> master3
from diagrams import Cluster, Diagram, Edge from diagrams.gcp.analytics import PubSub from diagrams.gcp.compute import Functions from diagrams.gcp.storage import Storage from diagrams.onprem.compute import Server from diagrams.onprem.client import Client graph_attr = {"bgcolor": "transparent", "pad": "0"} with Diagram("Current Stock", graph_attr=graph_attr, show=False, filename="images/current_stock"): server_1 = Server("Third-party API") server_2 = Server("Third-party API") server_3 = Server("Third-party API") webshop_1 = Client("Webshop") with Cluster("Operational Data Hub Platform"): with Cluster("Operational Data Hub"): with Cluster("Pub/Sub Topic X"): pubsub_1 = PubSub("Subscription XA") with Cluster("Pub/Sub Topic Y"): pubsub_2 = PubSub("Subscription YA") with Cluster("Ingest Project"): function_1 = Functions("Restingest") function_2 = Functions("Produce delta event")
from diagrams.generic.device import Mobile from diagrams.generic.os import IOS from diagrams.onprem.compute import Server from diagrams import Cluster, Diagram, Edge with Diagram("Purchasing Flow"): with Cluster('Player'): payment = Mobile("Payment") fulfillment = Mobile("Fulfillment") with Cluster('Services'): iap = IOS("IAP Backend") backend = Server("Game Backend") payment >> Edge(label = 'do purchase') >> iap fulfillment << Edge(label = 'receipt, product ID') << iap fulfillment >> Edge(label = 'receipt') >> backend backend >> Edge(label = 'is receipt good?') >> iap >> backend backend >> Edge(label = 'updated player') >> fulfillment
from diagrams import Cluster, Diagram, Edge from diagrams.aws.compute import Lambda from diagrams.aws.compute import ECS from diagrams.aws.storage import S3 from diagrams.aws.database import RDS from diagrams.aws.integration import SNS from diagrams.aws.management import Cloudwatch from diagrams.aws.network import APIGateway from diagrams.onprem.compute import Server from diagrams.onprem.client import User with Diagram("BLT Kata final container diagram", show=True): payment_gw = Server("Payment Gateway") customer = User("Customer") marketing = User("Marketing") with Cluster("System"): with Cluster("Promotions"): promotions_cms = ECS("CMS") promotions_gw = APIGateway("Promotions API") promotions_be = Lambda("Promotions BE") promotions_cms >> promotions_gw >> promotions_be with Cluster("In Store"): printer_fe = S3("Docket Printer Front-end") docket_printer = Server("Docket Printer") cashier = User("Cashier") store_fe = S3("Store Front-end") store_api = APIGateway("Store API") store_be = Lambda("Store BE")
from diagrams import Cluster, Diagram from diagrams.onprem.compute import Server from diagrams.onprem.network import Internet with Diagram("docker_postgresql_nodejs", show=False): with Cluster("Docker Host"): with Cluster("Docker Container/Network"): servers = [Server("postgresql"), Server("nodejs")]
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"): primary = PostgreSQL("users") primary - Edge(color="brown", style="dotted") - PostgreSQL("replica") << Edge( label="collect") << metrics grpcsvc >> Edge(color="black") >> primary
from diagrams import Diagram, Cluster from diagrams.gcp.database import Firestore from diagrams.gcp.network import CDN, DNS, LoadBalancing from diagrams.gcp.storage import GCS from diagrams.gcp.compute import GKE from diagrams.onprem.compute import Server from diagrams.oci.network import Internetgateway with Diagram("Gran - GCP Design", show=False): server = Server("Client (Nuxt.js)") with Cluster("Google Cloud Platform"): firestore = Firestore("Firebase Firestore") cdn = CDN("Cloud CDN") dns = DNS("Cloud DNS") lb = LoadBalancing("Cloud Load Balancing") gcs = GCS("Cloud Storage") gke = GKE("Kubernetes Engine") net = Internetgateway("Gateway") dns >> cdn >> gcs dns >> lb >> gke >> firestore server >> net net >> dns
# kubernetes-diagram.py # run the cmd: python3 cyri-lan-archi-diagram.py to generate the png file. from diagrams import Cluster, Diagram from diagrams.generic.network import Switch, Router from diagrams.generic.storage import Storage from diagrams.k8s.compute import Pod from diagrams.k8s.network import Ingress, Service from diagrams.k8s.storage import PV, PVC, StorageClass from diagrams.elastic.elasticsearch import Elasticsearch, Logstash, Kibana from diagrams.oci.connectivity import DNS from diagrams.onprem.compute import Server, Nomad with Diagram("Kubernetes Diagram", show=False): synology = DNS("reverse DNS") with Cluster("RaspberryPi4 + K3S"): ingress = Ingress("cyri.intra") svc = Service("services") pvc = PVC("pv claim") with Cluster("apps"): logstash = Logstash("logstash-oss") elasticsearch = Elasticsearch("elasticsearch") squid = Server("squid") elk = [elasticsearch - logstash - Kibana("kibana")] with Cluster("local-storage"): pv = [StorageClass("storage class") >> PV("persistent volume")] k8s = ingress >> svc k8s >> squid >> pvc << pv k8s >> logstash >> pvc << pv synology << ingress
files = ["{}{}".format(outdir, f'step_{x}') for x in range(1, 6)] steps = [ "Step 1 - Webapp and Database", "Step 2 - Scaling Messages", "Step 3 - Searching Messages", "Step 4 -Client-side Caching", "Step 5 - Logging and Metrics" ] with Diagram(show=False) as d: # Step 1 with d, Diagram(show=True, filename=files[0]): with Cluster("Web"): web_clients = [React("Client 1"), React("Client 2")] with Cluster("API and Database"): with Cluster("Heroku"): hasura = Server("GraphQL") with Cluster("Aiven"): pg = PostgreSQL("DB") web_clients << Edge(color="green") >> hasura >> Edge( color="green") << pg # Step 2 with Diagram(show=True, filename=files[1]): with Cluster("Web"): web_clients = [React("Client 1"), React("Client 2")] with Cluster("API and Database"): with Cluster("Heroku"): hasura = Server("GraphQL") with Cluster("Aiven"): pg = PostgreSQL("DB") web_clients << Edge(color="green") >> hasura >> Edge(
from diagrams.gcp.analytics import PubSub from diagrams.gcp.compute import Functions from diagrams.gcp.storage import Storage from diagrams.onprem.compute import Server from diagrams.onprem.client import Client graph_attr = {"bgcolor": "transparent", "pad": "0"} with Diagram("Posting third-party license data", graph_attr=graph_attr, show=False, filename="images/renewal_licenses_posting"): webshop_1 = Client("Webshop") server_1_1 = Server("Abode API") with Cluster("Operational Data Hub Platform"): with Cluster("Operational Data Hub"): with Cluster("Pub/Sub Topic"): pubsub_1_1 = PubSub("Subscription") with Cluster("Ingest Project"): function_1_1 = Functions("Restingest") function_1_2 = Functions("Produce delta event") storage_1_1 = Storage("GCS Bucket") function_1_1 >> storage_1_1 storage_1_1 - Edge(label="Bucket Trigger", style="dashed") - function_1_2 >> Edge( label="Publish") >> pubsub_1_1
#!/usr/bin/python3 from diagrams import Cluster, Diagram, Edge from diagrams.onprem.compute import Server # < diagrama > with Diagram("Infra as <Code> - Diagrama", filename="diagrama_infra_as_code_diagrama", outformat="jpg"): Server("web")
direction="TB"): with Cluster("Group#1") as pe: with Cluster("Configuration Cluster") as configServer: configServerP = ECS("Primary") configServerB = ECS("Backup") configServerP - configServerB with Cluster("VM#1"): s1 = ECS("MicroService #A") s2 = ECS("MicroService #B") ELB("elb") >> s1 with Cluster("VM#2"): s3 = [Server("S3 - A...Z")] # 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")
from diagrams.onprem.compute import Server from diagrams.aws.general import GenericSamlToken from diagrams.k8s.controlplane import CM from diagrams import Diagram, Edge, Cluster from diagrams.onprem.network import Envoy from diagrams.onprem.container import Containerd from diagrams.k8s.compute import Pod graph_attr = {"fontsize": "15", "pad": "0.5", "bgcolor": "transparent"} with Diagram( show=False, filename="../../img/sidecar_full", graph_attr=graph_attr, ): integration = Server("Target") idp = Vault("IdP") with Cluster("Kubernetes-based Internal Platform"): controller = CM("Custom\nController") with Cluster("Pod boundary"): Pod("Istio-enabled") envoy = Envoy("Envoy") sidecar = Containerd("Sidecar") primary = Containerd("Primary") token = GenericSamlToken("") sidecar >> Edge( label="1. refresh token (out-of-band)") >> envoy >> idp sidecar - Edge( label="2. provide token", style="dashed") - token - Edge(style="dashed") - primary
with Cluster("CA bundle, http://bit.ly/marcredhatcerts"): ca_bundle = ECS("CA bundle") with Cluster("Storage, http://bit.ly/marcredhatstorage"): storage = RDS("Container registry") storage - [RDS("Apps")] with Cluster("Developers and Admins"): devs_and_admins = User("Developers") devs_and_admins - [User("Admins")] with Cluster("Users"): users = [User("Users")] with Cluster("Operations VLAN"): operations_VLAN = [Server("GitlabCI"), Server("Jenkins"), Server("Bamboo"), Server("LDAP"), Server("NTP"), Server("SMTP")] devs_and_admins >> operations_VLAN >> internallb >> master_group internallb >> infra_group >> storage users >> dns >> lb >> worker_group >> storage worker_group >> ca_bundle
from diagrams import Diagram, Cluster, Edge from diagrams.aws.compute import AutoScaling from diagrams.aws.network import VPC from diagrams.onprem.iac import Ansible from diagrams.programming.language import Bash from diagrams.onprem.compute import Server with Diagram("AWS Launch Template", show=False, direction="TB"): with Cluster("vpc"): launch_template = AutoScaling("launch template") VPC("security group(s)") >> launch_template [Bash("bash"), Ansible("ansible"), Server("cloud-init")] >> Edge(label="userdata") >> launch_template
from diagrams.gcp.analytics import PubSub from diagrams.gcp.compute import AppEngine, Functions from diagrams.gcp.database import Firestore from diagrams.gcp.devtools import Scheduler from diagrams.gcp.storage import Storage from diagrams.onprem.compute import Server from diagrams.onprem.client import Client graph_attr = {"bgcolor": "transparent", "pad": "0"} with Diagram("Customer support mailbox", graph_attr=graph_attr, show=False, filename="images/mailbox"): server_1 = Server("Mail server") webshop_1 = Client("Webshop") with Cluster("Operational Data Hub Platform"): with Cluster("Operational Data Hub"): with Cluster("Pub/Sub Topic"): pubsub_1 = PubSub("Subscription") with Cluster("Ingest Project"): schedule_1 = Scheduler("Cloud Scheduler") function_1 = Functions("EWS Mail Ingest") storage_1 = Storage("GCS Bucket") with Cluster("Consume Project"): function_2 = Functions("Consume") firestore_1 = Firestore("Database")