dcasati / Kubernetes Plantuml
Projects that are alternatives of or similar to Kubernetes Plantuml
Kubernetes-PlantUML
These are the PlantUML sprites, macros and stereotypes for creating PlantUML diagrams with the Kubernetes components. The official Kubernetes Icons Set (where this work is based) can be found here
This repo is heavily influenced by the awesome work from Ricardo Niepel on Azure-PlantUML
Table of Contents
Getting Started
TL;DR - If you're familiar with PlantUML this is what you need:
' Kubernetes
!define KubernetesPuml https://raw.githubusercontent.com/dcasati/kubernetes-PlantUML/master/dist
' global definition
!includeurl KubernetesPuml/kubernetes_Common.puml
!includeurl KubernetesPuml/kubernetes_Context.puml
!includeurl KubernetesPuml/kubernetes_Simplified.puml
' k8s specific components
!includeurl KubernetesPuml/OSS/KubernetesPod.puml
!includeurl KubernetesPuml/OSS/KubernetesPsp.puml
!includeurl KubernetesPuml/OSS/KubernetesPv.puml
!includeurl KubernetesPuml/OSS/KubernetesPvc.puml
[...]
If you're starting with PlantUML, here's what you need:
- VS Code with the PlantUML extension
- Graphviz
- Copy one of the examples from: https://github.com/dcasati/kubernetes-PlantUML/tree/master/samples
I also have an introduction to PlantUML here
Examples
A basic hello world
example could look like this:
This picture was rendered with the following code:
@startuml kubernetes
footer Kubernetes Plant-UML
scale max 1024 width
skinparam nodesep 10
skinparam ranksep 10
' Kubernetes
!define KubernetesPuml https://raw.githubusercontent.com/dcasati/kubernetes-PlantUML/master/dist
!includeurl KubernetesPuml/kubernetes_Common.puml
!includeurl KubernetesPuml/kubernetes_Context.puml
!includeurl KubernetesPuml/kubernetes_Simplified.puml
!includeurl KubernetesPuml/OSS/KubernetesSvc.puml
!includeurl KubernetesPuml/OSS/KubernetesPod.puml
actor "User" as userAlias
left to right direction
' Kubernetes Components
Cluster_Boundary(cluster, "Kubernetes Cluster") {
Namespace_Boundary(ns, "Web") {
KubernetesSvc(svc, "service", "")
KubernetesPod(pod1, "web-pod1", "")
KubernetesPod(pod2, "web-pod2", "")
}
}
Rel(userAlias,svc,"get HTTP/1.1 index.html", "1")
Rel(svc,pod1,"load Balances to Pods", "2")
Rel(svc,pod2,"load Balances to Pods", "2")
Rel_U(pod1, svc, "serves content", "3")
Rel(svc, userAlias, "return content to", "4")
@enduml
A more complete example would look like this picture:
and the accompaining code:
@startuml kubernetes
footer Kubernetes Plant-UML
scale max 1024 width
skinparam nodesep 10
skinparam ranksep 10
' Kubernetes
!define KubernetesPuml https://raw.githubusercontent.com/dcasati/kubernetes-PlantUML/master/dist
!includeurl KubernetesPuml/kubernetes_Common.puml
!includeurl KubernetesPuml/kubernetes_Context.puml
!includeurl KubernetesPuml/kubernetes_Simplified.puml
!includeurl KubernetesPuml/OSS/KubernetesSvc.puml
!includeurl KubernetesPuml/OSS/KubernetesIng.puml
!includeurl KubernetesPuml/OSS/KubernetesPod.puml
!includeurl KubernetesPuml/OSS/KubernetesRs.puml
!includeurl KubernetesPuml/OSS/KubernetesDeploy.puml
!includeurl KubernetesPuml/OSS/KubernetesHpa.puml
actor "User" as userAlias
left to right direction
' Kubernetes Components
Cluster_Boundary(cluster, "Kubernetes Cluster") {
Namespace_Boundary(ns, "Back End") {
KubernetesIng(ingress, "your.domain.com", "")
KubernetesSvc(svc, "service", "")
KubernetesPod(pod1, "pod1", "")
KubernetesPod(pod2, "pod2", "")
KubernetesPod(pod3, "pod3", "")
KubernetesRs(rs,"","")
KubernetesDeploy(deploy,"deployment","")
KubernetesHpa(hpa, "HPA", "")
}
}
Rel(userAlias,ingress," ")
Rel(ingress,svc," ")
Rel(svc,pod1," ")
Rel(svc,pod2," ")
Rel(svc,pod3," ")
Rel_U(rs,pod1," ")
Rel_U(rs,pod2," ")
Rel_U(rs,pod3," ")
Rel_U(deploy,rs, " ")
Rel_U(hpa,deploy, " ")
@enduml
Using kubernetes-PlantUML with other PlantUML files
You can certainly mix and match the stencils from kubernetes-PlantUML with other PlantUML files. For instance, here is an example of using it with the Azure-PlantUML files to ilustrate this reference architecture
The equivalent of that in PlantUML would look like this:
@startuml kubernetes
footer Kubernetes Plant-UML
scale max 1024 width
skinparam nodesep 10
skinparam ranksep 10
' Azure
!define AzurePuml https://raw.githubusercontent.com/RicardoNiepel/Azure-PlantUML/release/2-1/dist
!includeurl AzurePuml/AzureCommon.puml
!includeurl AzurePuml/AzureSimplified.puml
!includeurl AzurePuml/Containers/AzureContainerRegistry.puml
!includeurl AzurePuml/Databases/AzureCosmosDb.puml
!includeurl AzurePuml/Databases/AzureSqlDatabase.puml
!includeurl AzurePuml/DevOps/AzurePipelines.puml
!includeurl AzurePuml/Identity/AzureActiveDirectory.puml
!includeurl AzurePuml/Networking/AzureLoadBalancer.puml
!includeurl AzurePuml/Security/AzureKeyVault.puml
' Kubernetes
!define KubernetesPuml https://raw.githubusercontent.com/dcasati/kubernetes-PlantUML/master/dist
!includeurl KubernetesPuml/kubernetes_Common.puml
!includeurl KubernetesPuml/kubernetes_Context.puml
!includeurl KubernetesPuml/kubernetes_Simplified.puml
!includeurl KubernetesPuml/OSS/KubernetesApi.puml
!includeurl KubernetesPuml/OSS/KubernetesIng.puml
!includeurl KubernetesPuml/OSS/KubernetesPod.puml
actor "DevOps" as devopsAlias
collections "Client Apps" as clientalias
collections "Helm Charts" as helmalias
left to right direction
' Azure Components
AzureActiveDirectory(aad, "\nAzure\nActive Directory", "Global")
AzureContainerRegistry(acr, "ACR", "Canada Central")
AzureCosmosDb(cosmos, "\nCosmos DB", "Global")
AzureKeyVault(keyvault, "\nAzure\nKey Vault", "Global")
AzureLoadBalancer(alb, "\nLoad\nBalancer", "Canada Central")
AzureSqlDatabase(sql, "\nExternal\ndata stores", "Canada Central")
AzurePipelines(ado, "CI/CD\nAzure Pipelines", "Global")
' Kubernetes Components
Cluster_Boundary(cluster, "Kubernetes Cluster") {
KubernetesApi(KubernetesApi, "Kubernetes API", "")
Namespace_Boundary(nsFrontEnd, "Front End") {
KubernetesIng(ingress, "API Gateway", "")
}
Namespace_Boundary(nsBackEnd, "Back End") {
KubernetesPod(KubernetesBE1, "", "")
KubernetesPod(KubernetesBE2, "", "")
KubernetesPod(KubernetesBE3, "", "")
}
Namespace_Boundary(nsUtil, "Utiliy Services") {
KubernetesPod(KubernetesUtil1, "", "")
KubernetesPod(KubernetesUtil2, "","")
}
}
Rel(devopsAlias, aad, "AUTH")
Rel(helmalias, KubernetesApi, "helm upgrade")
Rel(aad, keyvault, " ")
Rel(KubernetesApi, aad, "RBAC", "ASYNC")
Rel(clientalias, alb, "HTTP", "ASYNC")
Rel(alb, ingress, "HTTP", "ASYNC")
Rel(ingress, KubernetesBE1, " ")
Rel(KubernetesBE1, KubernetesBE2, " ")
Rel(KubernetesBE1, KubernetesBE3, " ")
Rel(KubernetesBE2, sql, " ")
Rel(KubernetesBE3, keyvault, "Pod Identity")
Rel(KubernetesBE3, cosmos, " ")
Rel(ado, acr, "docker push")
Rel_U(KubernetesApi, acr, "docker pull")
@enduml
List of Supported Symbols
Contributing
I've built this on a necessity that I have for making better diagrams when Kubernetes is part of the solution. This is based on a community effort and as such this should belong to the Kubernetes community. Feel free to fork and to submit PRs.
Reference
None of the work here would be possible without the foundation from Ricardo Niepel, PlantUML and the C4 Model
- Ricardo Niepel - Azure-PlantUML
- C4 Model - https://c4model.com