Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 

199 lignes
20 KiB

  1. <!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>Examples · Diagrams</title><meta name="viewport" content="width=device-width"/><meta name="generator" content="Docusaurus"/><meta name="description" content="Here are some more examples."/><meta name="docsearch:language" content="en"/><meta property="og:title" content="Examples · Diagrams"/><meta property="og:type" content="website"/><meta property="og:url" content="https://diagrams.mingrammer.com/"/><meta property="og:description" content="Here are some more examples."/><meta property="og:image" content="https://diagrams.mingrammer.com/img/diagrams.png"/><meta name="twitter:card" content="summary"/><meta name="twitter:image" content="https://diagrams.mingrammer.com/img/diagrams.png"/><link rel="shortcut icon" href="/img/diagrams.ico"/><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css"/><script type="text/javascript" src="https://buttons.github.io/buttons.js"></script><script src="/js/scrollSpy.js"></script><link rel="stylesheet" href="/css/main.css"/><script src="/js/codetabs.js"></script></head><body class="sideNavVisible separateOnPageNav"><div class="fixedHeaderContainer"><div class="headerWrapper wrapper"><header><a href="/"><img class="logo" src="/img/diagrams.ico" alt="Diagrams"/><h2 class="headerTitleWithLogo">Diagrams</h2></a><div class="navigationWrapper navigationSlider"><nav class="slidingNav"><ul class="nav-site nav-site-internal"><li class="siteNavGroupActive"><a href="/docs/installation" target="_self">Docs</a></li><li class="siteNavGroupActive"><a href="/docs/diagram" target="_self">Guides</a></li><li class=""><a href="https://github.com/mingrammer/diagrams" target="_self">GitHub</a></li></ul></nav></div></header></div></div><div class="navPusher"><div class="docMainWrapper wrapper"><div class="docsNavContainer" id="docsNav"><nav class="toc"><div class="toggleNav"><section class="navWrapper wrapper"><div class="navBreadcrumb wrapper"><div class="navToggle" id="navToggler"><div class="hamburger-menu"><div class="line1"></div><div class="line2"></div><div class="line3"></div></div></div><h2><i>›</i><span>Getting Started</span></h2><div class="tocToggler" id="tocToggler"><i class="icon-toc"></i></div></div><div class="navGroups"><div class="navGroup"><h3 class="navGroupCategoryTitle">Getting Started</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/installation">Installation</a></li><li class="navListItem navListItemActive"><a class="navItem" href="/docs/examples">Examples</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Guides</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/diagram">Diagrams</a></li><li class="navListItem"><a class="navItem" href="/docs/node">Nodes</a></li><li class="navListItem"><a class="navItem" href="/docs/cluster">Clusters</a></li></ul></div></div></section></div><script>
  2. var coll = document.getElementsByClassName('collapsible');
  3. var checkActiveCategory = true;
  4. for (var i = 0; i < coll.length; i++) {
  5. var links = coll[i].nextElementSibling.getElementsByTagName('*');
  6. if (checkActiveCategory){
  7. for (var j = 0; j < links.length; j++) {
  8. if (links[j].classList.contains('navListItemActive')){
  9. coll[i].nextElementSibling.classList.toggle('hide');
  10. coll[i].childNodes[1].classList.toggle('rotate');
  11. checkActiveCategory = false;
  12. break;
  13. }
  14. }
  15. }
  16. coll[i].addEventListener('click', function() {
  17. var arrow = this.childNodes[1];
  18. arrow.classList.toggle('rotate');
  19. var content = this.nextElementSibling;
  20. content.classList.toggle('hide');
  21. });
  22. }
  23. document.addEventListener('DOMContentLoaded', function() {
  24. createToggler('#navToggler', '#docsNav', 'docsSliderActive');
  25. createToggler('#tocToggler', 'body', 'tocActive');
  26. var headings = document.querySelector('.toc-headings');
  27. headings && headings.addEventListener('click', function(event) {
  28. var el = event.target;
  29. while(el !== headings){
  30. if (el.tagName === 'A') {
  31. document.body.classList.remove('tocActive');
  32. break;
  33. } else{
  34. el = el.parentNode;
  35. }
  36. }
  37. }, false);
  38. function createToggler(togglerSelector, targetSelector, className) {
  39. var toggler = document.querySelector(togglerSelector);
  40. var target = document.querySelector(targetSelector);
  41. if (!toggler) {
  42. return;
  43. }
  44. toggler.onclick = function(event) {
  45. event.preventDefault();
  46. target.classList.toggle(className);
  47. };
  48. }
  49. });
  50. </script></nav></div><div class="container mainContainer docsContainer"><div class="wrapper"><div class="post"><header class="postHeader"><h1 id="__docusaurus" class="postHeaderTitle">Examples</h1></header><article><div><span><p>Here are some more examples.</p>
  51. <h2><a class="anchor" aria-hidden="true" id="grouped-workers"></a><a href="#grouped-workers" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Grouped Workers</h2>
  52. <pre><code class="hljs css language-python"><span class="hljs-keyword">from</span> diagrams <span class="hljs-keyword">import</span> Diagram
  53. <span class="hljs-keyword">from</span> diagrams.aws.compute <span class="hljs-keyword">import</span> EC2
  54. <span class="hljs-keyword">from</span> diagrams.aws.database <span class="hljs-keyword">import</span> RDS
  55. <span class="hljs-keyword">from</span> diagrams.aws.network <span class="hljs-keyword">import</span> ELB
  56. <span class="hljs-keyword">with</span> Diagram(<span class="hljs-string">"Grouped Workers"</span>, show=<span class="hljs-literal">False</span>, direction=<span class="hljs-string">"TB"</span>):
  57. ELB(<span class="hljs-string">"lb"</span>) &gt;&gt; [EC2(<span class="hljs-string">"worker1"</span>),
  58. EC2(<span class="hljs-string">"worker2"</span>),
  59. EC2(<span class="hljs-string">"worker3"</span>),
  60. EC2(<span class="hljs-string">"worker4"</span>),
  61. EC2(<span class="hljs-string">"worker5"</span>)] &gt;&gt; RDS(<span class="hljs-string">"events"</span>)
  62. </code></pre>
  63. <p><img src="/img/grouped_workers_diagram.png" alt="grouped workers diagram"></p>
  64. <h2><a class="anchor" aria-hidden="true" id="clustered-web-services"></a><a href="#clustered-web-services" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Clustered Web Services</h2>
  65. <pre><code class="hljs css language-python"><span class="hljs-keyword">from</span> diagrams <span class="hljs-keyword">import</span> Cluster, Diagram
  66. <span class="hljs-keyword">from</span> diagrams.aws.compute <span class="hljs-keyword">import</span> ECS
  67. <span class="hljs-keyword">from</span> diagrams.aws.database <span class="hljs-keyword">import</span> ElastiCache, RDS
  68. <span class="hljs-keyword">from</span> diagrams.aws.network <span class="hljs-keyword">import</span> ELB
  69. <span class="hljs-keyword">from</span> diagrams.aws.network <span class="hljs-keyword">import</span> Route53
  70. <span class="hljs-keyword">with</span> Diagram(<span class="hljs-string">"Clustered Web Services"</span>, show=<span class="hljs-literal">False</span>):
  71. dns = Route53(<span class="hljs-string">"dns"</span>)
  72. lb = ELB(<span class="hljs-string">"lb"</span>)
  73. <span class="hljs-keyword">with</span> Cluster(<span class="hljs-string">"Services"</span>):
  74. svc_group = [ECS(<span class="hljs-string">"web1"</span>),
  75. ECS(<span class="hljs-string">"web2"</span>),
  76. ECS(<span class="hljs-string">"web3"</span>)]
  77. <span class="hljs-keyword">with</span> Cluster(<span class="hljs-string">"DB Cluster"</span>):
  78. db_master = RDS(<span class="hljs-string">"userdb"</span>)
  79. db_master - [RDS(<span class="hljs-string">"userdb ro"</span>)]
  80. memcached = ElastiCache(<span class="hljs-string">"memcached"</span>)
  81. dns &gt;&gt; lb &gt;&gt; svc_group
  82. svc_group &gt;&gt; db_master
  83. svc_group &gt;&gt; memcached
  84. </code></pre>
  85. <p><img src="/img/clustered_web_services_diagram.png" alt="clustered web services diagram"></p>
  86. <h2><a class="anchor" aria-hidden="true" id="event-processing"></a><a href="#event-processing" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Event Processing</h2>
  87. <pre><code class="hljs css language-python"><span class="hljs-keyword">from</span> diagrams <span class="hljs-keyword">import</span> Cluster, Diagram
  88. <span class="hljs-keyword">from</span> diagrams.aws.compute <span class="hljs-keyword">import</span> ECS, EKS, Lambda
  89. <span class="hljs-keyword">from</span> diagrams.aws.database <span class="hljs-keyword">import</span> Redshift
  90. <span class="hljs-keyword">from</span> diagrams.aws.integration <span class="hljs-keyword">import</span> SQS
  91. <span class="hljs-keyword">from</span> diagrams.aws.storage <span class="hljs-keyword">import</span> S3
  92. <span class="hljs-keyword">with</span> Diagram(<span class="hljs-string">"Event Processing"</span>, show=<span class="hljs-literal">False</span>):
  93. source = EKS(<span class="hljs-string">"k8s source"</span>)
  94. <span class="hljs-keyword">with</span> Cluster(<span class="hljs-string">"Event Flows"</span>):
  95. <span class="hljs-keyword">with</span> Cluster(<span class="hljs-string">"Event Workers"</span>):
  96. workers = [ECS(<span class="hljs-string">"worker1"</span>),
  97. ECS(<span class="hljs-string">"worker2"</span>),
  98. ECS(<span class="hljs-string">"worker3"</span>)]
  99. queue = SQS(<span class="hljs-string">"event queue"</span>)
  100. <span class="hljs-keyword">with</span> Cluster(<span class="hljs-string">"Processing"</span>):
  101. handlers = [Lambda(<span class="hljs-string">"proc1"</span>),
  102. Lambda(<span class="hljs-string">"proc2"</span>),
  103. Lambda(<span class="hljs-string">"proc3"</span>)]
  104. store = S3(<span class="hljs-string">"events store"</span>)
  105. dw = Redshift(<span class="hljs-string">"analytics"</span>)
  106. source &gt;&gt; workers &gt;&gt; queue &gt;&gt; handlers
  107. handlers &gt;&gt; store
  108. handlers &gt;&gt; dw
  109. </code></pre>
  110. <p><img src="/img/event_processing_diagram.png" alt="event processing diagram"></p>
  111. <h2><a class="anchor" aria-hidden="true" id="message-collecting-system"></a><a href="#message-collecting-system" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Message Collecting System</h2>
  112. <pre><code class="hljs css language-python"><span class="hljs-keyword">from</span> diagrams <span class="hljs-keyword">import</span> Cluster, Diagram
  113. <span class="hljs-keyword">from</span> diagrams.gcp.analytics <span class="hljs-keyword">import</span> BigQuery, Dataflow, PubSub
  114. <span class="hljs-keyword">from</span> diagrams.gcp.compute <span class="hljs-keyword">import</span> AppEngine, Functions
  115. <span class="hljs-keyword">from</span> diagrams.gcp.database <span class="hljs-keyword">import</span> BigTable
  116. <span class="hljs-keyword">from</span> diagrams.gcp.iot <span class="hljs-keyword">import</span> IotCore
  117. <span class="hljs-keyword">from</span> diagrams.gcp.storage <span class="hljs-keyword">import</span> GCS
  118. <span class="hljs-keyword">with</span> Diagram(<span class="hljs-string">"Message Collecting"</span>, show=<span class="hljs-literal">False</span>):
  119. pubsub = PubSub(<span class="hljs-string">"pubsub"</span>)
  120. <span class="hljs-keyword">with</span> Cluster(<span class="hljs-string">"Source of Data"</span>):
  121. [IotCore(<span class="hljs-string">"core1"</span>),
  122. IotCore(<span class="hljs-string">"core2"</span>),
  123. IotCore(<span class="hljs-string">"core3"</span>)] &gt;&gt; pubsub
  124. <span class="hljs-keyword">with</span> Cluster(<span class="hljs-string">"Targets"</span>):
  125. <span class="hljs-keyword">with</span> Cluster(<span class="hljs-string">"Data Flow"</span>):
  126. flow = Dataflow(<span class="hljs-string">"data flow"</span>)
  127. <span class="hljs-keyword">with</span> Cluster(<span class="hljs-string">"Data Lake"</span>):
  128. flow &gt;&gt; [BigQuery(<span class="hljs-string">"bq"</span>),
  129. GCS(<span class="hljs-string">"storage"</span>)]
  130. <span class="hljs-keyword">with</span> Cluster(<span class="hljs-string">"Event Driven"</span>):
  131. <span class="hljs-keyword">with</span> Cluster(<span class="hljs-string">"Processing"</span>):
  132. flow &gt;&gt; AppEngine(<span class="hljs-string">"engine"</span>) &gt;&gt; BigTable(<span class="hljs-string">"bigtable"</span>)
  133. <span class="hljs-keyword">with</span> Cluster(<span class="hljs-string">"Serverless"</span>):
  134. flow &gt;&gt; Functions(<span class="hljs-string">"func"</span>) &gt;&gt; AppEngine(<span class="hljs-string">"appengine"</span>)
  135. pubsub &gt;&gt; flow
  136. </code></pre>
  137. <p><img src="/img/message_collecting_diagram.png" alt="message collecting diagram"></p>
  138. <h2><a class="anchor" aria-hidden="true" id="exposed-pod-with-3-replicas-on-k8s"></a><a href="#exposed-pod-with-3-replicas-on-k8s" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Exposed Pod with 3 Replicas on k8s</h2>
  139. <pre><code class="hljs css language-python"><span class="hljs-keyword">from</span> diagrams <span class="hljs-keyword">import</span> Diagram
  140. <span class="hljs-keyword">from</span> diagrams.k8s.clusterconfig <span class="hljs-keyword">import</span> HPA
  141. <span class="hljs-keyword">from</span> diagrams.k8s.compute <span class="hljs-keyword">import</span> Deployment, Pod, ReplicaSet
  142. <span class="hljs-keyword">from</span> diagrams.k8s.network <span class="hljs-keyword">import</span> Ingress, Service
  143. <span class="hljs-keyword">with</span> Diagram(<span class="hljs-string">"Exposed Pod with 3 Replicas"</span>, show=<span class="hljs-literal">False</span>):
  144. net = Ingress(<span class="hljs-string">"domain.com"</span>) &gt;&gt; Service(<span class="hljs-string">"svc"</span>)
  145. net &gt;&gt; [Pod(<span class="hljs-string">"pod1"</span>),
  146. Pod(<span class="hljs-string">"pod2"</span>),
  147. Pod(<span class="hljs-string">"pod3"</span>)] &lt;&lt; ReplicaSet(<span class="hljs-string">"rs"</span>) &lt;&lt; Deployment(<span class="hljs-string">"dp"</span>) &lt;&lt; HPA(<span class="hljs-string">"hpa"</span>)
  148. </code></pre>
  149. <p><img src="/img/exposed_pod_with_3_replicas_diagram.png" alt="exposed pod with 3 replicas diagram"></p>
  150. <h2><a class="anchor" aria-hidden="true" id="stateful-architecture-on-k8s"></a><a href="#stateful-architecture-on-k8s" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Stateful Architecture on k8s</h2>
  151. <pre><code class="hljs css language-python"><span class="hljs-keyword">from</span> diagrams <span class="hljs-keyword">import</span> Cluster, Diagram
  152. <span class="hljs-keyword">from</span> diagrams.k8s.compute <span class="hljs-keyword">import</span> Pod, StatefulSet
  153. <span class="hljs-keyword">from</span> diagrams.k8s.network <span class="hljs-keyword">import</span> Service
  154. <span class="hljs-keyword">from</span> diagrams.k8s.storage <span class="hljs-keyword">import</span> PV, PVC, StorageClass
  155. <span class="hljs-keyword">with</span> Diagram(<span class="hljs-string">"Stateful Architecture"</span>, show=<span class="hljs-literal">False</span>):
  156. <span class="hljs-keyword">with</span> Cluster(<span class="hljs-string">"Apps"</span>):
  157. svc = Service(<span class="hljs-string">"svc"</span>)
  158. sts = StatefulSet(<span class="hljs-string">"sts"</span>)
  159. apps = []
  160. <span class="hljs-keyword">for</span> _ <span class="hljs-keyword">in</span> range(<span class="hljs-number">3</span>):
  161. pod = Pod(<span class="hljs-string">"pod"</span>)
  162. pvc = PVC(<span class="hljs-string">"pvc"</span>)
  163. pod - sts - pvc
  164. apps.append(svc &gt;&gt; pod &gt;&gt; pvc)
  165. apps &lt;&lt; PV(<span class="hljs-string">"pv"</span>) &lt;&lt; StorageClass(<span class="hljs-string">"sc"</span>)
  166. </code></pre>
  167. <p><img src="/img/stateful_architecture_diagram.png" alt="stateful architecture diagram"></p>
  168. </span></div></article></div><div class="docLastUpdate"><em>Last updated on 2020-2-7</em></div><div class="docs-prevnext"><a class="docs-prev button" href="/docs/installation"><span class="arrow-prev">← </span><span>Installation</span></a><a class="docs-next button" href="/docs/diagram"><span>Diagrams</span><span class="arrow-next"> →</span></a></div></div></div><nav class="onPageNav"><ul class="toc-headings"><li><a href="#grouped-workers">Grouped Workers</a></li><li><a href="#clustered-web-services">Clustered Web Services</a></li><li><a href="#event-processing">Event Processing</a></li><li><a href="#message-collecting-system">Message Collecting System</a></li><li><a href="#exposed-pod-with-3-replicas-on-k8s">Exposed Pod with 3 Replicas on k8s</a></li><li><a href="#stateful-architecture-on-k8s">Stateful Architecture on k8s</a></li></ul></nav></div><footer class="nav-footer" id="footer"><section class="sitemap"><a href="/" class="nav-home"><img src="/img/diagrams.ico" alt="Diagrams" width="66" height="58"/></a><div><h5>Docs</h5><a href="/docs/en/installation">Getting Started</a><a href="/docs/en/diagram">Guides</a></div><div><h5>More</h5><a href="https://github.com/mingrammer/diagrams">GitHub</a><a class="github-button" data-icon="octicon-star" data-count-href="/mingrammer/diagrams/stargazers" data-show-count="true" data-count-aria-label="# stargazers on GitHub" aria-label="Star this project on GitHub">Star</a></div></section><section class="copyright">Copyright © 2020 mingrammer</section></footer></div></body></html>