Files
IaC/terraform/main.tf

65 lines
1.4 KiB
HCL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
terraform {
required_providers {
proxmox = {
source = "bpg/proxmox"
version = "0.89.0" # Используем самую свежую версию конца 2025 года
}
}
backend "http" {}
}
provider "proxmox" {
endpoint = var.proxmox_api_url
api_token = "${var.proxmox_api_token_id}=${var.proxmox_api_token_secret}"
insecure = true
ssh {
agent = false
}
}
# ВАЖНО: Название ресурса теперь proxmox_virtual_environment_vm
resource "proxmox_virtual_environment_vm" "k8s_nodes" {
for_each = var.vm_nodes
node_name = "pve"
name = each.value.name
vm_id = each.value.id
# Клонирование теперь настраивается так
clone {
vm_id = 9000
}
cpu {
cores = 2
type = "x86-64-v2-AES" # Рекомендуемый тип для современных K8s
}
memory {
dedicated = 4096
}
# В новых версиях блоки стали более детальными
network_interface {
bridge = "vmbr0"
}
disk {
datastore_id = "local-lvm"
interface = "scsi0"
size = 20
}
initialization {
ip_config {
ipv4 {
address = "${each.value.ip}/24"
gateway = "10.33.33.1"
}
}
user_account {
username = "ubuntu"
keys = ["ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPkMcT6PGm4xwBlwwwLkzdzTF/pgtADIcdejf5xALbxQ semaphore-gitea-key"]
}
}
}