resource "proxmox_virtual_environment_download_file" "latest_alpine" { content_type = "vztmpl" datastore_id = var.datastore_id node_name = var.proxmox_node url = "http://download.proxmox.com/images/system/alpine-3.20-default_20240908_amd64.tar.xz" } resource "proxmox_virtual_environment_file" "kube-init" { content_type = "snippets" datastore_id = var.datastore_id node_name = var.proxmox_node file_mode = "0755" source_file { path = "init-kube.sh" } } resource "proxmox_virtual_environment_container" "kube-masters" { hook_script_file_id = proxmox_virtual_environment_file.kube-init.id vm_id = var.vmid + count.index + 10 node_name = var.proxmox_node count = var.master_count depends_on = [ proxmox_virtual_environment_download_file.latest_alpine, proxmox_virtual_environment_file.kube-init ] operating_system { template_file_id = proxmox_virtual_environment_download_file.latest_alpine.id type = "alpine" } initialization { hostname = "kube-master-${tostring(count.index)}.kubes.42069.no" user_account { password = var.user_password keys = var.ssh_keys } ip_config { ipv4 { address = "${var.subnet_prefix}.${70 + count.index}/24" gateway = "${var.subnet_prefix}.1" } } } network_interface { name = "eth0" } startup { order = "1" } } resource "proxmox_virtual_environment_container" "kube-workers" { hook_script_file_id = proxmox_virtual_environment_file.kube-init.id vm_id = var.vmid + 100 + count.index node_name = var.proxmox_node count = var.worker_count depends_on = [ proxmox_virtual_environment_download_file.latest_alpine, proxmox_virtual_environment_file.kube-init ] operating_system { template_file_id = proxmox_virtual_environment_download_file.latest_alpine.id type = "alpine" } initialization { hostname = "kube-worker-${tostring(count.index)}.kubes.42069.no" user_account { password = var.user_password keys = var.ssh_keys } ip_config { ipv4 { address = "${var.subnet_prefix}.${80 + count.index}/24" gateway = "${var.subnet_prefix}.1" } } } network_interface { name = "eth0" } startup { order = "3" } }