diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 00000000..7db56a78 --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1 @@ +mermaid*.js diff --git a/docs/Makefile b/docs/Makefile index 02dd9596..e841dc81 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -2,16 +2,9 @@ default: book -.PHONY: diagrams -diagrams: - 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/ +mermaid*.js: + mdbook-mermaid install . .PHONY: book -book: diagrams +book: mermaid*.js mdbook build . diff --git a/docs/book.toml b/docs/book.toml index 6802f1e7..b92d7ab1 100644 --- a/docs/book.toml +++ b/docs/book.toml @@ -5,7 +5,11 @@ multilingual = false src = "src" title = "Khue's Homelab" +[preprocessor.mermaid] +command = "mdbook-mermaid" + [output.html] +additional-js = ["mermaid.min.js", "mermaid-init.js"] git-repository-url = "https://github.com/khuedoan/homelab" edit-url-template = "https://github.com/khuedoan/homelab/edit/master/docs/{path}" diff --git a/docs/diagrams/provisioning_flow.py b/docs/diagrams/provisioning_flow.py deleted file mode 100644 index 9a3438ee..00000000 --- a/docs/diagrams/provisioning_flow.py +++ /dev/null @@ -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 diff --git a/docs/diagrams/requirements.txt b/docs/diagrams/requirements.txt deleted file mode 100644 index ec562f21..00000000 --- a/docs/diagrams/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -diagrams diff --git a/docs/src/deployment/provisioning-flow.md b/docs/src/deployment/provisioning-flow.md index e518c1b3..05ef55a4 100644 --- a/docs/src/deployment/provisioning-flow.md +++ b/docs/src/deployment/provisioning-flow.md @@ -2,23 +2,66 @@ ## 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: -- Build the `./metal` layer: +- (1) Build the `./metal` layer: - Create an ephemeral, stateless PXE server - Install Linux on all servers in parallel - Build a Kubernetes cluster (based on k3s) -- Build the `./bootstrap` layer: +- (2) Build the `./bootstrap` layer: - 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: -- Build the `./system` layer (storage, networking, monitoring, etc) -- Build the `./platform` layer (Gitea, Vault, SSO, etc) -- Build the `./apps` layer: (Syncthing, Jellyfin, etc) +- (3) Build the `./system` layer (storage, networking, monitoring, etc) +- (4) Build the `./platform` layer (Gitea, Vault, SSO, 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