Ajout de terraform

guppy 2023-04-24 16:41:15 +02:00
parent bb49a010d0
commit d9d6afae2d
3 changed files with 100 additions and 0 deletions

65
terraform/main.tf 100644
View File

@ -0,0 +1,65 @@
resource "proxmox_vm_qemu" "control_plane" {
count = 1
name = "control-plane-${count.index}.k8s.cluster"
target_node = "${var.pm_node}"
clone = "debian-11-cloudinit-template"
os_type = "cloud-init"
cores = 4
sockets = "1"
cpu = "host"
memory = 2048
scsihw = "virtio-scsi-pci"
bootdisk = "scsi0"
disk {
size = "20G"
type = "scsi"
storage = "local-lvm"
iothread = 1
}
network {
model = "virtio"
bridge = "vmbr0"
}
# cloud-init settings
# adjust the ip and gateway addresses as needed
ipconfig0 = "ip=192.168.0.11${count.index}/24,gw=192.168.0.1"
sshkeys = file("${var.ssh_key_file}")
}
resource "proxmox_vm_qemu" "worker_nodes" {
count = 3
name = "worker-${count.index}.k8s.cluster"
target_node = "${var.pm_node}"
clone = "debian-11-cloudinit-template"
os_type = "cloud-init"
cores = 4
sockets = "1"
cpu = "host"
memory = 4098
scsihw = "virtio-scsi-pci"
bootdisk = "scsi0"
disk {
size = "20G"
type = "scsi"
storage = "local-lvm"
iothread = 1
}
network {
model = "virtio"
bridge = "vmbr0"
}
# cloud-init settings
# adjust the ip and gateway addresses as needed
ipconfig0 = "ip=192.168.0.12${count.index}/24,gw=192.168.0.1"
sshkeys = file("${var.ssh_key_file}")
}

View File

@ -0,0 +1,16 @@
terraform {
required_providers {
proxmox = {
source = "telmate/proxmox"
version = "2.9.0"
}
}
}
provider "proxmox" {
pm_parallel = 1
pm_tls_insecure = true
pm_api_url = var.pm_api_url
pm_password = var.pm_password
pm_user = var.pm_user
}

View File

@ -0,0 +1,19 @@
variable "pm_api_url" {
default = "https://proxmox.local:8006/api2/json"
}
variable "pm_node" {
default = "vm"
}
variable "pm_user" {
default = ""
}
variable "pm_password" {
default = ""
}
variable "ssh_key_file" {
default = "~/.ssh/id_rsa.pub"
}