2024-10-16 15:04:40 +00:00
|
|
|
|
|
|
|
resource "proxmox_virtual_environment_download_file" "latest_alpine" {
|
|
|
|
content_type = "vztmpl"
|
2024-10-18 11:13:11 +00:00
|
|
|
datastore_id = var.datastore_id
|
|
|
|
node_name = var.proxmox_node
|
2024-10-16 15:04:40 +00:00
|
|
|
url = "http://download.proxmox.com/images/system/alpine-3.20-default_20240908_amd64.tar.xz"
|
|
|
|
}
|
|
|
|
|
2024-10-18 11:13:11 +00:00
|
|
|
resource "proxmox_virtual_environment_file" "kube-init" {
|
|
|
|
content_type = "snippets"
|
|
|
|
datastore_id = var.datastore_id
|
|
|
|
node_name = var.proxmox_node
|
|
|
|
file_mode = "0755"
|
2024-10-21 07:45:23 +00:00
|
|
|
source_file {
|
|
|
|
path = "init-kube.sh"
|
2024-10-18 11:13:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "proxmox_virtual_environment_container" "kube-masters" {
|
2024-10-21 09:08:14 +00:00
|
|
|
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
|
2024-10-18 11:13:11 +00:00
|
|
|
depends_on = [
|
|
|
|
proxmox_virtual_environment_download_file.latest_alpine,
|
|
|
|
proxmox_virtual_environment_file.kube-init
|
|
|
|
]
|
2024-10-21 07:45:23 +00:00
|
|
|
operating_system {
|
|
|
|
template_file_id = proxmox_virtual_environment_download_file.latest_alpine.id
|
|
|
|
type = "alpine"
|
|
|
|
}
|
2024-10-16 15:04:40 +00:00
|
|
|
initialization {
|
2024-10-18 11:13:11 +00:00
|
|
|
hostname = "kube-master-${tostring(count.index)}.kubes.42069.no"
|
2024-10-21 07:45:23 +00:00
|
|
|
user_account {
|
|
|
|
password = var.user_password
|
|
|
|
keys = var.ssh_keys
|
|
|
|
}
|
2024-10-16 15:04:40 +00:00
|
|
|
ip_config {
|
|
|
|
ipv4 {
|
2024-10-21 09:08:14 +00:00
|
|
|
address = "${var.subnet_prefix}.${70 + count.index}/24"
|
|
|
|
gateway = "${var.subnet_prefix}.1"
|
2024-10-16 15:04:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
network_interface {
|
|
|
|
name = "eth0"
|
|
|
|
}
|
2024-10-23 13:20:56 +00:00
|
|
|
disk {
|
|
|
|
size = 12
|
|
|
|
}
|
|
|
|
cpu {
|
|
|
|
cores = 2
|
|
|
|
}
|
|
|
|
memory {
|
|
|
|
dedicated = 512
|
|
|
|
}
|
2024-10-16 15:04:40 +00:00
|
|
|
startup {
|
|
|
|
order = "1"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "proxmox_virtual_environment_container" "kube-workers" {
|
2024-10-21 09:08:14 +00:00
|
|
|
hook_script_file_id = proxmox_virtual_environment_file.kube-init.id
|
2024-10-18 11:13:11 +00:00
|
|
|
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
|
|
|
|
]
|
2024-10-21 07:45:23 +00:00
|
|
|
operating_system {
|
|
|
|
template_file_id = proxmox_virtual_environment_download_file.latest_alpine.id
|
|
|
|
type = "alpine"
|
|
|
|
}
|
2024-10-16 15:04:40 +00:00
|
|
|
initialization {
|
|
|
|
hostname = "kube-worker-${tostring(count.index)}.kubes.42069.no"
|
2024-10-21 07:45:23 +00:00
|
|
|
user_account {
|
|
|
|
password = var.user_password
|
|
|
|
keys = var.ssh_keys
|
|
|
|
}
|
2024-10-18 11:13:11 +00:00
|
|
|
ip_config {
|
|
|
|
ipv4 {
|
2024-10-21 09:08:14 +00:00
|
|
|
address = "${var.subnet_prefix}.${80 + count.index}/24"
|
|
|
|
gateway = "${var.subnet_prefix}.1"
|
2024-10-18 11:13:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
network_interface {
|
|
|
|
name = "eth0"
|
2024-10-16 15:04:40 +00:00
|
|
|
}
|
2024-10-23 13:20:56 +00:00
|
|
|
disk {
|
|
|
|
size = 12
|
|
|
|
}
|
|
|
|
cpu {
|
|
|
|
cores = 2
|
|
|
|
}
|
|
|
|
memory {
|
|
|
|
dedicated = 512
|
|
|
|
}
|
2024-10-18 11:13:11 +00:00
|
|
|
startup {
|
|
|
|
order = "3"
|
2024-10-16 15:04:40 +00:00
|
|
|
}
|
|
|
|
}
|