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

@ -1,34 +0,0 @@
debug: false
machine:
install:
disk: ${install_disk}
network:
hostname: ${hostname}
nameservers:
- 10.13.37.2
interfaces:
- interface: eth0
dhcp: false
kubelet:
extraArgs:
pod-max-pids: 1000
extraConfig:
imageGCHighThresholdPercent: 75
imageGCLowThresholdPercent: 70
cluster:
apiServer:
auditPolicy:
apiVersion: audit.k8s.io/v1
kind: Policy
rules:
# Log only metadata in audit logs
- level: Metadata
network:
hostname: ${hostname}
cni:
name: none
nodeLabels:
topology.kubernetes.io/region: ${cluster_name}
topology.kubernetes.io/zone: ${node_name}
proxy:
disabled: true

View file

@ -1,93 +0,0 @@
terraform {
required_providers {
proxmox = {
source = "bpg/proxmox"
version = "0.85.1"
}
talos = {
source = "siderolabs/talos"
version = "0.9.0"
}
}
}
resource "proxmox_virtual_environment_vm" "controlplane" {
name = var.controlplane.node_name
node_name = "pve01"
tags = ["tofu"]
bios = "ovmf"
on_boot = true
machine = "q35"
stop_on_destroy = true
operating_system {
type = "l26"
}
agent {
enabled = true
}
cpu {
cores = var.controlplane.cpu
sockets = 1
type = "x86-64-v2-AES"
}
memory {
dedicated = var.controlplane.memory * 1024
}
disk {
datastore_id = var.controlplane.storagepool
interface = "virtio0"
aio = "io_uring"
size = var.controlplane.disk * 1024
file_format = "raw"
}
cdrom {
file_id = format("local:iso/talos-%s-nocloud-amd64-secureboot.iso", var.controlplane.talos_version)
}
efi_disk {
datastore_id = var.controlplane.storagepool
file_format = "raw"
type = "4m"
}
tpm_state {
datastore_id = var.controlplane.storagepool
version = "v2.0"
}
initialization {
datastore_id = var.controlplane.storagepool
ip_config {
ipv4 {
address = var.controlplane.node_ipv4_address
gateway = var.controlplane.ipv4_gateway
}
}
dns {
servers = ["10.13.37.2"]
}
}
network_device {
bridge = "vmbr1"
}
}
# resource "talos_machine_secrets" "controlplane" {
# talos_version = var.controlplane.talos_version
# }
#
# data "talos_client_configuration" "controlplane" {
# cluster_name = var.controlplane.cluster_name
# client_configuration = talos_machine_secrets.controlplane.client_configuration
# nodes = [for k, v in var.controlplane : v.ip]
# endpoints = [var.controlplane.cluster_endpoint]
# }

View file

@ -1,17 +0,0 @@
variable "controlplane" {
description = "Control plane node configuration"
type = object({
cpu = number
memory = number
disk = string
storagepool = string
talos_version = string
cluster_name = string
kubernetes_version = string
node_name = string
node_ipv4_address = string
cluster_endpoint = string
ipv4_gateway = string
})
}

View file

@ -23,10 +23,10 @@ locals {
}
resource "proxmox_virtual_environment_download_file" "talos-image" {
node_name = "pve01"
content_type = "iso"
datastore_id = "local"
overwrite = true
node_name = "pve01"
content_type = "iso"
datastore_id = "local"
overwrite = true
url = local.iso_url
file_name = local.iso_file

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)
})
}

View file

@ -1,34 +0,0 @@
debug: false
machine:
install:
disk: ${install_disk}
network:
hostname: ${hostname}
nameservers:
- 10.13.37.2
interfaces:
- interface: eth0
dhcp: false
kubelet:
extraArgs:
pod-max-pids: 1000
extraConfig:
imageGCHighThresholdPercent: 75
imageGCLowThresholdPercent: 70
cluster:
apiServer:
auditPolicy:
apiVersion: audit.k8s.io/v1
kind: Policy
rules:
# Log only metadata in audit logs
- level: Metadata
network:
hostname: ${hostname}
cni:
name: none
nodeLabels:
topology.kubernetes.io/region: ${cluster_name}
topology.kubernetes.io/zone: ${node_name}
proxy:
disabled: true

View file

@ -1,93 +0,0 @@
terraform {
required_providers {
proxmox = {
source = "bpg/proxmox"
version = "0.85.1"
}
talos = {
source = "siderolabs/talos"
version = "0.9.0"
}
}
}
resource "proxmox_virtual_environment_vm" "worker" {
name = var.worker.node_name
node_name = "pve01"
tags = ["tofu"]
bios = "ovmf"
on_boot = true
machine = "q35"
stop_on_destroy = true
operating_system {
type = "l26"
}
agent {
enabled = true
}
cpu {
cores = var.worker.cpu
sockets = 1
type = "x86-64-v2-AES"
}
memory {
dedicated = var.worker.memory * 1024
}
disk {
datastore_id = var.worker.storagepool
interface = "virtio0"
aio = "io_uring"
size = var.worker.disk * 1024
file_format = "raw"
}
cdrom {
file_id = format("local:iso/talos-%s-nocloud-amd64-secureboot.iso", var.worker.talos_version)
}
efi_disk {
datastore_id = var.worker.storagepool
file_format = "raw"
type = "4m"
}
tpm_state {
datastore_id = var.worker.storagepool
version = "v2.0"
}
initialization {
datastore_id = var.worker.storagepool
ip_config {
ipv4 {
address = var.worker.node_ipv4_address
gateway = var.worker.ipv4_gateway
}
}
dns {
servers = ["10.13.37.2"]
}
}
network_device {
bridge = "vmbr1"
}
}
# resource "talos_machine_secrets" "controlplane" {
# talos_version = var.controlplane.talos_version
# }
#
# data "talos_client_configuration" "controlplane" {
# cluster_name = var.controlplane.cluster_name
# client_configuration = talos_machine_secrets.controlplane.client_configuration
# nodes = [for k, v in var.controlplane : v.ip]
# endpoints = [var.controlplane.cluster_endpoint]
# }

View file

@ -1,17 +0,0 @@
variable "worker" {
description = "Worker node configuration"
type = object({
cpu = number
memory = number
disk = string
storagepool = string
talos_version = string
cluster_name = string
kubernetes_version = string
node_name = string
node_ipv4_address = string
cluster_endpoint = string
ipv4_gateway = string
})
}