# h3mul/homelab-k3s-flux architecture

> Architecture diagram of the GitHub repository h3mul/homelab-k3s-flux, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/h3mul/homelab-k3s-flux
- Repository: https://github.com/h3mul/homelab-k3s-flux

## Overview

##### Main Components

a. Infrastructure Layer:
- Talos OS Nodes (Physical Infrastructure)
- BGP Router Integration
- Network Configuration

b. Kubernetes Core:
- Talos Kubernetes Cluster
- Flux System (Control Plane)
- CNI (Cilium)

c. Core Services:
- Sealed Secrets Controller
- Cert Manager
- External DNS
- Ingress Controllers (NGINX)

d. Application Categories (Group these logically):
- Media Services (Jellyfin, Sonarr, Radarr, etc.)
- Monitoring Stack (Prometheus, Grafana, Loki)
- Development Tools (Gitea, Drone)
- Storage Services (Democratic CSI, VolSync)
- Network Services (Blocky, External DNS)

##### Relationship Flows

- GitOps flow: GitHub → Flux → Cluster
- Traffic flow: Internet → Ingress → Services
- Storage: Democratic CSI → TrueNAS → Applications
- Backup flows: Applications → VolSync → B2 Storage
- Monitoring: Applications → Prometheus → Grafana

##### Specific Implementation Details

Create sections showing:
- Flux bootstrap process
- Sealed Secrets workflow
- Backup architecture with VolSync
- BGP integration with MetalLB
- Certificate management flow

##### Important Elements to Highlight

- Security boundary zones
- Persistent storage locations
- Backup paths
- External service integrations (Cloudflare, B2)
- Internal network routing

##### Technical Details

- Flux reconciliation paths
- Kustomization hierarchy
- Helm repository relationships
- Persistent volume claims
- Network policies

Remember to emphasize the GitOps-based nature of the setup, showing how Flux manages the entire configuration from the GitHub repository to the cluster state.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef infrastructure fill:#E6E6E6,stroke:#333
    classDef kubernetes fill:#326CE5,stroke:#333,color:white
    classDef security fill:#FF6B6B,stroke:#333,color:white
    classDef storage fill:#FFD93D,stroke:#333
    classDef monitoring fill:#A367DC,stroke:#333,color:white
    classDef network fill:#4ECDC4,stroke:#333
    classDef media fill:#95D5B2,stroke:#333
    classDef development fill:#F8B195,stroke:#333
    classDef external fill:#C8C8C8,stroke:#333

    %% External Services Layer
    subgraph External["External Services"]
        GitHub["GitHub Repository"]:::external
        Cloudflare["Cloudflare DNS"]:::external
        B2["Backblaze B2"]:::external
    end

    %% Infrastructure Layer
    subgraph Infrastructure["Infrastructure Layer"]
        TalosOS["Talos OS Nodes"]:::infrastructure
        BGP["BGP Router"]:::infrastructure
        Network["Network Config"]:::infrastructure
    end

    %% Kubernetes Core Layer
    subgraph K8sCore["Kubernetes Core"]
        Cluster["Talos K8s Cluster"]:::kubernetes
        FluxSystem["Flux System"]:::kubernetes
        Cilium["Cilium CNI"]:::kubernetes
    end

    %% Platform Services Layer
    subgraph Platform["Platform Services"]
        SealedSecrets["Sealed Secrets"]:::security
        CertManager["Cert Manager"]:::security
        ExternalDNS["External DNS"]:::network
        IngressNGINX["Ingress NGINX"]:::network
    end

    %% Storage Layer
    subgraph Storage["Storage Services"]
        DemocraticCSI["Democratic CSI"]:::storage
        VolSync["VolSync"]:::storage
        TrueNAS["TrueNAS"]:::storage
    end

    %% Application Layer
    subgraph Apps["Applications"]
        direction TB
        
        subgraph Media["Media Services"]
            Jellyfin["Jellyfin"]:::media
            Sonarr["Sonarr"]:::media
            Radarr["Radarr"]:::media
        end

        subgraph Monitoring["Monitoring Stack"]
            Prometheus["Prometheus"]:::monitoring
            Grafana["Grafana"]:::monitoring
            Loki["Loki"]:::monitoring
        end

        subgraph DevTools["Development Tools"]
            Gitea["Gitea"]:::development
            Drone["Drone"]:::development
        end

        subgraph NetworkServices["Network Services"]
            Blocky["Blocky"]:::network
        end
    end

    %% Relationships
    GitHub --> FluxSystem
    FluxSystem --> Cluster
    Cloudflare --> ExternalDNS
    BGP --> Cilium
    Cilium --> Cluster
    IngressNGINX --> Apps
    DemocraticCSI --> TrueNAS
    VolSync --> B2
    Apps --> Prometheus
    Prometheus --> Grafana

    %% Click Events
    click TalosOS "https://github.com/H3mul/homelab-k3s-flux/blob/main/provision/talos/talconfig.yaml"
    click BGP "https://github.com/H3mul/homelab-k3s-flux/blob/main/cluster/cilium-bgp-loadbalancer/cilium-bgp-peering-policy-opnsense.yaml"
    click FluxSystem "https://github.com/H3mul/homelab-k3s-flux/blob/main/bootstrap/flux-system/gotk-components.yaml"
    click Cilium "https://github.com/H3mul/homelab-k3s-flux/blob/main/cluster/cilium/helmrelease-cilium.yaml"
    click SealedSecrets "https://github.com/H3mul/homelab-k3s-flux/blob/main/cluster/sealed-secrets/helmrelease-sealed-secrets.yaml"
    click CertManager "https://github.com/H3mul/homelab-k3s-flux/blob/main/cluster/cert-manager/helmrelease-cert-manager.yaml"
    click ExternalDNS "https://github.com/H3mul/homelab-k3s-flux/blob/main/cluster/external-dns/helmrelease-external-dns.yaml"
    click IngressNGINX "https://github.com/H3mul/homelab-k3s-flux/blob/main/cluster/ingress-nginx/helmrelease-ingress-nginx.yaml"
    click Jellyfin "https://github.com/H3mul/homelab-k3s-flux/blob/main/cluster/jellyfin/helmrelease-jellyfin.yaml"
    click Sonarr "https://github.com/H3mul/homelab-k3s-flux/blob/main/cluster/sonarr/helmrelease-sonarr.yaml"
    click Radarr "https://github.com/H3mul/homelab-k3s-flux/blob/main/cluster/radarr/helmrelease-radarr.yaml"
    click Prometheus "https://github.com/H3mul/homelab-k3s-flux/blob/main/cluster/kube-prometheus-stack/helmrelease-kube-prometheus-stack.yaml"
    click Grafana "https://github.com/H3mul/homelab-k3s-flux/blob/main/cluster/grafana/helmrelease-grafana.yaml"
    click Loki "https://github.com/H3mul/homelab-k3s-flux/blob/main/cluster/loki/helmrelease-loki.yaml"
    click Gitea "https://github.com/H3mul/homelab-k3s-flux/blob/main/cluster/gitea/helmrelease-gitea.yaml"
    click Drone "https://github.com/H3mul/homelab-k3s-flux/blob/main/cluster/drone/helmrelease-drone.yaml"
    click DemocraticCSI "https://github.com/H3mul/homelab-k3s-flux/blob/main/cluster/democratic-csi/helmrelease-democratic-csi-iscsi.yaml"
    click VolSync "https://github.com/H3mul/homelab-k3s-flux/blob/main/cluster/volsync-system/helmrelease-volsync.yaml"
    click Blocky "https://github.com/H3mul/homelab-k3s-flux/blob/main/cluster/blocky/helmrelease-blocky.yaml"
```
