kubernetes_icon) with Cluster("K8s Destroying Pipeline"): destroyServersStage = Custom("Destroy Servers", terraform_icon) with Cluster("Hetzner Cloud"): with Cluster("WireGuard VPN"): with Cluster("Kubernetes Cluster"): masterNodes = Master("N masters") workerNodes = Node("N workers") with Cluster("System Application"): argoCd = Argocd("Argo CD") sealedSecrets = Custom("Sealed Secrets", bitnami_icon) metallb = Custom("Metal LB", metallb_icon) certManager = Custom("Cert Manager", cert_manager_icon) istio = Istio("Istio") storage = StorageClass("HCloud CSI") loki = Custom("Loki", loki_icon) createServersStage >> deployClusterStage >> deployComponentsStage createServersStage >> masterNodes deployClusterStage >> masterNodes deployComponentsStage >> argoCd deployComponentsStage >> sealedSecrets deployClusterStage >> metallb masterNodes - workerNodes createServersStage >> cloudFlare createServersStage >> wasabi destroyServersStage >> cloudFlare destroyServersStage >> wasabi destroyServersStage >> masterNodes
# 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
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 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")
from diagrams import Cluster, Diagram, Edge from diagrams.k8s.compute import Pod, DaemonSet from diagrams.k8s.storage import PV, PVC, StorageClass with Diagram("Persistent Storage with replica for a Pod", show=False): with Cluster("k8s"): pod = Pod("d2") pvc = PVC("pvc-2") pv1 = PV("pvc-[uuid] (primary)") pv2 = PV("pvc-[uuid] (replica)") sc = StorageClass("storageos-rep-1") ds = DaemonSet("StorageOS") pod >> pvc pvc << pv1 << sc pvc - Edge(color="red", style="dotted") - pv2 pv2 - Edge(color="brown", style="dotted") - sc sc >> ds
pgpool_replica_set_count = 1 pgpool_pods = [ Pod("Pgpool Pod") for pod in range(0, pgpool_replica_set_count, 1) ] pgpool_svc = Service("Pgpool Service") # Relationships pgpool_dep >> pgpool_rs >> pgpool_pods << pgpool_svc # PostgreSQL # Resources db_sset = StatefulSet("PostgreSQL StatefulSet") db_stateful_set_count = 3 db_svc = Service("DB Service") sc = StorageClass("Storage Class (SSD)") db_pods = [] for _ in range(db_stateful_set_count): db_pod = Pod("DB Pod") db_pvc = PersistentVolumeClaim("DB PVC") db_pv = PersistentVolume("DB PV") # Relationships sc << db_pv << db_pvc << db_pod >> db_sset db_pods.append(db_pod << db_svc) # Relationships app_pods << app_svc_int << app_lb_int << app_fw # app_pods >> pgpool_svc # Not rendered since the diagram is busy enough with Diagram("TRM Exercise Overview", show=False):