# yasos-lab/lab-deploy architecture

> Architecture diagram of the GitHub repository yasos-lab/lab-deploy, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yasos-lab/lab-deploy
- Repository: https://github.com/yasos-lab/lab-deploy

## Overview

#### Purpose and Execution Model
This is an Ansible-based homelab infrastructure repository. It converges physical/VM hosts over SSH into role-specific states: Proxmox, network appliances, Docker service hosts, Kubernetes nodes, a Jellyfin server, and controller workstations. Primary operator entry points are `bootstrap.sh` and top-level playbooks such as `deploy-docker-node.yml`, `deploy-kubernetes.yml`, and `config-network.yml`.

#### Inventory, Targeting, and Secrets
`inventories/hosts.yml` defines host groups and nested Kubernetes control-plane/worker groups. Group and host variables provide the desired-state inputs, with shared Docker and monitoring values in `inventories/group_vars/all/docker.yml` and `inventories/group_vars/all/monitoring.yml`; per-host service choices live in `inventories/host_vars/docker_node/containers.yml`. Sensitive values are isolated in Vault-encrypted `inventories/group_vars/all/secrets.yml`, requiring a local vault password file at execution time.

#### Shared Host Baseline
Reusable task units establish common host capabilities before specialized services: packages/repositories, filesystems, service management, shell configuration, monitoring, backup, and remote storage mounts. The core implementation is under `tasks/common/packages.yml`, `tasks/common/filesystem.yml`, and `tasks/common/monitoring.yml`. This is the principal boundary between generic Linux host provisioning and workload-specific deployment.

#### Docker Application Platform
Docker hosts are configured through `tasks/docker/docker.yml` and `tasks/docker/services.yml`, then rendered into ordered Compose application domains. The domains include network/identity ingress, core services, monitoring, cloud, media, automation, and AI, represented by templates such as `templates/docker/00-network/docker-compose.yml.j2`, `templates/docker/02-monitoring/docker-compose.yml.j2`, and `templates/docker/04-media/docker-compose.yml.j2`. Traefik and Authelia configuration form the ingress/authentication edge in `templates/docker/00-network/config/traefik/traefik.yml.j2` and `templates/docker/00-network/config/authelia/configuration.yml.j2`.

#### Kubernetes Cluster Bootstrap
Kubernetes is an ordered, staged deployment rather than a generic role: system preparation, packages, filesystem, virtual IP, kubeadm initialization, Cilium CNI, node joining, and verification. Stages are explicitly encoded in `tasks/k8s/01-system.yml`, `tasks/k8s/05-kubeadm-init.yml`, and `tasks/k8s/08-verify-cluster.yml`. Control-plane-specific and worker-specific inputs are separated in `inventories/group_vars/k8s_controlplanes/main.yml` and `inventories/group_vars/k8s_workers/main.yml`; containerd and kube-vip manifests are rendered from `templates/k8s/containerd/config.toml.j2` and `templates/k8s/manifests/kube-vip.yml.j2`.

#### Network and Edge Services
Network-targeted playbooks configure router-like hosts with DNS filtering/resolution, VPN, reverse proxying, and high availability. Task boundaries are `tasks/network/pihole.yml`, `tasks/network/unbound.yml`, `tasks/network/pivpn.yml`, `tasks/network/caddy.yml`, and `tasks/network/keepalived.yml`. Their rendered configurations—particularly `templates/network/caddy/Caddyfile.j2` and `templates/network/keepalived/keepalived.conf.j2`—depend on network group variables and create the edge between local clients, internal services, and external access.

#### Storage, Backup, and Observability Integrations
Hosts can mount remote storage through rclone and perform backups through Restic, implemented in `tasks/common/rclone.yml`, `tasks/common/restic.yml`, and associated systemd/script templates. Monitoring spans host-side agents and Dockerized Prometheus, Loki, Promtail, and Glance configuration, centered on `tasks/common/glance-agent.yml`, `templates/docker/02-monitoring/config/prometheus/prometheus.yml.j2`, and `templates/docker/02-monitoring/config/loki/loki-config.yml.j2`. Jellyfin is both a standalone node path and a media-platform workload, with common installation tasks in `tasks/common/jellyfin.yml`.

Main entry points: [`bootstrap.sh`](https://github.com/yasos-lab/lab-deploy/blob/main/bootstrap.sh) (Bootstrap & deploy playbooks), [`tasks/common/packages.yml`](https://github.com/yasos-lab/lab-deploy/blob/main/tasks/common/packages.yml) (Common host baseline), [`tasks/docker/docker.yml`](https://github.com/yasos-lab/lab-deploy/blob/main/tasks/docker/docker.yml) (Docker host setup), [`inventories/hosts.yml`](https://github.com/yasos-lab/lab-deploy/blob/main/inventories/hosts.yml) (Host inventory)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inputs["Inventory &amp; Desired State"]
  node_inventory["Host inventory<br/>Ansible inventory<br/>[hosts.yml]"]
  node_shared_vars["Shared service variables<br/>group variables<br/>[docker.yml]"]
  node_host_services["Docker host services<br/>host variables<br/>[containers.yml]"]
  node_vault["Vault secrets<br/>encrypted variables<br/>[secrets.yml]"]
end

subgraph group_automation["Ansible Automation"]
  node_entrypoints["Bootstrap &amp; deploy playbooks<br/>Ansible entry points<br/>[bootstrap.sh]"]
  node_common_baseline["Common host baseline<br/>shared task layer<br/>[packages.yml]"]
  node_storage_backup["Remote storage &amp; backup<br/>common task units<br/>[rclone.yml]"]
end

subgraph group_docker["Docker Platform"]
  node_docker_setup["Docker host setup<br/>Docker tasks<br/>[docker.yml]"]
  node_compose_domains["Compose application domains<br/>rendered Compose stacks"]
  node_ingress_auth["Traefik &amp; Authelia<br/>ingress and identity<br/>[traefik.yml.j2]"]
  node_docker_observability["Docker observability stack<br/>monitoring services<br/>[prometheus.yml.j2]"]
end

subgraph group_kubernetes["Kubernetes Bootstrap"]
  node_k8s_stage_system["Kubernetes system preparation<br/>bootstrap stage<br/>[01-system.yml]"]
  node_k8s_controlplane["Kubeadm control plane<br/>bootstrap stage"]
  node_k8s_nodes["CNI, VIP &amp; node joining<br/>cluster stages<br/>[kube-vip.yml.j2]"]
  node_k8s_verify["Cluster verification<br/>bootstrap stage"]
end

subgraph group_network["Network Edge"]
  node_network_services["Network services<br/>network task layer<br/>[pihole.yml]"]
  node_edge_proxy_ha["Caddy &amp; Keepalived<br/>edge configuration<br/>[Caddyfile.j2]"]
end

node_operator(("Operator<br/>human entry point"))
node_managed_hosts{{"Homelab hosts<br/>physical and VM targets"}}

node_operator -->|"runs"| node_entrypoints
node_entrypoints -->|"targets"| node_inventory
node_entrypoints -.->|"loads"| node_vault
node_inventory -->|"resolves variables"| node_shared_vars
node_inventory -->|"resolves host choices"| node_host_services
node_entrypoints -->|"applies"| node_common_baseline
node_common_baseline -->|"includes"| node_storage_backup
node_common_baseline -->|"precedes"| node_docker_setup
node_shared_vars -->|"configures"| node_docker_setup
node_host_services -->|"selects services"| node_docker_setup
node_docker_setup -->|"renders and deploys"| node_compose_domains
node_compose_domains -->|"includes network edge"| node_ingress_auth
node_compose_domains -->|"includes monitoring"| node_docker_observability
node_common_baseline -->|"precedes"| node_k8s_stage_system
node_k8s_stage_system -->|"prepares for"| node_k8s_controlplane
node_k8s_controlplane -->|"enables"| node_k8s_nodes
node_k8s_nodes -->|"completes"| node_k8s_verify
node_entrypoints -->|"applies"| node_network_services
node_network_services -->|"renders"| node_edge_proxy_ha
node_common_baseline -->|"converges"| node_managed_hosts
node_docker_setup -->|"configures Docker hosts"| node_managed_hosts
node_k8s_verify -->|"validates cluster nodes"| node_managed_hosts
node_network_services -->|"configures edge hosts"| node_managed_hosts
node_edge_proxy_ha -->|"routes external access"| node_ingress_auth

click node_entrypoints "https://github.com/yasos-lab/lab-deploy/blob/main/bootstrap.sh"
click node_inventory "https://github.com/yasos-lab/lab-deploy/blob/main/inventories/hosts.yml"
click node_shared_vars "https://github.com/yasos-lab/lab-deploy/blob/main/inventories/group_vars/all/docker.yml"
click node_host_services "https://github.com/yasos-lab/lab-deploy/blob/main/inventories/host_vars/docker_node/containers.yml"
click node_vault "https://github.com/yasos-lab/lab-deploy/blob/main/inventories/group_vars/all/secrets.yml"
click node_common_baseline "https://github.com/yasos-lab/lab-deploy/blob/main/tasks/common/packages.yml"
click node_storage_backup "https://github.com/yasos-lab/lab-deploy/blob/main/tasks/common/rclone.yml"
click node_docker_setup "https://github.com/yasos-lab/lab-deploy/blob/main/tasks/docker/docker.yml"
click node_compose_domains "https://github.com/yasos-lab/lab-deploy/blob/main/templates/docker/00-network/docker-compose.yml.j2"
click node_ingress_auth "https://github.com/yasos-lab/lab-deploy/blob/main/templates/docker/00-network/config/traefik/traefik.yml.j2"
click node_docker_observability "https://github.com/yasos-lab/lab-deploy/blob/main/templates/docker/02-monitoring/config/prometheus/prometheus.yml.j2"
click node_k8s_stage_system "https://github.com/yasos-lab/lab-deploy/blob/main/tasks/k8s/01-system.yml"
click node_k8s_controlplane "https://github.com/yasos-lab/lab-deploy/blob/main/tasks/k8s/05-kubeadm-init.yml"
click node_k8s_nodes "https://github.com/yasos-lab/lab-deploy/blob/main/templates/k8s/manifests/kube-vip.yml.j2"
click node_k8s_verify "https://github.com/yasos-lab/lab-deploy/blob/main/tasks/k8s/08-verify-cluster.yml"
click node_network_services "https://github.com/yasos-lab/lab-deploy/blob/main/tasks/network/pihole.yml"
click node_edge_proxy_ha "https://github.com/yasos-lab/lab-deploy/blob/main/templates/network/caddy/Caddyfile.j2"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_inventory,node_shared_vars,node_host_services,node_vault toneBlue
class node_entrypoints,node_common_baseline,node_storage_backup toneAmber
class node_docker_setup,node_compose_domains,node_ingress_auth,node_docker_observability toneMint
class node_k8s_stage_system,node_k8s_controlplane,node_k8s_nodes,node_k8s_verify toneRose
class node_network_services,node_edge_proxy_ha toneIndigo
class node_operator,node_managed_hosts toneNeutral
```

## Components

### Inventory & Desired State

- [Host inventory](https://github.com/yasos-lab/lab-deploy/blob/main/inventories/hosts.yml): Ansible inventory · Defines host groups and Kubernetes control-plane and worker targeting. · `inventories/hosts.yml`
- [Shared service variables](https://github.com/yasos-lab/lab-deploy/blob/main/inventories/group_vars/all/docker.yml): group variables · Supplies shared Docker and monitoring desired state. · `inventories/group_vars/all/docker.yml`
- [Docker host services](https://github.com/yasos-lab/lab-deploy/blob/main/inventories/host_vars/docker_node/containers.yml): host variables · Selects per-host container services. · `inventories/host_vars/docker_node/containers.yml`
- [Vault secrets](https://github.com/yasos-lab/lab-deploy/blob/main/inventories/group_vars/all/secrets.yml): encrypted variables · Requires a local vault password at runtime. · `inventories/group_vars/all/secrets.yml`

### Ansible Automation

- [Bootstrap & deploy playbooks](https://github.com/yasos-lab/lab-deploy/blob/main/bootstrap.sh): Ansible entry points · Bootstrap and role-specific playbooks drive convergence over SSH. · `bootstrap.sh`
- [Common host baseline](https://github.com/yasos-lab/lab-deploy/blob/main/tasks/common/packages.yml): shared task layer · Provisions packages, filesystems, monitoring, service management, backups, and mounts. · `tasks/common/packages.yml`
- [Remote storage & backup](https://github.com/yasos-lab/lab-deploy/blob/main/tasks/common/rclone.yml): common task units · Mounts remote storage and configures Restic backups. · `tasks/common/rclone.yml`

### Docker Platform

- [Docker host setup](https://github.com/yasos-lab/lab-deploy/blob/main/tasks/docker/docker.yml): Docker tasks · Installs Docker and deploys configured services. · `tasks/docker/docker.yml`
- [Compose application domains](https://github.com/yasos-lab/lab-deploy/blob/main/templates/docker/00-network/docker-compose.yml.j2): rendered Compose stacks · Ordered network, core, monitoring, cloud, media, automation, and AI domains. · `templates/docker/00-network/docker-compose.yml.j2`
- [Traefik & Authelia](https://github.com/yasos-lab/lab-deploy/blob/main/templates/docker/00-network/config/traefik/traefik.yml.j2): ingress and identity · Provides reverse proxying and authentication for Docker services. · `templates/docker/00-network/config/traefik/traefik.yml.j2`
- [Docker observability stack](https://github.com/yasos-lab/lab-deploy/blob/main/templates/docker/02-monitoring/config/prometheus/prometheus.yml.j2): monitoring services · Prometheus, Loki, Promtail, and Glance configuration. · `templates/docker/02-monitoring/config/prometheus/prometheus.yml.j2`

### Kubernetes Bootstrap

- [Kubernetes system preparation](https://github.com/yasos-lab/lab-deploy/blob/main/tasks/k8s/01-system.yml): bootstrap stage · Prepares nodes before cluster initialization. · `tasks/k8s/01-system.yml`
- [Kubeadm control plane](https://github.com/yasos-lab/lab-deploy/blob/main/tasks/k8s/05-kubeadm-init.yml): bootstrap stage · Initializes the cluster control plane. · `tasks/k8s/05-kubeadm-init.yml`
- [CNI, VIP & node joining](https://github.com/yasos-lab/lab-deploy/blob/main/templates/k8s/manifests/kube-vip.yml.j2): cluster stages · Renders containerd and kube-vip, installs Cilium, and joins nodes. · `templates/k8s/manifests/kube-vip.yml.j2`
- [Cluster verification](https://github.com/yasos-lab/lab-deploy/blob/main/tasks/k8s/08-verify-cluster.yml): bootstrap stage · `tasks/k8s/08-verify-cluster.yml`

### Network Edge

- [Network services](https://github.com/yasos-lab/lab-deploy/blob/main/tasks/network/pihole.yml): network task layer · Configures DNS filtering/resolution, VPN, reverse proxy, and HA. · `tasks/network/pihole.yml`
- [Caddy & Keepalived](https://github.com/yasos-lab/lab-deploy/blob/main/templates/network/caddy/Caddyfile.j2): edge configuration · Provides reverse proxying and high-availability virtual addressing. · `templates/network/caddy/Caddyfile.j2`

### Other components

- **Operator**: human entry point
- **Homelab hosts**: physical and VM targets · Proxmox, network appliances, Docker hosts, Kubernetes nodes, Jellyfin, and workstations.

## Connections

- Operator → Bootstrap & deploy playbooks: runs
- Bootstrap & deploy playbooks → Host inventory: targets
- Bootstrap & deploy playbooks → Vault secrets: loads
- Host inventory → Shared service variables: resolves variables
- Host inventory → Docker host services: resolves host choices
- Bootstrap & deploy playbooks → Common host baseline: applies
- Common host baseline → Remote storage & backup: includes
- Common host baseline → Docker host setup: precedes
- Shared service variables → Docker host setup: configures
- Docker host services → Docker host setup: selects services
- Docker host setup → Compose application domains: renders and deploys
- Compose application domains → Traefik & Authelia: includes network edge
- Compose application domains → Docker observability stack: includes monitoring
- Common host baseline → Kubernetes system preparation: precedes
- Kubernetes system preparation → Kubeadm control plane: prepares for
- Kubeadm control plane → CNI, VIP & node joining: enables
- CNI, VIP & node joining → Cluster verification: completes
- Bootstrap & deploy playbooks → Network services: applies
- Network services → Caddy & Keepalived: renders
- Common host baseline → Homelab hosts: converges
- Docker host setup → Homelab hosts: configures Docker hosts
- Cluster verification → Homelab hosts: validates cluster nodes
- Network services → Homelab hosts: configures edge hosts
- Caddy & Keepalived → Traefik & Authelia: routes external access
