Files
IaC/terraform/main.tf

59 lines
1.3 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" с источником "bpg/proxmox"
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
ssh {
agent = false
}
}
# Если здесь ошибка, попробуйте изменить имя ресурса на "node" (просто для теста)
resource "proxmox_virtual_machine" "k8s_nodes" {
for_each = var.vm_nodes
node_name = "pve" # ПРОВЕРЬТЕ ЭТО ИМЯ В ИНТЕРФЕЙСЕ PROXMOX
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..."] # ВАШ ПУБЛИЧНЫЙ КЛЮЧ
}
}
}