# kube-hetzner/terraform-hcloud-kube-hetzner architecture

> Architecture diagram of the GitHub repository kube-hetzner/terraform-hcloud-kube-hetzner, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kube-hetzner/terraform-hcloud-kube-hetzner
- Repository: https://github.com/kube-hetzner/terraform-hcloud-kube-hetzner

## Overview

##### Main Components

a. Infrastructure Layer:
- Hetzner Cloud Provider
- Network Components (Private Network, Subnets)
- Load Balancers
- Floating IPs
- Placement Groups
- Storage (Volumes)

b. Node Layer:
- Control Plane Nodes (MicroOS-based)
- Agent Nodes (MicroOS-based)
- Autoscaler Nodes (Optional)

c. Kubernetes Layer:
- K3s Distribution
- CNI (Flannel/Calico/Cilium)
- Storage Providers (Longhorn/Hetzner CSI)
- Ingress Controllers (Traefik/Nginx/HAProxy)

##### Component Relationships

- Hetzner Cloud Provider → All Infrastructure Components
- Load Balancers → Control Plane Nodes
- Private Network → All Nodes
- Control Plane Nodes ↔ Agent Nodes (via Private Network)
- Storage → Relevant Nodes
- Ingress Controllers → Load Balancers

##### Specific Implementation Details

**┌─ Automation & Management ─┐**
- Terraform              │
- Packer (OS Images)     │
- Cloud-Init             │
- ┘

**┌─ Security ──────────────┐**
- Firewalls            │
- Network Policies     │
- Encryption at Rest   │
- ┘

**┌─ High Availability ────┐**
- Multi-Node Control  │
- Load Balancing      │
- Auto-healing        │
- ┘

##### Flow Directions

Following flows:
- External Traffic → Load Balancer → Ingress → Services
- Internal Traffic Flow between Nodes
- Control Plane to Agent Node Communication
- Storage Access Patterns

##### Deployment Stages

Showing the deployment flow:
##### -ons Deployment

- The modular nature of the system
- High availability features
- Security implementations
- Networking architecture
- Automation capabilities

Remember to include version information and any environment-specific configurations as notes or in a separate reference section.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Infrastructure
        HC[Hetzner Cloud Provider]
        PN[Private Network]
        LB[Load Balancers]
        FIP[Floating IPs]
        PG[Placement Groups]:::placement
        ST[Storage]
    end

    subgraph Node_Layer
        CP[Control Plane Nodes]:::control
        AN[Agent Nodes]:::agent
        ASN[Autoscaler Nodes]:::autoscaler
    end

    subgraph Kubernetes_Components
        K3S[K3s Distribution]
        
        subgraph CNI_Solutions
            CAL[Calico]:::cni
            CIL[Cilium]:::cni
        end
        
        subgraph Storage_Solutions
            LH[Longhorn]:::storage
            CSI[Hetzner CSI]:::storage
        end
        
        subgraph Ingress_Controllers
            TR[Traefik]:::ingress
            NG[Nginx]:::ingress
            HA[HAProxy]:::ingress
        end
        
        CCM[Cloud Controller Manager]:::k8s
    end

    subgraph Management
        TF[Terraform]
        PK[Packer OS Images]:::packer
        CI[Cloud-Init]:::cloudinit
    end

    subgraph Security
        FW[Firewalls]
        NP[Network Policies]
        ER[Encryption at Rest]
    end

    %% Relationships
    HC --> PN
    HC --> LB
    HC --> FIP
    HC --> PG
    HC --> ST
    
    LB --> CP
    PN --> CP
    PN --> AN
    PN --> ASN
    
    CP <--> AN
    CP <--> ASN
    
    K3S --> CP
    K3S --> AN
    K3S --> ASN
    
    CAL & CIL --> PN
    LH & CSI --> ST
    TR & NG & HA --> LB

    %% Click Events
    click CP "https://github.com/kube-hetzner/terraform-hcloud-kube-hetzner/blob/master/control_planes.tf"
    click AN "https://github.com/kube-hetzner/terraform-hcloud-kube-hetzner/blob/master/agents.tf"
    click ASN "https://github.com/kube-hetzner/terraform-hcloud-kube-hetzner/blob/master/autoscaler-agents.tf"
    click PG "https://github.com/kube-hetzner/terraform-hcloud-kube-hetzner/blob/master/placement_groups.tf"
    click CAL "https://github.com/kube-hetzner/terraform-hcloud-kube-hetzner/blob/master/templates/calico.yaml.tpl"
    click CIL "https://github.com/kube-hetzner/terraform-hcloud-kube-hetzner/blob/master/templates/cilium.yaml.tpl"
    click LH "https://github.com/kube-hetzner/terraform-hcloud-kube-hetzner/blob/master/templates/longhorn.yaml.tpl"
    click CSI "https://github.com/kube-hetzner/terraform-hcloud-kube-hetzner/blob/master/templates/hcloud-csi.yaml.tpl"
    click HA "https://github.com/kube-hetzner/terraform-hcloud-kube-hetzner/blob/master/templates/haproxy_ingress.yaml.tpl"
    click NG "https://github.com/kube-hetzner/terraform-hcloud-kube-hetzner/blob/master/templates/nginx_ingress.yaml.tpl"
    click TR "https://github.com/kube-hetzner/terraform-hcloud-kube-hetzner/blob/master/templates/traefik_ingress.yaml.tpl"
    click CCM "https://github.com/kube-hetzner/terraform-hcloud-kube-hetzner/blob/master/templates/ccm.yaml.tpl"
    click CI "https://github.com/kube-hetzner/terraform-hcloud-kube-hetzner/blob/master/modules/host/templates/cloudinit.yaml.tpl"
    click PK "https://github.com/kube-hetzner/terraform-hcloud-kube-hetzner/blob/master/packer-template/hcloud-microos-snapshots.pkr.hcl"

    %% Styling
    classDef infrastructure fill:#a8d1ff
    classDef control fill:#90EE90
    classDef agent fill:#98FB98
    classDef autoscaler fill:#98FB98
    classDef k8s fill:#FFB347
    classDef cni fill:#FFB347
    classDef storage fill:#FFB347
    classDef ingress fill:#FFB347
    classDef security fill:#FFB6C1
    classDef network fill:#DDA0DD
    classDef placement fill:#a8d1ff
    classDef packer fill:#C8A2C8
    classDef cloudinit fill:#C8A2C8

    %% Legend
    subgraph Legend
        L1[Infrastructure]:::infrastructure
        L2[Control Plane]:::control
        L3[Agent Nodes]:::agent
        L4[Kubernetes Components]:::k8s
        L5[Security]:::security
        L6[Network]:::network
    end
```
