The Goal#
To build a reproducible, disposable Kubernetes environment for local development without the cost of public cloud providers. I wanted a "one-click" experience: run a script, and get a fully functioning cluster.
The Architecture#
The project combines three powerful tools to automate the entire lifecycle of the cluster:
-
Infrastructure Layer (Terraform):
- Interacts with the Proxmox VE API to clone Ubuntu Cloud-Init templates.
- Dynamically provisions Virtual Machines (Masters and Workers) with defined resources (CPU/RAM).
- Configures networking and cloud-init user data automatically.
-
Configuration Layer (Ansible):
- Dynamic Inventory: Automatically detects the IP addresses of the Terraform-provisioned VMs.
- K3s Bootstrapping: Installs the K3s binary, configures the master node, and generates the join tokens.
- Worker Join: Automates the process of joining worker nodes to the cluster.
-
The Result:
- A production-ready K3s Cluster running locally.
- Zero manual SSH required—everything is handled via keys and automation.
- Destruction and recreation of the entire cluster takes less than 5 minutes.