Mermaid code
flowchart TD
C[Client] --> I[Ingress<br/>api.example.com]
subgraph NS["Namespace: shop"]
I --> S[Service<br/>ClusterIP :80]
subgraph DEP["Deployment: api (3 replicas)"]
P1[Pod api-1]
P2[Pod api-2]
P3[Pod api-3]
end
S --> P1
S --> P2
S --> P3
CM[ConfigMap<br/>app settings] -.-> P1
SEC[Secret<br/>database credentials] -.-> P1
P1 --> PV[(PersistentVolume<br/>uploads)]
end Paste this into any tool that renders Mermaid, or into the editor to change the theme and export PNG or SVG. Syntax reference: Flowchart guide.
What this diagram shows
Follow the request from Client to the Ingress, into the Namespace: shop subgraph, through the Service to one of three pods inside the Deployment subgraph. Dotted edges from ConfigMap and Secret show configuration mounted into the pods, and the cylinder PersistentVolume holds uploaded files. Only Pod api-1 is wired to the mounts to keep the picture readable; the other two are identical.
Nested subgraphs are what make this a flowchart job. They map directly onto the namespace and deployment boundaries that Kubernetes itself uses.
How to adapt it
- Rename
Namespace: shopandDeployment: apito your real namespace and workload names. - Add a second deployment subgraph, for example a worker, and connect it to a
Queuenode instead of the service. - Replace
Service<br/>ClusterIP :80withService<br/>LoadBalancerif you expose the workload without an ingress. - Add a
HPA[HorizontalPodAutoscaler]node with a dotted edge into the deployment subgraph to show autoscaling. - Draw the
SecretandConfigMapedges to all three pods if you want to stress that every replica gets the same configuration.
FAQ
Why are the subgraph titles in quotes?
Because they contain a colon and parentheses. Mermaid treats unquoted colons and brackets as syntax; wrapping the title in double quotes after the id, as in subgraph NS["Namespace: shop"], avoids a parse error.
What do the dotted arrows mean?
The -.-> edge is a dotted link. Here it marks configuration that is mounted into the pod rather than request traffic, so readers can separate the data path from the configuration path.
Can I show which node each pod runs on?
Yes. Add a subgraph per node, for example subgraph N1[Node 1], and move the pod nodes inside. Keep the deployment subgraph if you still want to show the replica count, but nesting three levels gets crowded fast.