Files
IaC/terraform/main.tf

59 lines
1.2 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.70.0"
}
}
backend "http" {}
}
provider "proxmox" {
endpoint = var.proxmox_api_url
api_token = "${var.proxmox_api_token_id}=${var.proxmox_api_token_secret}"
insecure = true
# Это важно для стабильности в Proxmox 9
ssh {
agent = false
}
}
resource "proxmox_virtual_machine" "k8s_nodes" {
for_each = var.vm_nodes
node_name = "pve-main" # УБЕДИТЕСЬ ЧТО ЭТО ИМЯ СОВПАДАЕТ С ИМЕНЕМ В PROXMOX GUI
name = each.value.name
vm_id = each.value.id
cpu {
cores = 2
}
memory {
dedicated = 4096
}
network_device {
bridge = "vmbr0"
}
disk {
datastore_id = "local-lvm"
file_id = "local:iso/debian-13-generic-amd64.iso" # Ваш образ
interface = "virtio0"
size = 20
}
initialization {
ip_config {
ipv4 {
address = "${each.value.ip}/24"
gateway = "10.33.33.1"
}
}
user_account {
username = "ubuntu"
keys = ["ssh-ed25519 AAAAC3..."] # ВАШ ПУБЛИЧНЫЙ КЛЮЧ
}
}
}