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
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:
I also have an introduction to PlantUML here
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
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
Category | Macro (Name) | Mono |
Url | |
---|---|---|---|---|
OSS | OSS/all.puml | |||
OSS | KubernetesCronjob (Kubernetes Cronjob) | OSS/KubernetesCronjob.puml | ||
OSS | KubernetesGroup (Kubernetes Group) | OSS/KubernetesGroup.puml | ||
OSS | KubernetesPsp (Kubernetes Psp) | OSS/KubernetesPsp.puml | ||
OSS | KubernetesRole (Kubernetes Role) | OSS/KubernetesRole.puml | ||
OSS | KubernetesApi (Kubernetes Api) | OSS/KubernetesApi.puml | ||
OSS | KubernetesJob (Kubernetes Job) | OSS/KubernetesJob.puml | ||
OSS | KubernetesCm (Kubernetes Cm) | OSS/KubernetesCm.puml | ||
OSS | KubernetesMaster (Kubernetes Master) | OSS/KubernetesMaster.puml | ||
OSS | KubernetesKproxy (Kubernetes Kproxy) | OSS/KubernetesKproxy.puml | ||
OSS | KubernetesCrd (Kubernetes Crd) | OSS/KubernetesCrd.puml | ||
OSS | KubernetesDs (Kubernetes Ds) | OSS/KubernetesDs.puml | ||
OSS | KubernetesSc (Kubernetes Sc) | OSS/KubernetesSc.puml | ||
OSS | KubernetesCrb (Kubernetes Crb) | OSS/KubernetesCrb.puml | ||
OSS | KubernetesSched (Kubernetes Sched) | OSS/KubernetesSched.puml | ||
OSS | KubernetesLimits (Kubernetes Limits) | OSS/KubernetesLimits.puml | ||
OSS | KubernetesQuota (Kubernetes Quota) | OSS/KubernetesQuota.puml | ||
OSS | KubernetesVol (Kubernetes Vol) | OSS/KubernetesVol.puml | ||
OSS | KubernetesSa (Kubernetes Sa) | OSS/KubernetesSa.puml | ||
OSS | KubernetesKubelet (Kubernetes Kubelet) | OSS/KubernetesKubelet.puml | ||
OSS | KubernetesPvc (Kubernetes Pvc) | OSS/KubernetesPvc.puml | ||
OSS | KubernetesCcm (Kubernetes Ccm) | OSS/KubernetesCcm.puml | ||
OSS | KubernetesSts (Kubernetes Sts) | OSS/KubernetesSts.puml | ||
OSS | KubernetesNetpol (Kubernetes Netpol) | OSS/KubernetesNetpol.puml | ||
OSS | KubernetesCrole (Kubernetes Crole) | OSS/KubernetesCrole.puml | ||
OSS | KubernetesRs (Kubernetes Rs) | OSS/KubernetesRs.puml | ||
OSS | KubernetesNode (Kubernetes Node) | OSS/KubernetesNode.puml | ||
OSS | KubernetesSecret (Kubernetes Secret) | OSS/KubernetesSecret.puml | ||
OSS | KubernetesNs (Kubernetes Ns) | OSS/KubernetesNs.puml | ||
OSS | KubernetesDeploy (Kubernetes Deploy) | OSS/KubernetesDeploy.puml | ||
OSS | KubernetesUser (Kubernetes User) | OSS/KubernetesUser.puml | ||
OSS | KubernetesPv (Kubernetes Pv) | OSS/KubernetesPv.puml | ||
OSS | KubernetesEp (Kubernetes Ep) | OSS/KubernetesEp.puml | ||
OSS | KubernetesSvc (Kubernetes Svc) | OSS/KubernetesSvc.puml | ||
OSS | KubernetesRb (Kubernetes Rb) | OSS/KubernetesRb.puml | ||
OSS | KubernetesEtcd (Kubernetes Etcd) | OSS/KubernetesEtcd.puml | ||
OSS | KubernetesIng (Kubernetes Ing) | OSS/KubernetesIng.puml | ||
OSS | KubernetesHpa (Kubernetes Hpa) | OSS/KubernetesHpa.puml |
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.
None of the work here would be possible without the foundation from Ricardo Niepel, PlantUML and the C4 Model