A turnkey Kubernetes cluster built with Talos Linux running on a Proxmox VE hypervisor. Provisioning is done with OpenTofu.
Kubernetes cluster features:
- Talos Linux v1.13.8
- Kubernetes v1.36.3
- no kube-proxy
- Cilium v1.20.0 as Container Network Interface (CNI)
- without kube-proxy
- with L2 loadbalancer support
- with Ingress controller support
- with Gateway API support
- with Egress gateway support
- Gateway API v1.6.1 CRDs (standard channel) are installed
- ArgoCD v3.4.2
This Kubernetes cluster is meant to be used in a test or home lab environment.
You need to have installed on your local machine:
The project is grouped into three sections:
- proxmox: provisioning of virtual machines, operating system and Kubernetes cluster
- kubernetes: provisioning of Kubernetes resources in the running Kubernetes cluster
- argocd: provisioning of Kubernetes resources using GitOps approach, can be configured with
install_argocd_app_of_appsflag
This way you can choose to only provision the cluster itself. As an additional option you can provision Kubernetes resources and bootstrap also ArgoCD.
Going through all the steps, you will have an ArgoCD instance running in the cluster eventually. You can then
install your applications using the GitOps approach. Have a look at install_argocd_app_of_apps and the related
configuration variables for further options.
The main idea is to provision the Kubernetes cluster and bootstrap ArgoCD with infrastructure as code using OpenTofu. So it can be rolled out very quickly and consistently. All other Kubernetes resources are then installed with ArgoCD using a git repository.
Usually you want to keep your Kubernetes cluster infrastructure and the Kubernetes resources in a separate repositories.
That way you have everything decoupled, and you can migrate your applications to a new cluster infrastructure more easily.
I added the Kubernetes resources in the argocd directory mainly for demonstration purposes.
First step is to provision the Proxmox part: create a configuration.auto.tfvars file based on the example and
edit it so it suits your needs. For each control plane and worker node in node_data, the hostname, CPU cores,
memory and disk size are optional and fall back to sensible defaults. When you omit the hostname, Talos Linux
generates one itself:
$ cd proxmox
$ cp configuration.auto.tfvars.example configuration.auto.tfvars
$ vim configuration.auto.tfvarsThen apply the configuration using OpenTofu:
$ tofu init
$ tofu plan
$ tofu applyYou can then grab and move the kube config file for Kubernetes provisioning like so:
$ tofu output -raw kubeconfig > ~/.kube/config
$ chmod 600 ~/.kube/configTest if your cluster access works by listing the nodes:
$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
your-cluster-name-cp-0 Ready control-plane 5d v1.36.3
your-cluster-name-worker-0 Ready <none> 5d v1.36.3You might need to wait a bit until the nodes come up. Proceed with the next step when all nodes are in the Ready
state.
Secondly, you can provision the resources inside the Kubernetes cluster. You have a couple of options to choose
from. All options can be configured using variables in configuration.auto.tfvars:
- Quick start: installs Cilium LB config, ArgoCD, Ingress without TLS (default settings) with OpenTofu. ArgoCD is
available on http://argocd.local.
- install_cilium_lb_config = true
- argocd_helm_values: see defaults in variables.tf
- install_argocd_app_of_apps = false
- install_argocd_app_of_apps_git_repo_secret = false
- GitOps using your own repository: installs ArgoCD, no Cilium LB config, no Ingress and the Kubernetes resources in
the repository you specify in
argocd_app_of_apps_source. Credentials for a private repository can be configured and installed with OpenTofu usinginstall_argocd_app_of_apps_git_repo_secretand the related variables:- install_cilium_lb_config = false
- argocd_helm_values/argocd_helm_yaml_values: add your Helm values and override defaults, for instance keep server insecure and switch off ingress
- install_argocd_app_of_apps = true
- argocd_app_of_apps_source = YOUR SOURCE SETTINGS
- install_argocd_app_of_apps_git_repo_secret = true
- argocd_app_of_apps_git_repo_secret_url = "https://github.com/you/yourrepo.git"
- argocd_app_of_apps_git_repo_secret_password_or_token = "github_pat_OLImf09435459hfjoi9m435298524jtfjn45i8tmnmds329023jdhn"
These are two use cases I envision here. Please regard them as examples. Of course, you can combine the variables to any other setup which suits your needs.
Create a configuration.auto.tfvars like so and edit it to your liking:
$ cd kubernetes
$ cp configuration.auto.tfvars.example configuration.auto.tfvars
$ vim configuration.auto.tfvarsThen do the provisioning with OpenTofu:
$ tofu init
$ tofu plan
$ tofu applyYou can grab the ArgoCD initial admin password with kubectl afterwards:
$ kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath='{.data.password}' | base64 -dArgoCD web user interface should be up and running by now. You can access it in your web browser on
http://argocd.local if you didn't change the defaults or under the domain you configured with argocd_domain.
Or log in using ArgoCD CLI (if installed) and check on sync status of your apps:
$ argocd login --port-forward --port-forward-namespace argocd --plaintext
$ argocd app list --port-forward --port-forward-namespace argocd --plaintextFor doing a GitOps quick start you can fork this repository and point the argocd_app_of_apps_source to the
argocd directory of your newly forked repository. This way you can make use of the example Kubernetes resources in
argocd directory and edit them to match your infrastructure.
Talos OS and Kubernetes versions are managed declaratively through the talos_machine resource
(proxmox/talos_linux.tf), part of the terraform-provider-talos
v0.12 alpha line. On every tofu plan/apply the provider reads the running Talos version and the
active machine configuration hash from each node; changing talos_version/install_image or
kubernetes_version in configuration.auto.tfvars and re-applying reconciles the drift.
Gracefully orchestrating in-place upgrades through Terraform/OpenTofu is a long-standing rough edge in
the Talos provider — see siderolabs/terraform-provider-talos#140
for the multi-year discussion on graceful, node-by-node upgrades, and #381
for clarification that changing talos_version, despite some contradictory wording across the
provider's docs, is in fact the supported way to trigger a Talos upgrade. The notes below reflect how
this repository actually wires up talos_machine/talos_machine_bootstrap today and what to watch
out for as a result.
- Pick the new Talos version and update
talos_version,talos_linux_iso_image_urlandtalos_linux_iso_image_filenameinconfiguration.auto.tfvars. - For every node in
node_data, updateinstall_imageto the matching version tag, e.g.factory.talos.dev/nocloud-installer/<schematic-id>:v1.14.0. The schematic ID stays the same across versions unless you change the extensions baked into the image on the Talos Image Factory; only the version tag needs bumping. - Run
tofu planto confirm only theimagefield (and any machine config drift) is changing, not disk layout or network settings. node_data.controlplanesandnode_data.workersare each applied withfor_eachand have nodepends_onchaining between individual nodes, so a plaintofu applyupgrades every node in parallel. For a multi-control-plane cluster this risks losing etcd quorum. Runtofu apply -parallelism=1instead to upgrade nodes one at a time — see the provider's Upgrading multiple nodes safely guidance.drain_on_upgradeis set tofalsefor both control plane and workertalos_machineresources intalos_linux.tf, so nodes reboot without being cordoned/drained first — acceptable for a home-lab cluster that can tolerate brief pod disruption. If you want zero-disruption upgrades, wirekubeconfig_wo = talos_cluster_kubeconfig.this.kubeconfig_rawinto both resources and setdrain_on_upgrade = true(see the provider's Draining nodes before upgrade).
- Update
kubernetes_versioninconfiguration.auto.tfvars. - This value feeds
data.talos_machine_configurationfor every node, changing the embeddedkubelet,kube-apiserver,kube-controller-manager,kube-schedulerandkube-proxyimage tags. Because this project doesn't use the newertalos_clusterresource or theignore_kubernetes_upgrade_driftattribute ontalos_machine,tofu applyre-applies those tags directly and in parallel across all nodes rather than following Talos's sequential, health-gatedupgrade-k8sprocedure. - For a small/home-lab cluster this is usually fine, but for a safer rollout run
tofu apply -parallelism=1for this step too, or upgrade manually withtalosctl upgrade-k8sfirst and only bumpkubernetes_versionafterwards, sotofu planreports no drift on the next apply.
Proxmox part:
- automate safe, node-by-node upgrade sequencing (draining,
-parallelism=1equivalent viadepends_on) for Talos/Kubernetes version bumps, see Upgrading
I am happy to receive pull requests for any improvements.
Install uv and sync dependencies:
uv syncInstall git hooks:
pre-commit install --hook-type commit-msg --hook-type pre-commit --hook-type pre-push