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
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
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
def main(): with Diagram('New SFTP Process') as diag: user = Windows('User') with Cluster('Repay-CDE-PROD-SFTP', direction='TB'): sftp_service = TransferForSftp('SFTP') s3_sftp_bucket = S3('channels_sftp_transfer') sftp_service - s3_sftp_bucket aws_sftp_group = [sftp_service, s3_sftp_bucket] user >> Edge(label='Upload a BLF into SFTP') >> sftp_service with Cluster('repay-cde-prod-channels', direction='TB'): lambda_blf_copy = Lambda('s3_copy_lambda') s3_blf_processor = S3('blf_processor bucket') sns_blf_uploaded_to_s3 = SNS('SNS - blf_uploaded_to_s3') redis = ElastiCache('(redis)') elasticsearch = ES('1 index per BLF') lambda_blf_copy >> s3_blf_processor s3_blf_processor >> sns_blf_uploaded_to_s3 cde_group = [ lambda_blf_copy, s3_blf_processor, sns_blf_uploaded_to_s3, redis, elasticsearch ] with Cluster('repay-cde-prod-k8s', direction='TB'): k8s_api_pod = Pod('Channels API\n/api/v1/blf_upload_sns') k8s_blf_processor_job = Job('process-blf-k8s') k8s_api_pod >> Edge( label='Create job if no BLF lock exists for org/filename' ) >> k8s_blf_processor_job k8s_group = [k8s_api_pod, k8s_blf_processor_job] # TODO - MAKE SURE TO HIGHLIGHT THE USE OF INVISIBLE EDGES s3_sftp_bucket >> Edge(style='invis') >> cde_group redis >> Edge(style='invis') >> k8s_group elasticsearch >> Edge(style='invis') >> k8s_group k8s_blf_processor_job << Edge( label='Download file from s3') << s3_blf_processor s3_sftp_bucket >> Edge( label='S3 notification Object Created') >> lambda_blf_copy sns_blf_uploaded_to_s3 >> Edge( label='HTTP request with BLF file name') >> k8s_api_pod k8s_api_pod >> Edge( label='Create BLF lock - 5 minute expiration') >> redis k8s_blf_processor_job >> Edge( label='Delete BLF lock when done') >> redis k8s_blf_processor_job >> Edge(label='Create ES index') >> elasticsearch
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
def get_common_architecture(cloud_provider, filename, container_registry, k8s_cluster_name, k8s_engine_name): with Diagram( f"QHub Architecture: {cloud_provider}", filename=f'{filename}', show=False, direction="TB", ): with Cluster(cloud_provider): gcr = ContainerRegistry(container_registry) with Cluster(k8s_cluster_name): kube_engine = KubernetesEngine(k8s_engine_name) conda_pvc = PersistentVolume('Conda') nfs_pvc = PersistentVolume('NFS') elb = LoadBalancing('Ingress') with Cluster('Master'): general = Node('general') Node('user') Node('worker') general << kube_engine with Cluster("Pods"): dask_gateway = Pod('Dask Gateway') jupyterhub = Pod('JupyterHub') dask_scheduler = Pod('Dask Scheduler') nfs_server = Pod('NFS Server') conda_store = Pod('Conda Store') nginx = Pod('Nginx') Pod('Cert Manager') image_puller = Pod('Image Puller') nginx >> elb nginx >> jupyterhub [nfs_server, conda_store, dask_gateway] << jupyterhub [conda_store, dask_scheduler] << dask_gateway image_puller >> gcr nfs_server >> nfs_pvc conda_store >> conda_pvc Helm('Helm') >> kube_engine
def get_common_architecture(cloud_provider, filename, container_registry, k8s_cluster_name, k8s_engine_name): with Diagram( f"QHub Architecture: {cloud_provider}", filename=f"{filename}", show=False, direction="TB", ): with Cluster(cloud_provider): gcr = ContainerRegistry(container_registry) with Cluster(k8s_cluster_name): kube_engine = KubernetesEngine(k8s_engine_name) conda_pvc = PersistentVolume("Conda") nfs_pvc = PersistentVolume("NFS") elb = LoadBalancing("Ingress") with Cluster("Master"): general = Node("general") Node("user") Node("worker") general << kube_engine with Cluster("Pods"): dask_gateway = Pod("Dask Gateway") jupyterhub = Pod("JupyterHub") dask_scheduler = Pod("Dask Scheduler") nfs_server = Pod("NFS Server") conda_store = Pod("Conda Store") nginx = Pod("Nginx") Pod("Cert Manager") image_puller = Pod("Image Puller") nginx >> elb nginx >> jupyterhub [nfs_server, conda_store, dask_gateway] << jupyterhub [conda_store, dask_scheduler] << dask_gateway image_puller >> gcr nfs_server >> nfs_pvc conda_store >> conda_pvc Helm("Helm") >> kube_engine
from diagrams import Cluster, Diagram, Edge from diagrams.k8s.compute import Pod from diagrams.k8s.compute import Deployment from diagrams.k8s.compute import ReplicaSet from diagrams.onprem.container import Docker with Diagram("kubernetes configuration files", show=False): depl = Deployment("Deployment") rs = ReplicaSet("ReplicaSet") pod = Pod("Pod") docker = Docker("Container") depl >> rs >> pod >> docker
with Diagram("Setup a blog on k3s", show=False, graph_attr=graph_attr, node_attr=node_attr, direction="TB"): users = Users("Users") with Cluster("LetsEncrypt API Servers", graph_attr=graph_attr): letsencrypt = LetsEncrypt("LE SSL Certificate") with Cluster("BareMetal Server", graph_attr=graph_attr): with Cluster("K8S Cluster", graph_attr=graph_attr): with Cluster("NS Cert-Manager", graph_attr=graph_attr): certificate_request = CertManager("mywebsite.com") with Cluster("NS www", graph_attr=graph_attr): website_secret = Secret("mywebsite.com") with Cluster("Ingress", graph_attr=graph_attr): ingress = Ingress("https") with Cluster("Pods", graph_attr=graph_attr): pod = Pod('website') with Cluster("Deployment", graph_attr=graph_attr): pod_deploy = Deployment("website") with Cluster("RS", graph_attr=graph_attr): pod_rs = RS("website") letsencrypt >> website_secret >> ingress certificate_request >> letsencrypt users >> ingress >> pod pod_rs >> pod pod_deploy >> pod
direction="LR", node_attr ={"fontsize": "14"}, edge_attr ={"labelfontsize": "14"}): with Cluster("Google Cloud") as cloud: storage = GCS("Google Cloud Storage") with Cluster("Kubernetes cluster"): with Cluster("Monitoring") as monitoring: metrics = Prometheus("Prometheus") metrics_push = Prometheus("Prometheus Gateway") metrics_push << Edge(label="pull metrics") << metrics service_monitor = CRD("ServiceMonitor") service_monitor << Edge(label="watch") << metrics metrics << Edge(label="query metrics") << Grafana("Grafana") with Cluster("Apache Spark application") as spark: Spark() driver = Pod("driver") driver << service_monitor exec_1 = Pod("executor 1") exec_2 = Pod("executor 2") exec_3 = Pod("executor 3") driver << exec_1 driver << exec_2 driver << exec_3 driver >> Edge(label="push metrics") >> metrics_push driver << Edge(label="pull metrics") << metrics exec_1 >> Edge(label="read/write") >> storage exec_2 >> Edge(label="read/write") >> storage exec_3 >> Edge(label="read/write") >> storage operator = Pod("Spark Operator") crd = CRD("SparkApplication") crd << Edge(label="watch") << operator >> Edge(label="create") >> driver
k8s_vol >> efs with Cluster("Public"): ig = InternetGateway("Internet gateway") elb = ElasticLoadBalancing("Ingress") public = [ig, elb] elb >> ecr with Cluster("Master"): general = Node("general") user = Node("user") worker = Node("worker") general << eks with Cluster("Pods"): dask_gateway = Pod("Dask Gateway") jupyterhub = Pod("JupyterHub") dask_scheduler = Pod("Dask Scheduler") nfs_server = Pod("NFS Server") conda_store = Pod("Conda Store") nginx = Pod("Nginx") cert_manager = Pod("Cert Manager") image_puller = Pod("Image Puller") nginx >> jupyterhub [nfs_server, conda_store, dask_gateway] << jupyterhub [conda_store, dask_scheduler] << dask_gateway [image_puller, nginx] >> elb nfs_server >> k8s_vol Helm("Helm") >> eks
def custom_icon(filename): return os.path.join("architecture/icons", filename) with Diagram( "QHub Architecture: High Level", filename="high_level_architecture", show=False, direction="TB", ): with Cluster("Kubernetes Cluster"): conda_pvc = PersistentVolume("Conda (Persistent Volume)") nfs_pvc = PersistentVolume("NFS (Persistent Volume)") elb = LoadBalancing("Ingress") with Cluster("Pods"): dask_gateway = Custom("Dask Gateway", custom_icon("dask.png")) jupyterhub = Custom("JupyterHub", custom_icon("jupyter_hub.png")) dask_scheduler = Custom("Dask Scheduler", custom_icon("dask.png")) nfs_server = Pod("NFS Server") conda_store = Custom("Conda Store", custom_icon("conda.png")) nginx = Custom("Nginx", custom_icon("nginx.png")) nginx >> elb nginx >> jupyterhub [nfs_server, conda_store, dask_gateway] << jupyterhub [conda_store, dask_scheduler] << dask_gateway nfs_server >> nfs_pvc conda_store >> conda_pvc
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()
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")
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
from diagrams import Diagram, Cluster, Edge from diagrams.custom import Custom from diagrams.k8s.compute import Pod globe_img = "resources/globe.png" graph_attr = {"pad": "0.5"} with Diagram(filename="shard", direction='TB', show=False, outformat='png', graph_attr=graph_attr): user_1 = [Custom("user", globe_img) for _ in range(1)] with Cluster("Shard"): web, jicofo, prosody = [Pod("web"), Pod("jicofo"), Pod("prosody")] user_1 >> web web >> prosody jicofo >> Edge() << prosody n_jvbs = 3 with Cluster("Jitsi Videobridge"): jvb_pods = [Pod(f"jvb-{i}") for i in range(n_jvbs)] [jvb_pods[i] >> Edge() << prosody for i in range(n_jvbs)] user_1 >> jvb_pods[0]
"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") pod_nexus - Edge(color="gray", style="dashed") - secret_nexus - Edge(color="gray", style="dashed") - token_nexus - Edge(color="gray", style="dashed") - sa_nexus pod_nexus - Edge(color="gray", style="dashed") - config_volume_nexus svc_nexus >> pod_nexus with Cluster("Chartmusem"): svc_chartmuseum = custom.Custom("Chartmuseum","assets/img/logos/logo_chartmuseum.png")
with Cluster("Remote Git"): github = Github("github") gitlab = Gitlab("gitlab") gits = [ github, gitlab] with Cluster("K8s cluster"): ic = CRD("IntegrationConfig") ij = CRD("IntegrationJob") ing = Ingress() with Cluster("CI/CD Operator"): webhookServer = Pod("Webhook server") github - Edge(label="PullRequest/Push/Tag") >> ing >> webhookServer webhookServer - Edge(label="Queued") >> ij pr = Custom("PipelineRun", tektonIcon) ij - Edge(label="Scheduled") >> pr tr1 = Custom("TaskRun-1", tektonIcon) tr2 = Custom("TaskRun-2", tektonIcon) tr3 = Custom("TaskRun-3", tektonIcon) pr >> tr3 >> Pod() pr >> tr2 >> Pod() pr >> tr1 >> Pod()
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
direction='TB', show=False, 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)] with Cluster("Kubernetes Cluster"): ingress = Ingress("edurusma.adalet.gov.tr") with Cluster("HAProxy"): n_haproxy = 2 haproxy_pods = [Pod(f"haproxy-{i}") for i in range(n_haproxy)] edge_conference_1 = Edge(color="red") edge_conference_2 = Edge(color="green") shard_0 = Custom("shard-0", jitsi_img) shard_1 = Custom("shard-1", jitsi_img) users_1 >> edge_conference_1 >> ingress users_2 >> edge_conference_2 >> ingress for haproxy in haproxy_pods: ingress >> haproxy for i in range(len(users_1)): haproxy_pods[i % len(haproxy_pods)] >> edge_conference_1 >> shard_0 for i in range(len(users_2)):
from diagrams import Cluster, Diagram from diagrams.k8s.compute import Pod, DaemonSet from diagrams.k8s.storage import PV, PVC, StorageClass with Diagram("Persistent Storage for a Pod", show=False): with Cluster("k8s"): pod = Pod("d1") pvc = PVC("pvc-1") pv = PV("pvc-[uuid]") sc = StorageClass("fast") ds = DaemonSet("StorageOS") pod >> pvc << pv << sc >> ds
from diagrams.k8s.compute import Pod from diagrams.k8s.network import Ingress from diagrams.generic.blank import Blank graph_attr = { # "splines": "curved" } with Diagram("OCP4 Default Ingress", show=False, direction="LR", graph_attr=graph_attr): dns = DNS("*.apps.dta.my.lab") lbint = LoadBalancing("HAProxy") with Cluster("OpenShift Cluster"): routerext = Ingress("default") with Cluster("Workers"): with Cluster("Projects"): with Cluster("proj-app-01"): workersint = [Pod("myApp")] with Cluster("proj-app-02"): workersext = [Pod("myApp")] dns >> lbint lbint >> routerext routerext >> workersint routerext >> workersext
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 primary >> Edge(label="3. RPC with token") >> envoy >> integration controller - Edge(label="inject requested sidecar", style="dashed") - sidecar
with Diagram("k8s Architecture", show=False): fe_ing = Ing("https//my-whiteapp.fr") with Cluster("White App"): nm = Namespace("WhiteApp") # Services fe_svc = SVC("") be_svc = SVC("") db_svc = SVC("") # Pods fe_pod = Pod("FrontEnd") be_pod = Pod("Backend") db_pod = Pod("Database") # Storage db_vol = Vol("DB Volume") be_vol = Vol("BE Volume") fe_ing >> fe_svc fe_svc >> fe_pod be_svc >> be_pod db_svc >> db_pod fe_pod >> be_svc
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
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 services - pods
from diagrams import Diagram, Cluster, Edge from diagrams.k8s.network import Ingress, Service from diagrams.k8s.compute import StatefulSet, Pod from diagrams.k8s.storage import PV from diagrams.k8s.infra import Node with Diagram("Advanced Distribution", show=False, direction="LR", graph_attr={"splines": "spline"}): with Cluster("Node 1"): be1 = Pod("trow-backend-1") 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
from diagrams import Diagram, Cluster from diagrams.k8s.network import Ingress, Service from diagrams.k8s.compute import StatefulSet, Pod from diagrams.k8s.storage import PV from diagrams.k8s.infra import Node with Diagram("Standard Kubernetes Install", show=False, direction="LR"): ing = Ingress("trow.io") svc = Service("trow-svc") ing >> svc pod = Pod("trow") StatefulSet("trow-set") - pod pod - PV("data-vol") svc >> pod with Cluster("Nodes"): workers = [Node("Node 1"), Node("Node 2"), Node("Node 3")] workers >> ing
"fontcolor": "#e9e9e9", } edge_attr = { "fontcolor": "#e9e9e9", "color": "#1cbfa9", } kuberik_icon = "logo.png" with Diagram(filename="play_trigger", show=False, edge_attr=edge_attr, outformat="png", graph_attr=graph_attr, node_attr=node_attr): with Cluster("Screening", graph_attr=graph_attr): screener_controller = Pod("Screener Controller") screener = CRD("Screener") events = CRD("Events") screener << Edge(label="configure", **edge_attr) - screener_controller screener_controller - Edge(label="") >> events movie = CRD("Movie") # "\n" fixes padding issues engine = Custom("Engine\n", kuberik_icon) movie << Edge(constraint="false") - engine [events, events, events] << engine with Cluster("Pipeline execution", graph_attr=graph_attr): play = CRD("Play") actions = [Job("Action"), Job("Action"), Job("Action")]
direction='TB', show=False, 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