Beispiel #1
0
def general(c):
    with Diagram('Context', filename='general', show=False, graph_attr={'pad': '0.0'}):
        _ = NS('astrid-kube')
        _cb_pod = Pod('CB')
        _cb_deploy = Deployment('CB')

        with Cluster('Services'):
            _srvs = [Service('elasticsearch-service'),
                     Service('kafka-service'), Service('cb-manager-service'), Service('kibana')]

        with Cluster('Storage'):
            _strg = PVC('elasticsearch-pv-volume') >> PV('elasticsearch-pv')

        _srvs >> _cb_pod << _cb_deploy << _strg
Beispiel #2
0
def basic_vault_agent_architecture():
    with Diagram(name="Vault Agent Architecture", show=False, direction="LR"):

        with Cluster("Control Plane"):
            apiserver = APIServer()

        with Cluster("Vault"):
            svc = Service(":8200")
            certs_secret = Secret("Certs Secret")
            vault_configmap = ConfigMap("Vault Config")
            vault = Vault("Vault")
            file_backend = PV("Encrypted Store")

            vault >> file_backend
            vault >> Edge() << svc
            vault << certs_secret
            vault << vault_configmap

        with Cluster("Secure Pod"):
            vault_agent = Custom("Vault Agent", crio_icon)
            vault_init_agent = Custom("Init Vault Agent", crio_icon)

            manual = [vault_init_agent, vault_agent]

            app_container = Custom("App", crio_icon)
            inMemory = Vol("In Memory")

            manual >> inMemory
            app_container << inMemory

            manual << svc << manual >> Edge() << app_container

        apiserver >> Edge() << vault
Beispiel #3
0
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
Beispiel #4
0
def general(c):
    with Diagram('general', show=False):
        _ = NS('astrid-kube')
        _cb_pod = Pod('CB')
        _cb_deploy = Deployment('CB')

        with Cluster('Services'):
            _srvs = [
                Service('elasticsearch-service'),
                Service('kafka-service'),
                Service('cb-manager-service')
            ]

        with Cluster('Storage'):
            _strg = PVC('elasticsearch-pv-volume') >> PV('elasticsearch-pv')

        _srvs >> _cb_pod << _cb_deploy << _strg
Beispiel #5
0
def k8s(name):
    with Cluster(name):
        with Cluster('ns: onepanel'):
            svc_core = Service('core')
            pd_core = Pod('core-*')
            dep_core = Deployment('core')
            dep_core >> pd_core
            svc_core >> pd_core

            svc_core_ui = Service('core-ui')
            pd_core_ui = Pod('core-ui-*')
            dep_core_ui = Deployment('core-ui')
            dep_core_ui >> pd_core_ui
            svc_core_ui >> pd_core_ui

        with Cluster('ns: istio-system'):
            ing = Ingress('istio-ingressgateway')
            # cert = Secret('TLS')

        with Cluster('ns: my-project'):
            with Cluster('Workspace'):
                svc_workspace = Service('jupyterlab')
                pd_workspace = Pod('jupyterlab-*')
                pv_workspace = PV('jupyterlab-data-0')
                sts_workspace = StatefulSet('jupyterlab')
                sts_workspace >> pd_workspace
                pd_workspace - pv_workspace
                svc_workspace >> pd_workspace

        # with Cluster('ns: cert-manager'):
        #     certmanager = Pod('cert-manager')

        # certmanager >> cert
        ing >> [svc_core, svc_core_ui, svc_workspace]

        node_1 = Node('node-1')
        node_2 = Node('node-2')
        node_3 = Node('node-2')
        pd_core - node_1
        pd_core - node_2
        pd_core_ui - node_1
        pd_core_ui - node_2
        pd_workspace - node_3

    return node_1, node_2, node_3, ing, pd_core, pv_workspace
Beispiel #6
0
from diagrams import Diagram, Cluster
from diagrams.k8s.rbac import ClusterRole, ClusterRoleBinding, Group, RoleBinding, Role, ServiceAccount, User
from diagrams.k8s.infra import ETCD, Master, Node
from diagrams.k8s.podconfig import ConfigMap, Secret
from diagrams.k8s.group import Namespace
from diagrams.k8s.network import Endpoint, Ingress, NetworkPolicy, Service
from diagrams.k8s.others import CRD, PSP
from diagrams.k8s.storage import PersistnetVolume, PersistentVolumeClaim, StorageClass, Volume
from diagrams.k8s.clusterconfig import HorizontalPodAutoscaler, LimitRange, Quota
from diagrams.k8s.controlplane import APIServer, CCM, ControllerManager, KubeProxy, Kubelet, Scheduler
from diagrams.k8s.compute import Cronjob, Deployment, DaemonSet, Job, Pod, ReplicaSet, StatefulSet

with Diagram("test-diagram", show=False):
    ingress = Ingress("in-as-mob")

    with Cluster("as-mob.ambevdevs.com.br"):
        with Cluster("/nonprod/asmob-empregado(/|$)(.*)"):
            ingress >> Service("autenticacao") >> Pod("teste")
        with Cluster("/nonprod/asmob-a(/|$)(.*)"):
            ingress >> Service("autenticacao") >> Pod("teste")
Beispiel #7
0
from diagrams import Diagram
from diagrams.k8s.compute import Deployment, Pod, ReplicaSet
from diagrams.k8s.network import Service

graph_attr = {
    "fontsize": "30",
    "bgcolor": "transparent",
    "pad": "0.8",
    "fixedsize": "shape",
    "fontname": "Roboto",
    "width": "10.0",
    "dpi": "80"
}

with Diagram("single member hazelcast cluster",
             show=False,
             outformat="png",
             graph_attr=graph_attr):
    Service() >> Pod() << ReplicaSet() << Deployment()

with Diagram("multiple member hazelcast cluster",
             show=False,
             outformat="png",
             graph_attr=graph_attr):
    Service() >> [Pod(), Pod(), Pod()] << ReplicaSet() << Deployment()
Beispiel #8
0
        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")

    with Cluster("Namespace A"):
        #POD1 = Pod("frontend")
        PODF = [Pod("frontend"), Pod("frontend"), Pod("frontend")]
        PODB = [Pod("backend"), Pod("backend"), Pod("backend")]
        haproxy_ingressA >> Edge(color="brown") >> Service(
            "frontend") >> PODF >> Service("backend") >> PODB >> SQL(
                "Replica1") >> haproxy_egressA >> serverExtA

    with Cluster("Namespace Metrics"):
        metrics = Prometheus("metric")
        PODF >> metrics << Edge(color="firebrick",
                                style="dashed") << Grafana("monitoring")
    with Cluster("Namespace Logging"):
        PODF >> Fluentd("forwarder") >> Splunk("CentralLogging")

    #with Cluster("Namespace B"):
    #    masterB = Pod("POD 3")
    #    masterB - Pod("POD 4")  >> haproxy_egressB >>  SQL("Replica1") >> serverExtB
    #    haproxy_ingressB >> Edge(color="black") >> masterB

    #aggregator = Fluentd("logging")
Beispiel #9
0
from diagrams import Diagram
from diagrams.k8s.compute import DaemonSet, Deployment, Pod, ReplicaSet
from diagrams.k8s.network import Ingress, Service
from diagrams.k8s.podconfig import ConfigMap
from diagrams.k8s.group import Namespace

with Diagram("JupyterHub Kubernetes Architecture", show=False):
    nublado_ns = Namespace("nublado")
    pp_net = Ingress("/pp")
    nb_net = Ingress("/nb")

    pp_svc = Service("Prepuller")
    pp_deploy = Deployment("Prepuller")
    pp_pod = Pod("Prepuller")
    pp_ds = DaemonSet("Single image puller")

    hub_config = ConfigMap("Hub Config YAML")

    hub_svc = Service("JupyterHub")
    hub_deploy = Deployment("JupyterHub")
    hub_pod = Pod("JupyterHub")

    proxy_svc = Service("JupyterHubProxy")
    proxy_deploy = Deployment("JupyterHubProxy")
    proxy_pod = Pod("JupyterHubProxy")

    user_ns = Namespace("nublado-lsptestuser01")
    user_lab_pod = Pod("JupyterLab pod")
    user_config = ConfigMap("Lab Config YAML + Token")

    nublado_ns >> nb_net >> proxy_svc >> proxy_deploy >> proxy_pod >> hub_svc
                pod = Pod("chartmuseum")
                secret = Secret("chartmuseum")
                token = Secret("default-token")
                sa = ServiceAccount("default")    

                pod - Edge(color="gray", style="dashed")  - secret  - Edge(color="gray", style="dashed")  - token  - Edge(color="gray", style="dashed")  - sa
                svc_chartmuseum >> pod

            with Cluster("Docker"):
                svc_docker_registry = custom.Custom("Docker Registry","assets/img/logos/logo_docker.png")

        with Cluster("Prow",graph_attr={"fontsize": "47"}):
           # logo_node = custom.Custom("","assets/img/logos/logo_prow.png")
            with Cluster("Tide"):
                svc_tide = Service("tide")

                pod_tide = Pod("tide")
                secret_tide = Secret("tide")
                token_tide = Secret("default-token")
                sa_tide = ServiceAccount("default")
                oauth_volume_tide = PV("oauth")
                config_volume_tide = PV("config")

                pod_tide - Edge(color="gray", style="dashed") - secret_tide - Edge(color="gray", style="dashed")  - token_tide - Edge(color="gray", style="dashed")  - sa_tide
                pod_tide - Edge(color="gray", style="dashed") - oauth_volume_tide - Edge(color="gray", style="dashed") - config_volume_tide

                svc_tide >> pod_tide
                
            with Cluster("Crier"):
                svc_crier = Service("crier")
Beispiel #11
0
                token = Secret("default-token")
                sa = ServiceAccount("default")

                pod - Edge(color="gray", style="dashed") - secret - Edge(
                    color="gray", style="dashed") - token - Edge(
                        color="gray", style="dashed") - sa
                svc_chartmuseum >> pod

            with Cluster("Docker"):
                svc_docker_registry = custom.Custom(
                    "Docker Registry", "assets/img/logos/logo_docker.png")

        with Cluster("Lighthouse", graph_attr={"fontsize": "47"}):
            # logo_node = custom.Custom("","assets/img/logos/logo_prow.png")
            with Cluster("foghorn"):
                svc_foghorn_hook = Service("hook")
                pod_foghorn = Pod("foghorn")
                secret_foghorn = Secret("foghorn")
                token_foghorn = Secret("hmac-token")
                token_oauth_foghorn = Secret("oauth-token")
                sa_foghorn = ServiceAccount("lighthouse")

                pod_foghorn - Edge(
                    color="gray", style="dashed") - secret_foghorn - Edge(
                        color="gray", style="dashed") - token_foghorn - Edge(
                            color="gray", style="dashed") - sa_foghorn
                svc_foghorn_hook >> pod_foghorn

            with Cluster("Keeper"):
                svc_keeper = Service("keeper")
from diagrams import Diagram
from diagrams.k8s.clusterconfig import HPA
from diagrams.k8s.compute import Deployment, Pod, ReplicaSet
from diagrams.k8s.network import Ingress, Service

with Diagram("Exposed Pod with 3 Replicas", show=False):
    net = Ingress("domain.com") >> Service("svc")
    net >> [Pod("pod1"), Pod("pod2"), Pod("pod3")
            ] << ReplicaSet("rs") << Deployment("dp") << HPA("hpa")
             outformat='png',
             graph_attr=graph_attr):
    with Cluster("Conference 1"):
        users_1 = [Custom("user", globe_img) for _ in range(3)]
    with Cluster("Conference 2"):
        users_2 = [Custom("user", globe_img) for _ in range(2)]

    all_users = Custom("all users", globe_img)

    with Cluster("Namespace 'jitsi'"):
        n_shards = 2
        n_haproxy = 2
        haproxy_sts = StatefulSet("haproxy")
        haproxy_pods = [Pod(f"haproxy-{j}") for j in range(n_haproxy)]
        haproxy_sts >> haproxy_pods
        web_service = Service("web")
        ingress = Ingress("jitsi.messenger.schule")
        ingress >> Service("haproxy") >> haproxy_pods >> web_service

        for k in range(n_shards):
            with Cluster(f"Shard-{k}"):
                web_pod = Pod(f"shard-{k}-web")
                prosody_pod = Pod(f"shard-{k}-prosody")
                jicofo_pod = Pod(f"shard-{k}-jicofo")
                Deployment(f"shard-{k}-prosody") >> prosody_pod
                Deployment(f"shard-{k}-jicofo") >> jicofo_pod
                web_service >> web_pod
                prosody_service = Service(f"shard-{k}-prosody")
                prosody_service >> prosody_pod
                prosody_service << web_pod
                prosody_service << jicofo_pod
Beispiel #14
0
from diagrams import Diagram, Cluster
from diagrams.gcp.database import Firestore
from diagrams.onprem.network import Envoy
from diagrams.onprem.compute import Server
from diagrams.oci.network import Internetgateway
from diagrams.k8s.compute import Pod
from diagrams.k8s.network import Ingress, Service

with Diagram("Gran - API System - Design", show=False):
    igw = Internetgateway("Gateway")

    with Cluster("Google Cloud Platform"):
        with Cluster("Google Kubernetes Engine"):
            net = Ingress("calmato.work")
            pods = [
                Pod("user service"),
                Pod("group service"),
                Pod("todo service")
            ]

            net >> Service("svc") >> Envoy("lb") >> pods

        with Cluster("Firebase"):
            auth = Server("firebase authentication")
            firestore = Firestore("firestore")

            pods >> auth
            pods >> firestore

    igw >> net
Beispiel #15
0
from diagrams import Diagram
from diagrams.k8s.clusterconfig import HPA
from diagrams.k8s.compute import Deployment, Pod, ReplicaSet
from diagrams.k8s.network import Ingress, Service

with Diagram("Research", show=False, filename="research"):
    net = Ingress("research.cashcowpro.com") >> Service("svc")
    pods = [
        Pod("api-1"),
        Pod("api-2"),
        Pod("api-3"),
        Pod("worker-1"),
        Pod("worker-2"),
        Pod("worker-3")
    ]
    net >> pods << ReplicaSet("rs") << Deployment("dp") << HPA("hpa")
Beispiel #16
0
        master = Master("Kubernetes Master\nRunning on GKE")
        k8api = API("Kubernetes Control API")
        s = []
        w = []
        ing = Traefik("Router & Proxy")
        ing >> app
        app >> pg
        app >> k8api
        k8api >> master
        pg >> app
        prom = Prometheus("Prometheus\nMonitoring")
        graf = Grafana("Grafana\nVisualization")
        ing >> graf
        graf >> prom
        for i in range(0, 5):
            with Cluster(f"Workshop {i+1}"):
                s.append(Service(f"Service"))
                w.append(Pod(f"Rstudio"))
                s[i] >> w[i]
                ing >> s[i]
                master - Edge(color="firebrick", style="dashed") - s[i]
                master - Edge(color="firebrick", style="dashed") - w[i]
            prom >> w[i]

    lb >> ing
    master - Edge(color="firebrick", style="dashed") - ing
    users >> web
    dns >> web
    web >> dns
    web >> lb
Beispiel #17
0
from diagrams import Diagram, Cluster
from diagrams.k8s.group import Namespace
from diagrams.k8s.compute import Deployment, Pod
from diagrams.k8s.network import Service
from diagrams.onprem.monitoring import Prometheus, Grafana
from diagrams.onprem.network import Istio

with Diagram('Observability') as result:
    with Cluster('Minikube') as minikube:
        with Cluster('default') as app_namespace:
            Service('simpleapp-sevice') << Deployment('simpleapp') << Pod('simpleapp') << Istio('proxy')
        with Cluster('kube-system') as kube_system:
            istio = Istio('config')
            istio >> Pod('Kiali')
            prom = Prometheus()
            prom << Grafana()
            prom >> Pod('Jaegar')

if __name__ == "__main__":
    result
Beispiel #18
0
from diagrams import Cluster, Diagram, Edge
from diagrams.k8s.network import Service
from diagrams.k8s.compute import Pod
from diagrams.onprem.network import Internet
from diagrams.onprem.network import Internet
from diagrams.k8s.compute import Deploy
from diagrams.k8s.podconfig import Secret
from diagrams.k8s.podconfig import ConfigMap
with Diagram("kubernetes deployment nodejs postgresql", show=False):
    with Cluster("Kubernetes Components"):
        with Cluster("Services"):
            service_internal = Service("Internal Service")
            service_external = Service("External Service")
        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
        deployment >> Edge(label="defines") >> service_external
        nodejs >> service_internal >> postgresql
    inet = Internet("Internet")
    inet >> service_external >> nodejs


Beispiel #19
0
            private_subnets = [
                PrivateSubnet("Subnet zone a"),
                PrivateSubnet("Subnet zone b"),
                PrivateSubnet("Subnet zone c"),
                PrivateSubnet("Subnet zone d"),
                ]
            with Cluster("Kubernetes cluster"):
                autoscaling_group = AutoScaling("Autoscaling group")
                autoscaling_group_instances = [
                    EC2("K8s worker zone a"),
                    EC2("K8s worker zone b"),
                    EC2("K8s worker zone c"),
                    EC2("K8s worker zone d"),
                ]
                ingress = Ingress("Ingress gateway")
                services = Service("Services")
                pods = Pod("Container pods")

    ci_pipeline = GitlabCI("CI pipeline")
    terraform_repo = Terraform("Infra as code")
    remote_state = S3("Remote state")

    ssl_certificate - dns_name
    dns_name - load_balancer
    load_balancer - public_subnets
    public_subnets - nat_gateway
    nat_gateway - private_subnets
    private_subnets - autoscaling_group
    autoscaling_group - autoscaling_group_instances
    autoscaling_group_instances - ingress
    ingress - services
Beispiel #20
0
            logging = Fluentd('logging')
            es = ElasticSearch('index')
            kibana = Kibana('Log View')
            logging >> es >> kibana
        with Cluster('Monitoring'):
            metrics = Prometheus('metrics')
            monitoring = Grafana('monitoring')
            tracing = Jaeger('tracing')

        with Cluster("DB") as cluster:
            db_books = PostgreSQL("books")
            db_auth = PostgreSQL("auth")
            # pvc = PVC("pvc")
            # pvc << [db_books, db_auth]
        with Cluster('Lorem Ipsum Apps'):
            books_svc = Service('books')
            apps = []
            for _ in range(2):
                pod = Pod("pod")
                apps.append(books_svc >> pod >> [db_books, metrics, logging])
            auth_svc = Service('auth')
            apps = []
            for _ in range(2):
                pod = Pod("pod")
                apps.append(auth_svc >> pod >> [db_auth, metrics, logging])
            search_engine = Service("Search Engine")

        net >> [books_svc, auth_svc, tracing]
        metrics >> [monitoring, tracing]
        db_books - search_engine
    ui >> net
Beispiel #21
0
from diagrams import Cluster, Diagram
from diagrams.k8s.compute import Pod, StatefulSet
from diagrams.k8s.network import Service
from diagrams.k8s.storage import PV, PVC, StorageClass

with Diagram("Stateful Architecture", show=False):
    with Cluster("Apps"):
        svc = Service("svc")
        sts = StatefulSet("sts")

        apps = []
        for _ in range(3):
            pod = Pod("pod")
            pvc = PVC("pvc")
            pod - sts - pvc
            apps.append(svc >> pod >> pvc)

    apps << PV("pv") << StorageClass("sc")
Beispiel #22
0
# 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
# kubeflow architecture diagram
from diagrams import Cluster, Diagram, Edge
from diagrams.onprem.client import Users
from diagrams.k8s.network import Ingress, Service

with Diagram("Kubeflow Networking Architecture", show=False):
    user = Users("Users")
    with Cluster("API gateway"):
        ingress_gateway = Ingress("Ingress")
        user >> Edge(color="darkgreen") >> ingress_gateway

        ingress_gateway >> [
            Service("Central Dashboard Virtual Service"),
            Service("Notebooks App Virtual Service")
        ]
Beispiel #24
0
from diagrams.k8s.network import Ingress, Service

from diagrams.onprem.database import MongoDB
from diagrams.onprem.database import MySQL
from diagrams.onprem.inmemory import Redis

from diagrams.custom import Custom

with Diagram("Food Platform Architecture", show=False):
    customUser = Custom("User", "./resources/notebook.png")

    orderWebUi = Pod("order web ui")

    ing = Ingress()

    gatewaySvc = Service("food gateway svc")
    gateway    = Pod("food gateway")

    orderDB  = MySQL("order")
    orderSvc = Service("order svc")
    orderApp = Pod("order app")
    orderApp >> orderDB
    orderSvc >> orderApp

    restaurantDB  = MySQL("restaurant")
    restaurantSvc = Service("restaurant svc")
    restaurantApp = Pod("restaurant app")
    restaurantApp >> restaurantDB
    restaurantSvc >> restaurantApp

    reviewDB  = MongoDB("review")
Beispiel #25
0
from diagrams import Cluster, Diagram, Edge
from diagrams.k8s.network import Service
from diagrams.k8s.compute import Pod
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
        app_fw = FirewallRules("Firewall")

        with Cluster("GKE"):

            with Cluster("App Namespace"):
                # Resources
                app_dep = Deployment("App Deployment")
                app_rs = ReplicaSet("App ReplicaSet")
                app_replica_set_count = 3
                app_pods = [
                    Pod("App Pod")
                    for pod in range(0, app_replica_set_count, 1)
                ]
                app_secret = Secret(
                    "App Secret\n(contains DB credentials & host)")
                app_svc_ext = Service("App Service (external)")
                app_svc_int = Service("App Service (internal)")

                # Relationships
                app_dep >> app_rs >> app_pods << app_svc_ext << app_ingress_ext << app_lb_ext << app_fw
                # app_pods << app_svc_int << app_lb_int << app_fw
                app_secret << app_dep

            with Cluster("DB Namespace"):
                # Pgpool
                # Resources
                pgpool_dep = Deployment("Pgpool Deployment")
                pgpool_rs = ReplicaSet("Pgpool ReplicaSet")
                pgpool_replica_set_count = 1
                pgpool_pods = [
                    Pod("Pgpool Pod")
Beispiel #27
0
def main():

    parser = argparse.ArgumentParser(description='Create Kubernetes diagrams')
    parser.add_argument('-n',
                        required=True,
                        type=str,
                        action='store',
                        dest='namespace',
                        help='Kubernetes namespace to get objects from')
    args = parser.parse_args()

    command = "kubectl -n " + args.namespace + " get ingress -o json"
    commandOutput = subprocess.run(command.split(), stdout=subprocess.PIPE)
    commandJson = commandOutput.stdout.decode('utf-8')
    ingressList = json.loads(commandJson)

    if len(ingressList["items"]) == 0:
        print("No ingress found. Aboring.")
        sys.exit()

    diagramMap = {}
    diagramMap["ingress"] = []
    for ingress in ingressList["items"]:
        ingressMap = {}
        ingressMap["name"] = ingress["metadata"]["name"]
        ingressMap["items"] = []
        for rule in ingress["spec"]["rules"]:
            hostMap = {}
            hostMap["name"] = rule["host"]
            hostMap["items"] = []
            for path in rule["http"]["paths"]:
                pathMap = {}
                pathMap["name"] = path["path"]
                srvName = path["backend"]["serviceName"]
                pathMap["serviceName"] = srvName
                pathMap["items"] = []

                command = "kubectl -n " + args.namespace + " get service " + srvName + " -o json"
                print("Running: " + command)
                commandOutput = subprocess.run(command.split(),
                                               stdout=subprocess.PIPE)
                commandJson = commandOutput.stdout.decode('utf-8')
                srvObj = json.loads(commandJson)

                #kubectl get pods -l environment=production,tier=frontend

                filter = ""
                for selector in srvObj["spec"]["selector"]:
                    if filter != "":
                        filter = "," + filter
                    filter = selector + "=" + srvObj["spec"]["selector"][
                        selector]

                command = "kubectl -n " + args.namespace + " get pods -l " + filter + " -o json"
                print("Running: " + command)
                commandOutput = subprocess.run(command.split(),
                                               stdout=subprocess.PIPE)
                commandJson = commandOutput.stdout.decode('utf-8')
                podsList = json.loads(commandJson)

                for pod in podsList["items"]:
                    podMap = {}
                    podMap["name"] = pod["metadata"]["name"]
                    pathMap["items"].append(podMap)

                hostMap["items"].append(pathMap)

            ingressMap["items"].append(hostMap)

        diagramMap["ingress"].append(ingressMap)

    for ingress in diagramMap["ingress"]:
        print(ingress["name"])
        with Diagram("auto_" + ingress["name"], show=False):
            dIngress = Ingress(ingress["name"])
            for host in ingress["items"]:
                print(host["name"])
                with Cluster(host["name"]):
                    for path in host["items"]:
                        print(path["name"])
                        print(path["serviceName"])
                        with Cluster(path["name"]):
                            dSrv = Service(path["serviceName"])
                            for pod in path["items"]:
                                dSrv >> Pod(pod["name"])
                            dIngress >> dSrv

    sys.exit()
Beispiel #28
0
from diagrams import Diagram, Cluster
from diagrams.k8s.clusterconfig import HPA
from diagrams.k8s.compute import Deployment, Pod, ReplicaSet
from diagrams.k8s.network import Ingress, Service

with Diagram("Exposed Pod with 4 Replicas", show=True):
    net = Ingress("releasemanagement.org")
    with Cluster("Kube Cluster"):
        net >> Service("svc") >> [Pod("pod1"),
                                  Pod("pod2"),
                                  Pod("pod3"),
                                  Pod("Pod4")] << ReplicaSet("rs") << Deployment("dp") << HPA("hpa")
›
        fe = Pod("trow-frontend")
        fe >> be1

    with Cluster("Node 2"):
        be2 = Pod("trow-backend-2")

    with Cluster("Node 3"):
        be3 = Pod("trow-backend-3")

    with Cluster("Node 4"):
        be4 = Pod("trow-backend-4")

    with Cluster("Node 5"):
        be5 = Pod("trow-backend-5")

    be1 - be2
    be1 - be3
    be1 - be4
    be1 - be5
    be2 - be3
    be2 - be4
    be2 - be5
    be3 - be4
    be3 - be5
    be4 - be5

    ing = Ingress("trow.io")
    svc = Service("trow-svc")
    ing >> svc
    svc >> fe
Beispiel #30
0
from diagrams import Cluster, Diagram
from diagrams.k8s.compute import Pod, Deploy
from diagrams.k8s.network import Service
from diagrams.k8s.infra import Master, Node
from diagrams.programming.language import Go
from diagrams.programming.framework import Vue
from diagrams.generic.database import SQL
from diagrams.generic.device import Tablet

print("hello world!\n")
with Diagram("", show=False):
    with Cluster("cluster"):
        Master("master") - Node("worker1") - Node("worker2")

    with Cluster("worker node"):
        with Cluster("deploy"):
            pod = [Pod("hello"), Pod("hello"), Pod("hello")]
        nodeport = Service("NodePort")
        nodeport >> pod
    Tablet("user") >> nodeport

    with Cluster("container in Pod, hello"):
        Vue("front end") - Go("back end") - SQL("db")