aboutsummaryrefslogtreecommitdiff
path: root/opentofu/main.tf
diff options
context:
space:
mode:
authorclyhtsuriva <aimeric@adjutor.xyz>2025-02-26 21:10:34 +0100
committerclyhtsuriva <aimeric@adjutor.xyz>2025-02-26 21:10:34 +0100
commitb95a4b78b4a4ede6190e8de3f024296894c07f8f (patch)
tree3b517b527f15b38588007073b8bfe15ed361cebe /opentofu/main.tf
parent1e1a8a1f3f4a8586072d3e31d2bef9c27786d448 (diff)
opentofu: add k3s nodes
ansible to acutally install k3s w.i.p.
Diffstat (limited to 'opentofu/main.tf')
-rw-r--r--opentofu/main.tf105
1 files changed, 105 insertions, 0 deletions
diff --git a/opentofu/main.tf b/opentofu/main.tf
index ff9f945..1cbd21f 100644
--- a/opentofu/main.tf
+++ b/opentofu/main.tf
@@ -59,4 +59,109 @@ module "ansible_provision_docker_server" {
ansible_playbook_path = var.docker_ansible_playbook_path
depends_on = [proxmox_virtual_environment_vm.docker_server]
}
+
+# Master Node (Control Plane)
+resource "proxmox_virtual_environment_vm" "k3s_master" {
+ count = 1
+ name = "k3s-master-${count.index}"
+ node_name = var.proxmox_node
+ tags = ["ubuntu", "k8s", "k3s_master"]
+
+ clone {
+ vm_id = var.ubuntu_server_noble_packer_image_id
+ full = true
+ }
+
+ agent {
+ enabled = true # Qemu Guest Agent
+ }
+
+ cpu {
+ cores = 2
+ sockets = 1
+ type = "host"
+ }
+
+ memory {
+ dedicated = 4096
+ }
+
+ disk {
+ interface = "virtio0"
+ datastore_id = "local-lvm"
+ size = 20
+ discard = "on"
+ iothread = true
+ }
+
+ network_device {
+ bridge = "vmbr0"
+ model = "virtio"
+ }
+
+ initialization {
+ ip_config {
+ ipv4 {
+ address = "dhcp"
+ }
+ }
+
+ user_account {
+ username = var.vm_username
+ keys = [var.ssh_public_key]
+ }
+ }
+}
+
+# Worker Nodes
+resource "proxmox_virtual_environment_vm" "k3s_worker" {
+ count = 2
+ name = "k3s-worker-${count.index}"
+ node_name = var.proxmox_node
+ tags = ["debian", "k8s", "k3s_worker"]
+
+ clone {
+ vm_id = var.debian_server_bookworm_packer_image_id
+ full = true
+ }
+
+ agent {
+ enabled = true # Qemu Guest Agent
+ }
+
+ cpu {
+ cores = 1
+ sockets = 1
+ type = "host"
+ }
+
+ memory {
+ dedicated = 2048
+ }
+
+ disk {
+ interface = "virtio0"
+ datastore_id = "local-lvm"
+ size = 20
+ discard = "on"
+ iothread = true
+ }
+
+ network_device {
+ bridge = "vmbr0"
+ model = "virtio"
+ }
+
+ initialization {
+ ip_config {
+ ipv4 {
+ address = "dhcp"
+ }
+ }
+
+ user_account {
+ username = var.vm_username
+ keys = [var.ssh_public_key]
+ }
+ }
}