-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathadvanced_web_services_open_source.py
executable file
·97 lines (81 loc) · 2.91 KB
/
advanced_web_services_open_source.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/env python3
# coding=utf-8
# vim:ts=4:sts=4:sw=4:et
#
# Author: Hari Sekhon
# Date: 2023-04-14 13:54:52 +0100 (Fri, 14 Apr 2023)
#
# https://github.com/HariSekhon/Diagrams-as-Code
#
# License: see accompanying Hari Sekhon LICENSE file
#
# If you're using my code you're welcome to connect with me on LinkedIn
# and optionally send me feedback to help steer this or other code I publish
#
# https://www.linkedin.com/in/HariSekhon
#
"""
Advanced Web Services Open Source
"""
# based on https://diagrams.mingrammer.com/docs/getting-started/examples
__author__ = 'Hari Sekhon'
__version__ = '0.1'
import os
from diagrams import Diagram, Cluster, Edge
# ============================================================================ #
# On-premise / Open Source resources:
#
# https://diagrams.mingrammer.com/docs/nodes/onprem
#
from diagrams.onprem.analytics import Spark
from diagrams.onprem.compute import Server
from diagrams.onprem.database import PostgreSQL
from diagrams.onprem.inmemory import Redis
from diagrams.onprem.aggregator import Fluentd
from diagrams.onprem.monitoring import Grafana, Prometheus
from diagrams.onprem.network import Nginx
from diagrams.onprem.queue import Kafka
# ============================================================================ #
# Edge is an object representing a connection between Nodes with some additional properties
#
# An edge object contains three attributes: label, color and style which mirror corresponding graphviz edge attributes
# pylint: disable=W0106
with Diagram(name="Advanced Web Services Open Source",
show=not bool(os.environ.get('CI', 0)),
filename='images/advanced_web_services_open_source',
):
nginx = Nginx("Nginx Ingress")
metrics = Prometheus("Promtheus metrics")
metrics << Edge(color="firebrick", style="dashed") << Grafana("Grafana monitoring")
with Cluster("Service Cluster"):
grpcsvc = [
Server("grpc1"),
Server("grpc2"),
Server("grpc3")]
with Cluster("Redis Sessions HA"):
primary = Redis("session")
primary \
- Edge(color="brown", style="dashed") \
- Redis("replica") \
<< Edge(label="collect") \
<< metrics
grpcsvc >> Edge(color="brown") >> primary
with Cluster("PostgreSQL Database HA"):
primary = PostgreSQL("users")
primary \
- Edge(color="brown", style="dotted") \
- PostgreSQL("replica") \
<< Edge(label="collect") \
<< metrics
grpcsvc >> Edge(color="black") >> primary
aggregator = Fluentd("Fluentd logging")
aggregator \
>> Edge(label="parse") \
>> Kafka("Kafka pub/sub stream") \
>> Edge(color="black", style="bold") \
>> Spark("analytics")
nginx \
>> Edge(color="darkgreen") \
<< grpcsvc \
>> Edge(color="darkorange") \
>> aggregator