chore: Refactor VM deployment

This commit is contained in:
Peter 2025-10-28 22:45:12 +01:00
parent d2e0c26900
commit 9ca0f7c431
Signed by: Peter
SSH key fingerprint: SHA256:B5tYaxBExaDm74r1px9iVeZ6F/ZDiyiy9SbBqfZYrvg
13 changed files with 192 additions and 328 deletions

View file

@ -0,0 +1,77 @@
terraform {
required_providers {
proxmox = {
source = "bpg/proxmox"
version = "0.85.1"
}
}
}
resource "proxmox_virtual_environment_vm" "talos-node" {
name = var.node.name
node_name = var.node.proxmox_node
tags = ["tofu"]
bios = "ovmf"
on_boot = true
machine = "q35"
stop_on_destroy = true
operating_system {
type = "l26"
}
agent {
enabled = true
}
cpu {
cores = var.node.cpu
sockets = 1
type = "x86-64-v2-AES"
}
memory {
dedicated = var.node.memory * 1024
}
disk {
datastore_id = var.node.storagepool
interface = "virtio0"
aio = "io_uring"
size = var.node.disk
file_format = "raw"
}
cdrom {
file_id = format("local:iso/talos-%s-nocloud-amd64-secureboot.iso", var.node.talos_version)
}
efi_disk {
datastore_id = var.node.storagepool
file_format = "raw"
type = "4m"
}
boot_order = ["virtio0", "ide3", "net0"]
tpm_state {
datastore_id = var.node.storagepool
version = "v2.0"
}
initialization {
datastore_id = var.node.storagepool
ip_config {
ipv4 {
address = format("%s/24", var.node.ipv4_address)
gateway = var.node.ipv4_gateway
}
}
dns {
servers = ["10.13.37.2"]
}
}
network_device {
bridge = "vmbr1"
}
}

View file

@ -0,0 +1,19 @@
variable "node" {
description = "Virtual node configuration"
type = object({
name = string
ipv4_address = string
ipv4_gateway = string
cpu = number
memory = number
disk = string
storagepool = string
talos_version = string
cluster_name = string
kubernetes_version = string
cluster_endpoint = string
proxmox_node = string
controlplane_addresses = list(string)
worker_addresses = list(string)
})
}