Production-ready, modular Terraform module for deploying High Availability Kubernetes clusters on Hetzner Cloud (hcloud). Designed with spread placement groups, private subnet network isolation, Hetzner Load Balancers, automated Cloud Controller (CCM) & CSI integration, and multi-distro support for K3s, RKE2, and Talos Linux.
flowchart TD
subgraph External ["External Access & Clients"]
User["<i class='fas fa-user'></i> Developers / kubectl / Clients"]
GitLabCI["<i class='fab fa-gitlab'></i> GitLab CI/CD Pipeline"]
end
subgraph HcloudInfra ["Hetzner Cloud Infrastructure (hcloud)"]
direction TB
subgraph EdgeSecurity ["Edge Security & Load Balancing Layer"]
Firewall["<i class='fas fa-shield-alt'></i> Hetzner Cloud Firewall<br/><small>hcloud_firewall (Only 6443/80/443 Allowed)</small>"]:::accent
HLB["<i class='fas fa-network-wired'></i> Hetzner Cloud Load Balancer<br/><small>hcloud_load_balancer (Static Public IP)</small>"]:::accent
end
subgraph PrivateNet ["Isolated Private Subnet (hcloud_network: 10.0.0.0/16)"]
direction TB
subgraph ControlPlane ["Control Plane HA (Spread Placement Group: hcloud_placement_group)"]
direction LR
CP1["<b>Control Plane 1 (nbg1)</b><br/><small>cpx31 (10.0.1.11)</small>"]:::boxNode
CP2["<b>Control Plane 2 (fsn1)</b><br/><small>cpx31 (10.0.1.12)</small>"]:::boxNode
CP3["<b>Control Plane 3 (hel1)</b><br/><small>cpx31 (10.0.1.13)</small>"]:::boxNode
end
subgraph StorageLayer ["State Persistence & Storage Layer"]
direction LR
Vol1["<b>hcloud_volume 1</b><br/><small>etcd Datastore</small>"]
Vol2["<b>hcloud_volume 2</b><br/><small>etcd Datastore</small>"]
Vol3["<b>hcloud_volume 3</b><br/><small>etcd Datastore</small>"]
ExtDB["<b>External DB</b><br/><small>PostgreSQL Node</small>"]
end
subgraph Workers ["Worker Node Pools (hcloud_server_network)"]
direction LR
Worker1["<b>Worker Node 1</b><br/><small>cx22 / cpx31 (10.0.1.21)</small>"]:::boxNode
Worker2["<b>Worker Node 2</b><br/><small>cx22 / cpx31 (10.0.1.22)</small>"]:::boxNode
end
subgraph CloudDrivers ["Hetzner Native Cloud Drivers"]
direction LR
HCCM["<b>Hetzner CCM Driver</b><br/><small>Private IP Auto-Discovery</small>"]:::accent
HCSI["<b>Hetzner CSI Driver</b><br/><small>Dynamic PVC Provisioning</small>"]:::accent
end
end
end
User --> Firewall
GitLabCI --> Firewall
Firewall --> HLB
HLB -->|"Private LB Health Checks (10.0.1.X)"| CP1
CP1 --- Vol1
CP2 --- Vol2
CP3 --- Vol3
CP1 --> ExtDB
CP1 --- Worker1
CP2 --- Worker2
HCCM --> CP1
HCSI --> CP1
classDef accent fill:#1f2630,stroke:#f97316,stroke-width:2px,color:#f97316;
classDef boxNode fill:#232a33,stroke:#313a44,stroke-width:1.5px,color:#f5f7fa;
Hardware Fault Tolerance with Spread Placement Groups (hcloud_placement_group):
type = "spread" placement groups. Hetzner Cloud guarantees control plane instances are hosted on physically separate hypervisor hardware frames, preventing single-point hardware failures.Isolated Private Network Topology (hcloud_network & hcloud_subnetwork):
10.0.0.0/16).10.0.1.X.Edge Security & Strict Firewall Rules (hcloud_firewall):
Dedicated Load Balancer Target Pools (hcloud_load_balancer_target):
10.0.1.X), automatically setting tls-san and node-ip for secure external kubectl access.Hetzner Native Cloud Controller (CCM) & Storage (CSI) Integration:
hcloud-cloud-controller-manager): Auto-discovers server private IPs, routes, and external load balancers natively within Kubernetes.hcloud-csi-driver): Enables Kubernetes Persistent Volume Claims (PVCs) to dynamically provision and attach high-performance Hetzner Block Storage volumes.Multi-Datacenter Geo-Redundancy:
nbg1), Falkenstein (fsn1), Helsinki (hel1), and Ashburn (ash).