The new provider adds takeOwnership: false to the kube-prometheus-stack release, so deploying this runs a Helm upgrade with the same chart version and values.
Homelab Infrastructure as Code
A Pulumi-based IaC project for a Proxmox homelab: a highly-available k3s cluster, its cluster-level infrastructure, and the applications running on top of it — all provisioned and configured from code.
This repo is intentionally abstract: credentials are never hardcoded, making it easy to fork and adapt as a template for your own homelab.
Why IaC for a homelab?
- Reproducibility — rebuild the entire environment from scratch from code
- Version history — every change is tracked in git; roll back at any time
- Auditability —
pulumi previewdiffs infrastructure changes before they're applied - Automation — CI/CD handles deploys; no manual SSH into nodes for routine changes
- Portability — swap node names, datastores, domains, or credentials without touching logic
Repository layout
.
├── 01-proxmox-infra/ # Stack 1 — k3s VMs + DHCP on Proxmox/pfSense
├── 02-k8s-bootstrap/ # Stack 2 — install k3s on the VMs over SSH
├── 03-k8s-infra/ # Stack 3 — storage, cert-manager, kube-vip
├── 04-k8s-apps/ # Stack 4 — application workloads
├── 05-monitoring/ # Stack 5 — kube-prometheus-stack (Prometheus + Grafana)
├── .gitea/workflows/ # CI/CD — one workflow per stack
└── CLAUDE.md # Conventions & architecture notes (root + one per stack)
Each stack is an independent Pulumi project (own Pulumi.yaml/package.json), all using the Pulumi stack name dev.
Stacks
Stacks are deployed in order and linked via pulumi.StackReference — outputs from one stack flow automatically into the next, so a stack must be deployed before anything depending on it will work.
proxmox-infra → k8s-bootstrap → k8s-infra
↘ k8s-apps → monitoring
1. proxmox-infra
Provisions a 6-node k3s cluster across three Proxmox hosts, each VM a clone of an Ubuntu Noble (24.04) cloud-image template:
| VM | Role | Proxmox host |
|---|---|---|
| k3s-master-1 | master | pve-b550 |
| k3s-worker-1 | worker | pve-b550 |
| k3s-master-2 | master | pve-esprimo |
| k3s-worker-3 | worker | pve-esprimo |
| k3s-master-3 | master | pve-optiplex |
| k3s-worker-2 | worker | pve-optiplex |
It also generates an ED25519 SSH keypair (stored in Pulumi state, public key injected via cloud-init) and registers each VM's MAC address as a DHCPv4 static mapping in pfSense.
Providers: @muhlba91/pulumi-proxmoxve, @pulumi/pfsense (locally bundled), @pulumi/tls
2. k8s-bootstrap
Starts the VMs via the Proxmox API and installs k3s over SSH: k3s-master-1 initializes the cluster (--cluster-init, embedded etcd), k3s-master-2/k3s-master-3 join as additional etcd nodes, and the three workers join as agents. Exports the cluster's kubeconfig as a secret for downstream stacks.
3. k8s-infra
Cluster-level infrastructure via Helm and @pulumi/kubernetes:
| Component | What it does |
|---|---|
NFS CSI Driver + truenas-nfs StorageClass |
Dynamic NFS-backed PVCs from a TrueNAS share |
| Longhorn | Default block storage (longhorn StorageClass, 2 replicas) |
cert-manager + letsencrypt-prod ClusterIssuer |
TLS certs via Let's Encrypt, DNS-01 through Cloudflare |
| kube-vip + kube-vip-cloud-provider | Announces a virtual IP and allocates it to LoadBalancer Services (e.g. Traefik) |
4. k8s-apps
Application workloads exposed at app.<domain> via Traefik with a Let's Encrypt cert.
5. monitoring
kube-prometheus-stack Helm release — Prometheus (20Gi Longhorn PVC) and Grafana (2Gi PVC, ingress at grafana.<domain>).
Prerequisites
- Pulumi CLI, Node.js 24+ and npm
- One or more Proxmox nodes with API tokens
- pfSense (DHCPv4 static mappings)
- TrueNAS with an NFS share (connected directly — no API key needed)
- A domain with DNS managed by Cloudflare (cert-manager DNS-01 + ingress hostnames)
- A self-hosted Pulumi state backend (PostgreSQL connection string)
- Gitea instance for CI/CD (optional for local-only use)
Getting started
Deploy stacks in order — each must be fully pulumi up'd before the next stack's StackReference resolves. Set the shared backend env vars once per shell:
export PULUMI_BACKEND_URL=postgresql://<user>:<pass>@<host>/<db>
export PULUMI_CONFIG_PASSPHRASE=<your-passphrase>
Clone your private config repo into .pulumi-config/ (see Stack config). For an existing setup, use the config from that repo and skip the stack init and config set commands below.
Then for each stack, in order:
cd 0N-<stack-dir>
npm install
pulumi stack init dev
pulumi config set ... # required keys and secrets
pulumi up --yes
Stack-specific notes:
- proxmox-infra — set Proxmox API tokens, pfSense credentials, VM credentials/SSH public key, and a static IP per node.
- k8s-bootstrap — set
k3sToken(e.g.openssl rand -hex 32) andcontrolPlaneVipAddress(secret; a free IP outside the DHCP pool, fronted by pfSense + HAProxy, see the runbook). Node IPs, Proxmox credentials and the SSH key come automatically fromproxmox-infra. - k8s-infra — before deploying, create an NFS dataset/share on TrueNAS (POSIX ACLs,
root/rootmaproot, restricted to your k3s nodes). SettruenasHost,truenasNfsPath,cloudflareApiToken,letsencryptEmail,kubeVipAddress(all secrets) andkubeVipInterface. - k8s-apps — set
domain, the base domain used for ingress hostnames. - monitoring — set
grafanaAdminPassword.
CI/CD (Gitea Actions)
One workflow per stack, .gitea/workflows/0N-deploy-<stack>.yaml, scoped to changes under that stack's directory.
| Trigger | Stacks | Action |
|---|---|---|
PR → main |
all | pulumi preview (read-only) |
Push to main |
01 | pulumi up (no refresh) |
Push to main |
03–05 | pulumi refresh + pulumi up |
| Manual dispatch | all | pulumi refresh + pulumi up |
Stack 02 (cluster bootstrap) deploys only via manual dispatch, because re-running it restarts the bootstrap sequence. Stack 01 (VM provisioning) skips the refresh on automatic deploys so a VM missing from Proxmox can't be recreated blank. After changing VMs in the Proxmox GUI, run its workflow manually to sync state.
To rebuild the whole cluster from new VMs, follow the rebuild runbook. A normal pulumi up won't do it.
Required secrets
| Secret | Used by |
|---|---|
PULUMI_BACKEND_URL, PULUMI_CONFIG_PASSPHRASE |
all workflows |
PULUMI_CONFIG_REPO_TOKEN (ci-bot token with read-only access to the config repo) |
all workflows |
Stack config
Each stack's encrypted Pulumi.dev.yaml is in a private repo, cloned into the gitignored .pulumi-config/ folder. CI checks out its main branch. After changing config, commit and push it there. That push doesn't start a deploy. See that repo's README for setup and usage.
CI reads the config repo as a separate user, so its token can't access your other private repos:
- As a Gitea admin, create a regular (non-admin) user named
ci-bot. - In the config repo's settings, add
ci-botas a collaborator with Read access. Don't add it to any other private repo. - Sign in as
ci-botand create an access token with only theread:repositorypermission. - In this repo's Actions secrets, add the token as
PULUMI_CONFIG_REPO_TOKEN.
Using this as a template
- Fork or copy the repo
- Update Proxmox node names/datastores and the
nodeConfigsarray in01-proxmox-infra/index.tsfor your VM topology - Set your own config/secrets per stack with
pulumi config set [--secret]— see each stack'sCLAUDE.mdfor the full list of required keys - Create your own private config repo and a
ci-botuser that can read it (see Stack config), then set the repo asrepositoryin each workflow'sCheckout Stack Configsteps - Point the CI/CD workflows at your own Gitea/GitOps instance and update the secrets above
Roadmap
- Migrate secrets management to OpenBao — replace
PULUMI_CONFIG_PASSPHRASEand the encrypted config repo with a self-hosted vault - Add a third bare-metal Proxmox node for true 3-node HA parity