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_raw { file_name = "kube-init.sh" data = <<-EOF #!/bin/sh apk update apk upgrade apk add openssh-server rc-update add sshd openrc -s sshd start EOF } } resource "proxmox_virtual_environment_container" "kube-masters" { # hook_script_file_id = "${var.datastore_id}:snippets/kube-init.sh" 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 ] initialization { # hostname = data.external.master_kube.result.name hostname = "kube-master-${tostring(count.index)}.kubes.42069.no" ip_config { ipv4 { address = "dhcp" } } user_account { password = var.user_password keys = var.ssh_keys } } network_interface { name = "eth0" } operating_system { template_file_id = proxmox_virtual_environment_download_file.latest_alpine.id type = "alpine" } startup { order = "1" } } resource "proxmox_virtual_environment_container" "kube-workers" { hook_script_file_id = "${var.datastore_id}:snippets/kube-init.sh" 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 ] initialization { # hostname = data.external.worker_kube.result.name hostname = "kube-worker-${tostring(count.index)}.kubes.42069.no" ip_config { ipv4 { address = "dhcp" } } user_account { password = var.user_password keys = var.ssh_keys } } network_interface { name = "eth0" } operating_system { template_file_id = proxmox_virtual_environment_download_file.latest_alpine.id type = "alpine" } startup { order = "3" } }