Files
terraform-proxmox-talos/README.md
2025-02-23 15:06:15 +01:00

7.0 KiB

Terraform Proxmox Talos

This Terraform module provisions a Talos Linux cluster on a Proxmox Virtual Environment.
It is is based on a greate article by Olav S. Thoresen: Talos cluster on Proxmox with Terraform.
In addition to the configuration provided by the article, this module enables you to provision a HA control plane and any number of worker nodes.

Configuration

Configure .env:

export PROXMOX_VE_USERNAME="root@pam"
export PROXMOX_VE_PASSWORD="super-secure-password"
export PROXMOX_VE_ENDPOINT="https://<proxmox-ip>:8006/"

Configure module (no-ha example):

module "talos_cluster" {
  source          = "../../"
  cluster_name    = "homelab"
  talos_version   = "1.9.4"
  default_gateway = "192.168.1.1"
  proxmox_nodes   = ["ms-01"]
  talos_controlplane_config = [{
    id        = 101
    name      = "talos-cp-01"
    ip        = "192.168.1.181"
    node      = "ms-01"
    cpu_cores = 2
    memory    = 2048
    disk_size = 20
  }]
  talos_worker_config = [{
    id        = 111
    name      = "talos-worker-01"
    ip        = "192.168.1.191"
    node      = "ms-01"
    cpu_cores = 4
    memory    = 4096
    disk_size = 100
  }]
}

output "kubeconfig" {
  value     = module.talos_cluster.kubeconfig
  sensitive = true
}

Provisioning

Apply configuration:

source .env
terraform init
terraform apply

Write Kubeconfig (caution, this will override you existing Kubeconfig):

terraform output -raw kubeconfig > ~/.kube/config

Verify:

kubectl get nodes

Requirements

Name Version
proxmox 0.72.0
talos 0.7.1

Providers

Name Version
proxmox 0.72.0
talos 0.7.1

Modules

No modules.

Resources

Name Type
proxmox_virtual_environment_download_file.talos_nocloud_image resource
proxmox_virtual_environment_vm.talos_cp resource
proxmox_virtual_environment_vm.talos_worker resource
talos_cluster_kubeconfig.kubeconfig resource
talos_machine_bootstrap.bootstrap resource
talos_machine_configuration_apply.cp_config_apply resource
talos_machine_configuration_apply.worker_config_apply resource
talos_machine_secrets.machine_secrets resource
talos_client_configuration.talosconfig data source
talos_cluster_health.health data source
talos_machine_configuration.machineconfig_cp data source
talos_machine_configuration.machineconfig_worker data source

Inputs

Name Description Type Default Required
cluster_name n/a string "homelab" no
default_gateway n/a string "192.168.1.1" no
proxmox_nodes Names of the Proxmox nodes, used to download and reference node images list(string)
[
"ms-01"
]
no
talos_controlplane_config Machine configuration of control-plane nodes
list(object({
id = number
ip = string
name = string
node = string
cpu_cores = number
memory = number
disk_size = number
}))
[
{
"cpu_cores": 2,
"disk_size": 20,
"id": 101,
"ip": "192.168.1.181",
"memory": 2048,
"name": "talos-cp-01",
"node": "ms-01"
},
{
"cpu_cores": 2,
"disk_size": 20,
"id": 102,
"ip": "192.168.1.182",
"memory": 2048,
"name": "talos-cp-02",
"node": "ms-01"
},
{
"cpu_cores": 2,
"disk_size": 20,
"id": 103,
"ip": "192.168.1.183",
"memory": 2048,
"name": "talos-cp-03",
"node": "ms-01"
}
]
no
talos_version n/a string "1.9.4" no
talos_worker_config Machine configuration of worker nodes
list(object({
id = number
ip = string
name = string
node = string
cpu_cores = number
memory = number
disk_size = number
}))
[
{
"cpu_cores": 4,
"disk_size": 100,
"id": 111,
"ip": "192.168.1.191",
"memory": 4096,
"name": "talos-worker-01",
"node": "ms-01"
},
{
"cpu_cores": 4,
"disk_size": 100,
"id": 112,
"ip": "192.168.1.192",
"memory": 4096,
"name": "talos-worker-02",
"node": "ms-01"
},
{
"cpu_cores": 4,
"disk_size": 100,
"id": 113,
"ip": "192.168.1.193",
"memory": 4096,
"name": "talos-worker-03",
"node": "ms-01"
},
{
"cpu_cores": 4,
"disk_size": 100,
"id": 114,
"ip": "192.168.1.194",
"memory": 4096,
"name": "talos-worker-04",
"node": "ms-01"
}
]
no

Outputs

Name Description
kubeconfig n/a
talosconfig n/a