docs: move diagrams to Mermaid

This commit is contained in:
Khue Doan 2022-05-04 00:45:18 +07:00
parent 132cd58c90
commit 3cedb11ffb
6 changed files with 59 additions and 57 deletions

1
docs/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
mermaid*.js

View File

@ -2,16 +2,9 @@
default: book default: book
.PHONY: diagrams mermaid*.js:
diagrams: mdbook-mermaid install .
cd diagrams \
&& python3 -m venv .venv \
&& source .venv/bin/activate \
&& pip3 install -r requirements.txt \
&& python3 *.py
mkdir -p src/images
cp diagrams/*.png src/images/
.PHONY: book .PHONY: book
book: diagrams book: mermaid*.js
mdbook build . mdbook build .

View File

@ -5,7 +5,11 @@ multilingual = false
src = "src" src = "src"
title = "Khue's Homelab" title = "Khue's Homelab"
[preprocessor.mermaid]
command = "mdbook-mermaid"
[output.html] [output.html]
additional-js = ["mermaid.min.js", "mermaid-init.js"]
git-repository-url = "https://github.com/khuedoan/homelab" git-repository-url = "https://github.com/khuedoan/homelab"
edit-url-template = "https://github.com/khuedoan/homelab/edit/master/docs/{path}" edit-url-template = "https://github.com/khuedoan/homelab/edit/master/docs/{path}"

View File

@ -1,38 +0,0 @@
from diagrams import Cluster, Diagram
from diagrams.generic.os import LinuxGeneral
from diagrams.k8s.ecosystem import Helm
from diagrams.k8s.infra import Node
from diagrams.onprem.container import Docker
from diagrams.onprem.gitops import ArgoCD
graph_attr = {
"pad": "0"
}
with Diagram("Provisioning flow", graph_attr=graph_attr, outformat="png", show=False):
with Cluster("./metal"):
pxe = Docker("PXE server")
os = LinuxGeneral(f"Rocky Linux")
cluster = Node("K3s")
pxe >> os >> cluster
with Cluster("./bootstrap"):
argocd = ArgoCD("ArgoCD")
cluster >> argocd
with Cluster("./system"):
system_charts = Helm("System charts")
argocd >> system_charts
with Cluster("./platform"):
platform_charts = Helm("Platform charts")
argocd >> platform_charts
with Cluster("./apps"):
app_charts = Helm("Application charts")
argocd >> app_charts

View File

@ -1 +0,0 @@
diagrams

View File

@ -2,23 +2,66 @@
## Overview ## Overview
![Provisioning flow](../images/provisioning_flow.png)
Everything is automated, after you edit the configuration files, you just need to run a single `make` command and it will: Everything is automated, after you edit the configuration files, you just need to run a single `make` command and it will:
- Build the `./metal` layer: - (1) Build the `./metal` layer:
- Create an ephemeral, stateless PXE server - Create an ephemeral, stateless PXE server
- Install Linux on all servers in parallel - Install Linux on all servers in parallel
- Build a Kubernetes cluster (based on k3s) - Build a Kubernetes cluster (based on k3s)
- Build the `./bootstrap` layer: - (2) Build the `./bootstrap` layer:
- Install ArgoCD - Install ArgoCD
- Install ApplicationSet to manage other layers (and also manage itself) - Configure the root app to manage other layers (and also manage itself)
From now on, ArgoCD will do the rest: From now on, ArgoCD will do the rest:
- Build the `./system` layer (storage, networking, monitoring, etc) - (3) Build the `./system` layer (storage, networking, monitoring, etc)
- Build the `./platform` layer (Gitea, Vault, SSO, etc) - (4) Build the `./platform` layer (Gitea, Vault, SSO, etc)
- Build the `./apps` layer: (Syncthing, Jellyfin, etc) - (5) Build the `./apps` layer: (Syncthing, Jellyfin, etc)
```mermaid
flowchart TD
subgraph metal
RockyLinux --> k3s
end
subgraph bootstrap
ArgoCD --> RootApp
end
subgraph system
MetalLB
NGINX
Longhorn
cert-manager
ExternalDNS
CloudflareTunnel
end
subgraph external
LetsEncrypt
Cloudflare
end
LetsEncrypt -.-> cert-manager
Cloudflare -.-> cert-manager
Cloudflare -.-> ExternalDNS
Cloudflare -.-> CloudflareTunnel
subgraph platform
Gitea
Tekton
Vault
end
subgraph apps
Jellyfin
Matrix
Paperless
Seafile
end
Hardware -- 1 --> metal -- 2 --> bootstrap -. 3 .-> system -. 4 .-> platform -. 5 .-> apps
```
## Detailed steps ## Detailed steps