Infrastructure-as-Code repository for a self-hosted, high-availability environment running on a Proxmox hypervisor. Manages the full stack from bare-metal host setup through VM provisioning, configuration management, and container orchestration.
Internet
│
├── WireGuard VPN Server (public IP) ──── 10.100.100.0/24 tunnel ──┐
│ │
└── Entry Point VM (192.168.10.27) ── iptables DNAT ──┐ │
│ │
┌──────────▼─────────────▼──────────┐
│ 192.168.10.0/24 Subnet │
│ │
│ ┌─────────────────────────────┐ │
│ │ HAProxy + Keepalived (VIP) │ │
│ │ .5 / .6 / .7 │ │
│ │ VIP: 192.168.10.8 │ │
│ └──────┬──────────┬──────────┘ │
│ │ │ │
│ ┌──────▼───┐ ┌──▼───────────┐ │
│ │ PostgreSQL│ │ K3s Cluster │ │
│ │ + Patroni │ │ 4 masters │ │
│ │ + etcd │ │ 10 workers │ │
│ │ .2/.3/.4 │ │ .9 - .22 │ │
│ └──────────-┘ │ │ │
│ │ Longhorn │ │
│ │ .23 - .26 │ │
│ └──────────────┘ │
└────────────────────────────────────┘
Documentation for the bare-metal host running Proxmox VE on Debian 13 (Hetzner dedicated server):
- Host Setup — Rescue mode install, user creation, SSH hardening, firewall (iptables)
- Networking — Virtual bridges (vmbr0/vmbr1/vmbr2), NAT/masquerade rules, IP forwarding
- Proxmox Config — ACME/Let's Encrypt SSL via Cloudflare DNS, user management, firewall rules
- VM Templating — Ubuntu 24.04 cloud-init image preparation with pre-baked SSH, UFW, and packages
- VPN VM — Dedicated VM for the WireGuard VPN server
Provisions VMs on Proxmox using the telmate/proxmox provider:
- Clones from an Ubuntu 24.04 cloud-init template
- Assigns static IPs on the
192.168.10.0/24subnet - Configures disk, memory, CPU, and SSH keys per VM
Configuration management for all VMs. Playbook execution order matters — see each subdirectory's README.
| Directory | Targets | Purpose |
|---|---|---|
Wireguard/ |
vpn_server, wg_clients |
WireGuard VPN server + client peer registration |
PostgreSQL/ |
database_servers |
3-node PostgreSQL HA (Patroni + etcd with TLS) |
HAProxy/ |
load_balancers |
HAProxy + Keepalived for PostgreSQL load balancing |
Kubernetes/ |
cluster_nodes |
Firewall port rules for k3s nodes |
Servers/ |
all |
OS package updates and distribution upgrades |
PostgreSQL HA execution order:
postgres.yaml— Install PostgreSQL from PGDG repo (stopped/disabled for Patroni)etcd.yaml— Install etcd v3.5.24 binary and create system useretcd_config.yaml— Configure etcd cluster with TLS certificatesacl_server_cert.yaml— Set up PostgreSQL SSL certs and ACLs for etcd accesspatroni.yaml— Configure and start Patroni for automatic failover
K3s cluster deployment and workload manifests:
k3s.sh— Bootstraps the full cluster: 4 masters (tainted, no workloads), 10 workers, Kube-VIP for HA API, MetalLB for LoadBalancer serviceslonghorn.sh— Joins 4 dedicated Longhorn storage nodes and installs Longhorn v1.10.0
| Manifest | Namespace | Purpose |
|---|---|---|
Traefik/ |
traefik |
Ingress controller (Helm), Cert-Manager, Let's Encrypt, Cloudflare DNS challenge |
Grafana/ |
monitoring |
Grafana with external PostgreSQL, Redis session cache, Longhorn PVC |
Prometheus/ |
prometheus |
Prometheus with node-exporter, 50Gi Longhorn PVC, 5-day retention |
| Subnet | Purpose |
|---|---|
192.168.10.0/24 |
Internal VM network (all infrastructure) |
10.100.100.0/24 |
WireGuard VPN tunnel |
192.168.10.200-250 |
MetalLB LoadBalancer IP pool |
192.168.10.254 |
Kube-VIP (k3s API HA endpoint) |
192.168.10.8 |
Keepalived VIP (HAProxy floating IP) |
192.168.10.212 |
Traefik LoadBalancer IP |
192.168.10.204 |
Grafana LoadBalancer IP |
192.168.10.205 |
Prometheus LoadBalancer IP |
| Role | Hosts | IPs |
|---|---|---|
| VPN Server | 1 | Public IP |
| Entry Point | 1 | 192.168.10.27 |
| PostgreSQL / etcd / Patroni | 3 | 192.168.10.2 - .4 |
| HAProxy / Keepalived | 3 | 192.168.10.5 - .7 |
| K3s Masters | 4 | 192.168.10.9 - .12 |
| K3s Workers | 10 | 192.168.10.13 - .22 |
| Longhorn Storage | 4 | 192.168.10.23 - .26 |
- Proxmox VE host with virtual bridges configured
- Terraform >= 1.0 with
telmate/proxmoxprovider - Ansible with
community.generalcollection - Helm 3 (for Traefik deployment)
- k3sup and kubectl (installed automatically by
k3s.sh) - WireGuard VPN access to the internal subnet
cd Terraform
terraform init
terraform plan
terraform applycd Ansible
# VPN
ansible-playbook Wireguard/wg_server.yaml
ansible-playbook Wireguard/wg_clients.yaml
# PostgreSQL HA
ansible-playbook PostgreSQL/postgres.yaml
ansible-playbook PostgreSQL/etcd.yaml
ansible-playbook PostgreSQL/etcd_config.yaml
ansible-playbook PostgreSQL/acl_server_cert.yaml
ansible-playbook PostgreSQL/patroni.yaml
# Load Balancers
ansible-playbook HAProxy/haproxy.yaml
ansible-playbook HAProxy/keepalived.yaml
# Kubernetes firewall
ansible-playbook Kubernetes/cluster_ports.yamlcd Kubernetes
chmod +x k3s.sh longhorn.sh
./k3s.sh
./longhorn.shcd Kubernetes/Manifests
bash Traefik/deploy.sh
bash Prometheus/deploy.sh
bash Grafana/deploy.sh- All secrets, passwords, and tokens in this repo are placeholders — replace before use
- SSH is hardened with key-only auth on non-standard ports
- VMs only accept SSH from the WireGuard VPN subnet
- etcd cluster communication uses mutual TLS
- PostgreSQL connections use SSL (hostssl in pg_hba)
- Traefik enforces HTTPS redirect on all ingress