示例#1
0
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
示例#2
0
    with Cluster("Data load"):
        storage = S3("Data storage")
        download = ECS("ECS download task")
        unzip_trigger = Lambda("S3 event trigger")
        unzip = ECS("ECS unzip task")
    with Cluster("Data processing"):
        parse = Glue("Glue Spark XML\nparser")
        catalog = GlueDataCatalog("Data Catalog")
        with Cluster("Feature engineering"):
            train_features = Glue("Glue Spark job:\ntrain features")
            predict_features = Glue("Glue Spark job:\nprediction features")
        prediction_db = Dynamodb("Prediction database")
    with Cluster("ML model"):
        cluster = EMRCluster("EMR Cluster")
        model_fit = Spark("Spark + MLeap")
        model = Sagemaker("Sagemaker endpoint")
    with Cluster("Serving"):
        app = Internet("Web app")
        api = APIGateway("REST API")
        predict_trigger = Lambda("Request/response\nhandler")
    user = User("End user")

    source >> download >> storage >> unzip_trigger >> unzip >> storage
    storage >> parse >> catalog
    catalog >> [train_features, predict_features]
    predict_features >> prediction_db >> predict_trigger
    train_features >> cluster >> model_fit >> model
    predict_trigger >> model >> predict_trigger
    storage >> app
    user >> Edge() << app >> api >> predict_trigger >> api >> app
示例#3
0
                alb_leg_b = ELB("elb-interface-2")
            with Cluster("Availability Zone C"):
                alb_leg_c = ELB("elb-interface-3")

        vpc_router = VPCRouter("Internal router")

        with Cluster("Private Subnet"):
            with Cluster("Availability Zone A"):
                eks1 = EKS("Kubernetes node 1")
            with Cluster("Availability Zone B"):
                eks2 = EKS("Kubernetes node 2")
            with Cluster("Availability Zone C"):
                eks3 = EKS("Kubernetes node 3")

    # Drawing step.
    Internet("Internet") >> igw

    igw >> alb_leg_a
    igw >> alb_leg_b
    igw >> alb_leg_c

    alb_leg_a >> vpc_router
    alb_leg_b >> vpc_router
    alb_leg_c >> vpc_router

    vpc_router >> eks1
    vpc_router >> eks2
    vpc_router >> eks3

with Diagram("Within K8s overview",
             show=True,
示例#4
0
from diagrams import Cluster, Diagram
from diagrams.generic.compute import Rack
from diagrams.onprem.compute import Server
from diagrams.onprem.network import Internet
from diagrams.generic.network import Router, Switch
from diagrams.generic.storage import Storage

with Diagram("baremetal", show=False):
    nbn = Internet("NBN")
    with Cluster("Routers"):
        routers = [Router("Main"), Router("Extender"), Router("Cluster")]
        routers[0] << routers[1] << routers[2]

    with Cluster("Switches"):
        switches = [Switch("Fully managed switch"), Switch("Unmanaged switch")]

    with Cluster("Dell Poweredge Servers"):
        nodes = [
            Rack("r710:MaaS"),
            Server("r810:ESXI"),
            Server("r710:KVM"),
            Server("r710:UNUSED")
        ]
    nas = Storage("NAS")

    routers[2] << switches[0]
    switches[0] << nas
    switches[0] << nodes
    switches[1] << nodes

    nbn << routers[0]
示例#5
0
from diagrams import Cluster, Diagram, Edge
from diagrams.aws.compute import EC2
from diagrams.aws.management import Cloudwatch
from diagrams.aws.network import InternetGateway, RouteTable, VPCRouter
from diagrams.aws.security import KMS, IAMRole
from diagrams.generic.network import Firewall
from diagrams.onprem.network import Internet

graph_attr = {
    "pad": "0",
    "bgcolor": "transparent"
}

with Diagram("template-08", show=False, direction="LR", filename="diagram-08", graph_attr=graph_attr):
    internet = Internet("Public Internet")
    with Cluster("Vpc 10.0.0.0/16"):
        internet_gateway = InternetGateway("Igw")
        internet - internet_gateway
        routeTable = RouteTable("RouteTable")
        routeTable >> Edge(label="0.0.0.0/0", style="dashed") >> internet_gateway
        with Cluster("Subnet 10.0.0.0/24"):
            router = VPCRouter("Router\n10.0.0.1")
            router - Edge(style="dashed") - routeTable
            router - internet_gateway
            ec2 = EC2("ec2\n10.0.0.x")
            ec2 - Edge(style="dashed") - router
            sg = Firewall("SG: 22/tcp")
            ec2 - sg - router
    KMS("KeyPair") - ec2
    ec2Role = IAMRole("Ec2InstanceRole") - ec2
示例#6
0
from diagrams.k8s.infra import Master
from diagrams.k8s.storage import Volume
from diagrams.k8s.podconfig import ConfigMap
from diagrams.k8s.podconfig import Secret
from diagrams.k8s.compute import Pod
from diagrams.k8s.network import Ingress
from diagrams.onprem.network import Internet
from diagrams.k8s.compute import Deployment
from diagrams.k8s.compute import StatefulSet
from diagrams.k8s.infra import Node
from diagrams.k8s.compute import ReplicaSet
from diagrams.k8s.network import Service

with Diagram("kubernetes getting started", show=False):
    node = Node("Node")
    inet = Internet("Kubernetes")
    vol = Volume("Volumes")
    cm = ConfigMap("ConfigMap")
    secret = ConfigMap("Secret")
    pod = ConfigMap("Pod")
    ingress = Ingress("Ingress")
    depl = Deployment("Deployment")
    ss = StatefulSet("StatefulSet")
    service = Service("Service")
    rs = ReplicaSet("Replication")
    node << inet
    pod << inet
    service << inet
    ingress << inet
    rs << inet
示例#7
0
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
示例#8
0
from diagrams.onprem.compute import Server
from diagrams.onprem.database import PostgreSQL
from diagrams.onprem.network import Internet
from diagrams.programming.framework import Spring, React
from diagrams.programming.language import Java

graph_attr = {
    "fontsize": "20",
    "bgcolor": "white"  # transparent
}

with Diagram("",
             direction="LR",
             graph_attr=graph_attr,
             outformat="png",
             filename="advanced-setup"):

    database = PostgreSQL("Database")
    collaborator = Java("UserRepository")

    with Cluster("Class Under Test  (CUT) "):
        cut = Java("RegistrationService")

    second_collaborator = Java("BannedUsersClient")
    api = Internet("Remote System")

    database << collaborator
    collaborator << cut
    second_collaborator << cut
    api << second_collaborator
示例#9
0
from diagrams import Cluster, Diagram
from diagrams.onprem.compute import Server
from diagrams.onprem.network import Internet

with Diagram("k3s testlab 01", show=False):
    vpn = Internet("lan")
    with Cluster("k3s master-master-master cluster"):
        virtualbox = [Server("k3s-01"), Server("k3s-02"), Server("k3s-03")]
    virtualbox >> vpn
示例#10
0
文件: diagram.py 项目: okeysea/logorg
from diagrams import Diagram, Cluster, Edge
from diagrams.aws.compute import ECS
from diagrams.aws.database import RDS
from diagrams.aws.network import Route53, ELB, InternetGateway
from diagrams.onprem.network import Internet
from diagrams.onprem.client import Users
from diagrams.aws.network import CloudFront
from diagrams.aws.storage import S3
from diagrams.aws.security import ACM

with Diagram("LogOrg", show=False):
    with Cluster("Internet"):
        internet = Internet("internet")
        users    = Users("User")

        with Cluster("AWS"):

            dns  = Route53("DNS")
            acm  = ACM("Certificate Manager")

            with Cluster("CDN/cdn.logorg.work"):

                cdn_front = CloudFront("CDN Front")
                cdn_storage = S3("Logorg Bucket")

            with Cluster("APP/VPC 10.0.0.0/www.logorg.work"):

                elb  = ELB("LB")
                igw  = InternetGateway("Internet Gateway")

                with Cluster("subnet-private"):
示例#11
0
文件: infra.py 项目: ViBiOh/mailer
#!/usr/bin/env python

from diagrams import Diagram, Cluster
from diagrams.k8s.compute import Deployment
from diagrams.onprem.compute import Server
from diagrams.onprem.network import Internet
from diagrams.onprem.queue import RabbitMQ

with Diagram("mailer", show=False, direction="TB"):
    with Cluster("github.com/ViBiOh"):
        mailer = Deployment("mailer")
        mjml = Deployment("mjml-api")

    [Internet("HTTP"), RabbitMQ("AMQP")] >> mailer >> [
        mjml,
        Server("SMTP"),
    ]
示例#12
0
from diagrams import Cluster, Diagram
from diagrams.onprem.compute import Server
from diagrams.onprem.network import Internet

with Diagram("k3s testlab 02", show=False):
    lan = Internet("lan")
    wan = Internet("wan")

    with Cluster("k3s master-master-master cluster"):
        cluster = [
            Server("k3s-node-01"),
            Server("k3s-node-02"),
            Server("k3s-node-03")
        ]
    wan << cluster
    cluster >> lan
    wan
示例#13
0
from diagrams.onprem.network import Internet, Nginx
from diagrams.saas.chat import Slack
from diagrams.onprem.client import User

graph_attr = {"fontsize": "18", "pad": "0"}

with Diagram(
        "SSL Checker Dashboard Diagram",
        filename="ssl-checker-diagram",
        show=False,
        graph_attr=graph_attr,
):
    user = User("User")
    ingress = Nginx("ingress")

    with Cluster("Dashboard Replicas"):
        dashboards = [
            Docker("dashboard"),
            Docker("dashboard"),
            Docker("dashboard"),
        ]

    checker = Docker("checker")

    notifier = Docker("notifier")

    user >> ingress >> dashboards >> Redis("redis") << [checker, notifier]

    checker >> Internet("hosts with SSL")
    notifier >> Slack("Slack")
    "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")
示例#15
0
#!/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
        firewall = WAF("AWS WAF")
        identity = IAM("AWS IAM")

        with Cluster("CDN"):
            cdn = S3("S3") >> CF("CloudFront CDN")

        with Cluster("Functions") as xyz:
            func_send_mail = Lambda("Send Email")
            func_store_data = Lambda("Store Data")
            functions = [func_send_mail, func_store_data]
            gateway >> Edge() << functions

        functions >> Edge() << identity

        func_send_mail >> Edge() >> email_service >> users
        func_store_data - Edge() - db
        cdn >> Edge() << route

        # Monitoring
        log_connection = Edge(color="darkpink", style="dotted")
        monitoring >> log_connection << gateway
        monitoring >> log_connection << [func_send_mail, func_store_data]
        monitoring >> log_connection << firewall

        firewall >> Edge() << cdn >> Edge() << gateway
        security >> Edge() << gateway

    Client() - \
        Internet("www.yoursite.com") >> \
        Edge(color="darkgreen", style="dotted") << \
        route >> Edge() << gateway
示例#17
0
from diagrams.aws.storage import S3
from diagrams.aws.management import Cloudformation
from diagrams.onprem.vcs import Github
from diagrams.onprem.network import Internet

with Diagram("NateGramer.com - S3 Backed Public Website", show=False):
    with Cluster("Feature Branch Stack"):
        featureDns = Route53("<branch>.NateGramer.com")
        featureCloudfront = CF("CloudFront Distribution")
        featureBucket = S3("Site Storage")
        featureStack = [featureDns, featureCloudfront, featureBucket]
        featureDns >> featureCloudfront >> featureBucket

    Github("Pull in any feature branch") >> Cloudformation(
        "Branch Stack") >> featureStack
    Internet() >> featureDns

    with Cluster("Dev Branch Stack"):
        devDns = Route53("dev.NateGramer.com")
        devCloudfront = CF("CloudFront Distribution")
        devBucket = S3("Site Storage")
        devStack = [devDns, devCloudfront, devBucket]
        devDns >> devCloudfront >> devBucket

    Github("Push in Dev Branch") >> Cloudformation("Branch Stack") >> devStack
    Internet() >> devDns

    with Cluster("Master Branch Stack"):
        dns = Route53("NateGramer.com")
        cloudfront = CF("CloudFront Distribution")
        bucket = S3("Site Storage")
示例#18
0
from diagrams.onprem.network import Internet
from diagrams.onprem.network import Internet
from diagrams.k8s.compute import Deploy
from diagrams.k8s.network import Ingress
from diagrams.k8s.podconfig import Secret
from diagrams.k8s.podconfig import ConfigMap
with Diagram("kubernetes deployment nodejs postgresql ingress", show=False):
    with Cluster("Kubernetes Components"):
        with Cluster("Services"):
            service_internal_node = Service("Internal Node Service")
            service_internal_postgres = Service("Internal Postgres Service")
        with Cluster("Ingress"):
            ingress = Ingress("Ingress")
        with Cluster("Pods"):
            postgresql = Pod("Postgresql")
            nodejs = Pod("Nodejs")

        with Cluster("configuration"):
            deployment = Deploy("Deployment")
            configmap = ConfigMap("ConfigMap")
            secret = Secret("Secret")
        deployment >> secret
        deployment >> configmap
        deployment >> Edge(label="defines") >> service_internal_node
        deployment >> Edge(label="defines") >> service_internal_postgres
        nodejs >> service_internal_postgres >> postgresql
    inet = Internet("Internet")
    inet >> ingress >> service_internal_node >> nodejs


示例#19
0
from diagrams.onprem.database import PostgreSQL
from diagrams.onprem.network import Internet
from diagrams.programming.framework import Spring, React

graph_attr = {
    "fontsize": "20",
    "bgcolor": "white"  # transparent
}

with Diagram("",
             direction="LR",
             graph_attr=graph_attr,
             outformat="png",
             filename="book-reviewr-application-architecture"):
    with Cluster("Book Reviewr"):
        frontend = React("Frontend")
        backend = Spring("Backend")

    queue = SQS("SQS (Messaging Queue)")
    users = Users("Users")
    database = PostgreSQL("PostgreSQL (Database)")
    keycloak = Server("Keycloak (Identity Provider)")
    api = Internet("Open Library (REST API)")

    keycloak << [frontend, backend]

    users >> frontend
    frontend >> backend >> database
    backend >> api
    backend << queue
示例#20
0
with Diagram("Cluster Integration",
             show=False,
             direction="TB",
             outformat="png",
             filename="/output/grouped_workers"):

    with Cluster("Other AWS Resources"):
        primary_load_balancer = ELB("Load Balancer")
        events_database = RDS("Events Databse")

    with Cluster("Primary ECS Cluster"):
        primary_cluster = create_ecs_cluster(start=0, end=7)

    with Cluster("Backup Clusters"):
        with Cluster("First Backup ECS Cluster"):
            backup_cluster1 = create_ecs_cluster(start=10, end=12)

        with Cluster("Second Backup ECS Cluster"):
            backup_cluster2 = create_ecs_cluster(start=20, end=21)

    primary_cluster >> events_database
    backup_cluster1 >> events_database
    backup_cluster2 >> events_database
    primary_load_balancer >> primary_cluster
    primary_load_balancer >> Edge(style="dashed",
                                  label="Cut over in an emergency") >> [
                                      backup_cluster1, backup_cluster2
                                  ]

    Internet() >> primary_load_balancer
示例#21
0
                tableau = Tableau("Tableau Server\n(EC2)")

        with Cluster("S3 Data Lake"):
            s3data = storage.S3("Data Bucket")
            s3meta = storage.S3("Metadata Bucket")
            s3logs = storage.S3("Logging Bucket")
            sftp = TransferForSftp("SFTP\nTransfer Service")
            py_fn1 = compute.Lambda("File Listener\n(Lambda Python)")
            glue = Glue("Spark Transforms\n(Glue)")

        # with Cluster("AWS Serverless"):
        events = Eventbridge("Event Triggers\n(AWS Eventbridge)")
        secrets = security.SecretsManager("AWS Secrets\nManager")
        cw = Cloudwatch("Cloudwatch Logs")

    source = Internet("External\nData Source")

    py_fn1 << s3data << py_fn1
    glue << s3data << glue

    nat << singer1
    nat >> source
    elb >> tableau
    s3meta >> singer1 >> s3data
    singer1 << secrets
    singer1 << events
    rs1 << singer1
    users >> elb
    source >> singer1
    rs1 >> tableau
    s3data << sftp