This commit is contained in:
2025-02-16 13:02:18 -06:00
parent 96f65d5322
commit ca44e683f6
4 changed files with 255 additions and 116 deletions

2
.gitignore vendored
View File

@@ -1 +1,3 @@
.idea
infra/terraform/.terraform
infra/terraform/.terraform.lock.hcl

116
infra/terraform/k3s.tf Normal file
View File

@@ -0,0 +1,116 @@
resource "proxmox_vm_qemu" "k3smaster" {
lifecycle {
prevent_destroy = true
}
count = local.k3smaster.count
ciuser = "administrator"
name = local.k3smaster.name[count.index]
target_node = local.k3smaster.node[count.index]
tags = local.k3smaster.tags
full_clone = false
qemu_os = "l26"
os_type = "cloud-init"
agent = 1
cores = local.k3smaster.cores
sockets = 1
cpu_type = "host"
memory = local.k3smaster.memory
scsihw = "virtio-scsi-pci"
boot = "order=virtio0"
onboot = true
sshkeys = local.sshkeys
vga {
type = "serial0"
}
serial {
id = 0
type = "socket"
}
disks {
ide {
ide2 {
cloudinit {
storage = local.storage
}
}
}
virtio {
virtio0 {
disk {
size = local.k3smaster.drive
format = local.format
storage = local.storage
}
}
}
}
network {
id = 0
model = "virtio"
bridge = "vmbr0"
tag = local.vlan
}
#Cloud Init Settings
ipconfig0 = "ip=192.168.${local.vlan}.${local.k3smaster.ip[count.index]}/24,gw=192.168.${local.vlan}.1"
searchdomain = "durp.loc"
nameserver = local.dnsserver
}
resource "proxmox_vm_qemu" "k3sserver" {
lifecycle {
prevent_destroy = true
}
count = local.k3sserver.count
ciuser = "administrator"
name = local.k3sserver.name[count.index]
target_node = local.k3sserver.node[count.index]
tags = local.k3sserver.tags
qemu_os = "l26"
full_clone = false
os_type = "cloud-init"
agent = 1
cores = local.k3sserver.cores
sockets = 1
cpu_type = "host"
memory = local.k3sserver.memory
scsihw = "virtio-scsi-pci"
#bootdisk = "scsi0"
boot = "order=virtio0"
onboot = true
sshkeys = local.sshkeys
vga {
type = "serial0"
}
serial {
id = 0
type = "socket"
}
disks {
ide {
ide2 {
cloudinit {
storage = local.storage
}
}
}
virtio {
virtio0 {
disk {
size = local.k3sserver.drive
format = local.format
storage = local.storage
}
}
}
}
network {
id = 0
model = "virtio"
bridge = "vmbr0"
tag = local.vlan
}
#Cloud Init Settings
ipconfig0 = "ip=192.168.${local.vlan}.${local.k3sserver.ip[count.index]}/24,gw=192.168.${local.vlan}.1"
searchdomain = "durp.loc"
nameserver = local.dnsserver
}

View File

@@ -24,9 +24,29 @@ locals {
emulatessd = true
format = "raw"
dnsserver = "192.168.12.1"
tags = "postgres"
vlan = 12
k3smaster = {
tags = "k3s_infra"
count = 3
name = ["master01-infra", "master02-infra", "master03-infra"]
cores = 2
memory = "4096"
drive = 20
node = ["mothership", "overlord", "vanguard"]
ip = ["11", "12", "13"]
}
k3sserver = {
tags = "k3s_infra"
count = 3
name = ["node01-infra", "node02-infra", "node03-infra"]
cores = 4
memory = "8192"
drive = 240
node = ["mothership", "overlord", "vanguard"]
ip = ["21", "22", "23"]
}
haproxy = {
tags = "haproxy"
count = 3
name = ["haproxy-01", "haproxy-02", "haproxy-03"]
cores = 2
@@ -36,6 +56,7 @@ locals {
ip = ["31", "32", "33"]
}
postgres = {
tags = "postgres"
count = 3
name = ["postgres-01", "postgres-02", "postgres-03"]
cores = 4
@@ -46,118 +67,3 @@ locals {
}
}
resource "proxmox_vm_qemu" "haproxy" {
count = local.haproxy.count
ciuser = "administrator"
vmid = "${local.vlan}${local.haproxy.ip[count.index]}"
name = local.haproxy.name[count.index]
target_node = local.haproxy.node[count.index]
clone = local.template
tags = local.tags
qemu_os = "l26"
full_clone = true
os_type = "cloud-init"
agent = 1
cores = local.haproxy.cores
sockets = 1
cpu_type = "host"
memory = local.haproxy.memory
scsihw = "virtio-scsi-pci"
#bootdisk = "scsi0"
boot = "order=virtio0"
onboot = true
sshkeys = local.sshkeys
vga {
type = "serial0"
}
serial {
id = 0
type = "socket"
}
disks {
ide {
ide2 {
cloudinit {
storage = local.storage
}
}
}
virtio {
virtio0 {
disk {
size = local.haproxy.drive
format = local.format
storage = local.storage
}
}
}
}
network {
id = 0
model = "virtio"
bridge = "vmbr0"
tag = local.vlan
}
#Cloud Init Settings
ipconfig0 = "ip=192.168.${local.vlan}.${local.haproxy.ip[count.index]}/24,gw=192.168.${local.vlan}.1"
searchdomain = "durp.loc"
nameserver = local.dnsserver
}
resource "proxmox_vm_qemu" "postgres" {
count = local.postgres.count
ciuser = "administrator"
vmid = "${local.vlan}${local.postgres.ip[count.index]}"
name = local.postgres.name[count.index]
target_node = local.postgres.node[count.index]
clone = local.template
tags = local.tags
qemu_os = "l26"
full_clone = true
os_type = "cloud-init"
agent = 1
cores = local.postgres.cores
sockets = 1
cpu_type = "host"
memory = local.postgres.memory
scsihw = "virtio-scsi-pci"
#bootdisk = "scsi0"
boot = "order=virtio0"
onboot = true
sshkeys = local.sshkeys
vga {
type = "serial0"
}
serial {
id = 0
type = "socket"
}
disks {
ide {
ide2 {
cloudinit {
storage = local.storage
}
}
}
virtio {
virtio0 {
disk {
size = local.postgres.drive
format = local.format
storage = local.storage
}
}
}
}
network {
id = 0
model = "virtio"
bridge = "vmbr0"
tag = local.vlan
}
#Cloud Init Settings
ipconfig0 = "ip=192.168.${local.vlan}.${local.postgres.ip[count.index]}/24,gw=192.168.${local.vlan}.1"
searchdomain = "durp.loc"
nameserver = local.dnsserver
}

115
infra/terraform/postgres.tf Normal file
View File

@@ -0,0 +1,115 @@
resource "proxmox_vm_qemu" "haproxy" {
count = local.haproxy.count
ciuser = "administrator"
vmid = "${local.vlan}${local.haproxy.ip[count.index]}"
name = local.haproxy.name[count.index]
target_node = local.haproxy.node[count.index]
clone = local.template
tags = local.haproxy.tags
qemu_os = "l26"
full_clone = true
os_type = "cloud-init"
agent = 1
cores = local.haproxy.cores
sockets = 1
cpu_type = "host"
memory = local.haproxy.memory
scsihw = "virtio-scsi-pci"
#bootdisk = "scsi0"
boot = "order=virtio0"
onboot = true
sshkeys = local.sshkeys
vga {
type = "serial0"
}
serial {
id = 0
type = "socket"
}
disks {
ide {
ide2 {
cloudinit {
storage = local.storage
}
}
}
virtio {
virtio0 {
disk {
size = local.haproxy.drive
format = local.format
storage = local.storage
}
}
}
}
network {
id = 0
model = "virtio"
bridge = "vmbr0"
tag = local.vlan
}
#Cloud Init Settings
ipconfig0 = "ip=192.168.${local.vlan}.${local.haproxy.ip[count.index]}/24,gw=192.168.${local.vlan}.1"
searchdomain = "durp.loc"
nameserver = local.dnsserver
}
resource "proxmox_vm_qemu" "postgres" {
count = local.postgres.count
ciuser = "administrator"
vmid = "${local.vlan}${local.postgres.ip[count.index]}"
name = local.postgres.name[count.index]
target_node = local.postgres.node[count.index]
clone = local.template
tags = local.postgres.tags
qemu_os = "l26"
full_clone = true
os_type = "cloud-init"
agent = 1
cores = local.postgres.cores
sockets = 1
cpu_type = "host"
memory = local.postgres.memory
scsihw = "virtio-scsi-pci"
#bootdisk = "scsi0"
boot = "order=virtio0"
onboot = true
sshkeys = local.sshkeys
vga {
type = "serial0"
}
serial {
id = 0
type = "socket"
}
disks {
ide {
ide2 {
cloudinit {
storage = local.storage
}
}
}
virtio {
virtio0 {
disk {
size = local.postgres.drive
format = local.format
storage = local.storage
}
}
}
}
network {
id = 0
model = "virtio"
bridge = "vmbr0"
tag = local.vlan
}
#Cloud Init Settings
ipconfig0 = "ip=192.168.${local.vlan}.${local.postgres.ip[count.index]}/24,gw=192.168.${local.vlan}.1"
searchdomain = "durp.loc"
nameserver = local.dnsserver
}