Skip to content

Commit

Permalink
feat: support k8s diagrams
Browse files Browse the repository at this point in the history
  • Loading branch information
mingrammer committed Feb 6, 2020
1 parent 994db50 commit 3eda1cb
Show file tree
Hide file tree
Showing 58 changed files with 419 additions and 8 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

**Diagram as Code**.

Diagrams lets you draw the cloud system architecture **in Python code**. It was born for **prototyping** a new system architecture design without any design tools. You can also describe or visualize the existing system architecture as well. Diagrams currently supports three major cloud providers: `AWS`, `Azure`, `GCP`.
Diagrams lets you draw the cloud system architecture **in Python code**. It was born for **prototyping** a new system architecture design without any design tools. You can also describe or visualize the existing system architecture as well. Diagrams currently supports four major providers: `AWS`, `Azure`, `GCP` and `Kubernetes`.

**Diagram as Code** also allows you to **tracking** the architecture diagram changes on any **version control** system.

Expand All @@ -31,9 +31,11 @@ You can start with [quick start](https://diagrams.mingrammer.com/docs/installati

## Examples

| Grouped Workers | Clustered Web Services | Event Processing |
| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| ![grouped workers](https://diagrams.mingrammer.com/img/grouped_workers_diagram.png) | ![clustered web services](https://diagrams.mingrammer.com/img/clustered_web_services_diagram.png) | ![event processing](https://diagrams.mingrammer.com/img/event_processing_diagram.png) |
| Grouped Workers | Clustered Web Services |
| ------------------------------------------------------------ | ------------------------------------------------------------ |
| ![grouped workers](https://diagrams.mingrammer.com/img/grouped_workers_diagram.png) | ![clustered web services](https://diagrams.mingrammer.com/img/clustered_web_services_diagram.png) |
| **Event Processing** | **Stateful Architecture** |
| ![event processing](https://diagrams.mingrammer.com/img/event_processing_diagram.png) | ![stateful architecture](https://diagrams.mingrammer.com/img/stateful_architecture_diagram.png) |

You can find all the examples on the [examples](https://diagrams.mingrammer.com/docs/examples) page.

Expand Down
2 changes: 1 addition & 1 deletion autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
app_root_dir="diagrams"

# NOTE: azure icon set is not latest version
providers=("aws" "azure" "gcp")
providers=("aws" "azure" "gcp" "k8s")

if ! [ -x "$(command -v round)" ]; then
echo 'round is not installed'
Expand Down
50 changes: 48 additions & 2 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
DIR_RESOURCE = "resources"
DIR_TEMPLATE = "templates"

PROVIDERS = ("base", "aws", "azure", "gcp")
PROVIDERS = ("base", "aws", "azure", "gcp", "k8s")

#########################
# Resource Processing #
Expand All @@ -24,7 +24,8 @@
FILE_PREFIXES = {
"aws": ("amazon-", "aws-"),
"azure": ("azure-",),
"gcp": ("cloud-",)
"gcp": ("cloud-",),
"k8s": (),
}

#########################
Expand All @@ -37,6 +38,9 @@
"aws": ("aws", "api", "ebs", "ec2", "efs", "emr", "rds", "ml", "mq", "vpc", "waf"),
"azure": ("ad", "b2c", "ai", "api", "cdn", "ddos", "dns", "fxt", "hana", "hd", "id", "sap", "sql", "vm"),
"gcp": ("gcp", "ai", "api", "cdn", "dns", "gke", "gpu", "ml", "nat", "os", "sdk", "sql", "tpu", "vpn"),
"k8s": (
"api", "cm", "ccm", "crb", "crd", "ds", "etcd", "hpa", "ns", "psp", "pv", "pvc", "rb", "rs", "sa", "sc", "sts",
"svc"),
}

# TODO: check if the classname exists
Expand Down Expand Up @@ -145,4 +149,46 @@
"Storage": "GCS",
},
},
"k8s": {
"clusterconfig": {
"Limits": "LimitRange",
"HPA": "HorizontalPodAutoscaler",
},
"compute": {
"Deploy": "Deployment",
"DS": "DaemonSet",
"RS": "ReplicaSet",
"STS": "StatefulSet"
},
"controlplane": {
"API": "APIServer",
"CM": "ControllerManager",
"KProxy": "KubeProxy",
"Sched": "Scheduler",
},
"group": {
"NS": "Namespace",
},
"network": {
"Ep": "Endpoint",
"Ing": "Ingress",
"Netpol": "NetworkPolicy",
"SVC": "Service",
},
"podconfig": {
"CM": "ConfigMap",
},
"rbac": {
"CRole": "ClusterRole",
"CRB": "ClusterRoleBinding",
"RB": "RoleBinding",
"SA": "ServiceAccount",
},
"storage": {
"PV": "PersistnetVolume",
"PVC": "PersistentVolumeClaim",
"SC": "StorageClass",
"Vol": "Volume",
},
}
}
12 changes: 12 additions & 0 deletions diagrams/k8s/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""
K8S provides a set of services for Kubernetes.
"""

from diagrams import Node


class _K8S(Node):
_provider = "k8s"
_icon_dir = "resources/k8s"

fontcolor = "#2d3436"
26 changes: 26 additions & 0 deletions diagrams/k8s/clusterconfig.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This module is automatically generated by autogen.sh. DO NOT EDIT.

from . import _K8S


class _Clusterconfig(_K8S):
_type = "clusterconfig"
_icon_dir = "resources/k8s/clusterconfig"


class HPA(_Clusterconfig):
_icon = "hpa.png"


class Limits(_Clusterconfig):
_icon = "limits.png"


class Quota(_Clusterconfig):
_icon = "quota.png"


# Aliases

LimitRange = Limits
HorizontalPodAutoscaler = HPA
44 changes: 44 additions & 0 deletions diagrams/k8s/compute.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# This module is automatically generated by autogen.sh. DO NOT EDIT.

from . import _K8S


class _Compute(_K8S):
_type = "compute"
_icon_dir = "resources/k8s/compute"


class Cronjob(_Compute):
_icon = "cronjob.png"


class Deploy(_Compute):
_icon = "deploy.png"


class DS(_Compute):
_icon = "ds.png"


class Job(_Compute):
_icon = "job.png"


class Pod(_Compute):
_icon = "pod.png"


class RS(_Compute):
_icon = "rs.png"


class STS(_Compute):
_icon = "sts.png"


# Aliases

Deployment = Deploy
DaemonSet = DS
ReplicaSet = RS
StatefulSet = STS
40 changes: 40 additions & 0 deletions diagrams/k8s/controlplane.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This module is automatically generated by autogen.sh. DO NOT EDIT.

from . import _K8S


class _Controlplane(_K8S):
_type = "controlplane"
_icon_dir = "resources/k8s/controlplane"


class API(_Controlplane):
_icon = "api.png"


class CCM(_Controlplane):
_icon = "c-c-m.png"


class CM(_Controlplane):
_icon = "c-m.png"


class KProxy(_Controlplane):
_icon = "k-proxy.png"


class Kubelet(_Controlplane):
_icon = "kubelet.png"


class Sched(_Controlplane):
_icon = "sched.png"


# Aliases

APIServer = API
ControllerManager = CM
KubeProxy = KProxy
Scheduler = Sched
17 changes: 17 additions & 0 deletions diagrams/k8s/group.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This module is automatically generated by autogen.sh. DO NOT EDIT.

from . import _K8S


class _Group(_K8S):
_type = "group"
_icon_dir = "resources/k8s/group"


class NS(_Group):
_icon = "ns.png"


# Aliases

Namespace = NS
23 changes: 23 additions & 0 deletions diagrams/k8s/infra.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# This module is automatically generated by autogen.sh. DO NOT EDIT.

from . import _K8S


class _Infra(_K8S):
_type = "infra"
_icon_dir = "resources/k8s/infra"


class ETCD(_Infra):
_icon = "etcd.png"


class Master(_Infra):
_icon = "master.png"


class Node(_Infra):
_icon = "node.png"


# Aliases
32 changes: 32 additions & 0 deletions diagrams/k8s/network.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This module is automatically generated by autogen.sh. DO NOT EDIT.

from . import _K8S


class _Network(_K8S):
_type = "network"
_icon_dir = "resources/k8s/network"


class Ep(_Network):
_icon = "ep.png"


class Ing(_Network):
_icon = "ing.png"


class Netpol(_Network):
_icon = "netpol.png"


class SVC(_Network):
_icon = "svc.png"


# Aliases

Endpoint = Ep
Ingress = Ing
NetworkPolicy = Netpol
Service = SVC
19 changes: 19 additions & 0 deletions diagrams/k8s/others.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This module is automatically generated by autogen.sh. DO NOT EDIT.

from . import _K8S


class _Others(_K8S):
_type = "others"
_icon_dir = "resources/k8s/others"


class CRD(_Others):
_icon = "crd.png"


class PSP(_Others):
_icon = "psp.png"


# Aliases
21 changes: 21 additions & 0 deletions diagrams/k8s/podconfig.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# This module is automatically generated by autogen.sh. DO NOT EDIT.

from . import _K8S


class _Podconfig(_K8S):
_type = "podconfig"
_icon_dir = "resources/k8s/podconfig"


class CM(_Podconfig):
_icon = "cm.png"


class Secret(_Podconfig):
_icon = "secret.png"


# Aliases

ConfigMap = CM
44 changes: 44 additions & 0 deletions diagrams/k8s/rbac.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# This module is automatically generated by autogen.sh. DO NOT EDIT.

from . import _K8S


class _Rbac(_K8S):
_type = "rbac"
_icon_dir = "resources/k8s/rbac"


class CRole(_Rbac):
_icon = "c-role.png"


class CRB(_Rbac):
_icon = "crb.png"


class Group(_Rbac):
_icon = "group.png"


class RB(_Rbac):
_icon = "rb.png"


class Role(_Rbac):
_icon = "role.png"


class SA(_Rbac):
_icon = "sa.png"


class User(_Rbac):
_icon = "user.png"


# Aliases

ClusterRole = CRole
ClusterRoleBinding = CRB
RoleBinding = RB
ServiceAccount = SA
Loading

0 comments on commit 3eda1cb

Please sign in to comment.