feat: Create nodes from templates
This commit is contained in:
parent
8f7e83d818
commit
c68529eb69
13 changed files with 230 additions and 143 deletions
|
|
@ -7,7 +7,7 @@ machine:
|
|||
network:
|
||||
hostname: ${hostname}
|
||||
nameservers:
|
||||
- 10.13.37.2
|
||||
- 192.168.1.2
|
||||
interfaces:
|
||||
- interface: eth0
|
||||
dhcp: false
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ machine:
|
|||
network:
|
||||
hostname: ${hostname}
|
||||
nameservers:
|
||||
- 10.13.37.2
|
||||
- 192.168.1.2
|
||||
kubelet:
|
||||
extraArgs:
|
||||
pod-max-pids: 1000
|
||||
|
|
|
|||
|
|
@ -1,45 +0,0 @@
|
|||
terraform {
|
||||
required_providers {
|
||||
proxmox = {
|
||||
source = "bpg/proxmox"
|
||||
version = "0.86.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data "http" "schematic" {
|
||||
url = "https://factory.talos.dev/schematics"
|
||||
method = "POST"
|
||||
request_body = file("${path.module}/schematic.yaml")
|
||||
request_headers = {
|
||||
"Content-Type" = "application/x-yaml"
|
||||
}
|
||||
}
|
||||
|
||||
locals {
|
||||
schematic_id = jsondecode(data.http.schematic.response_body)["id"]
|
||||
iso_url = "${"https://factory.talos.dev/image"}/${local.schematic_id}/v${var.talos_version}/nocloud-amd64-secureboot.raw.xz"
|
||||
iso_file = "talos-${var.talos_version}-nocloud-amd64-secureboot.raw"
|
||||
}
|
||||
|
||||
resource "null_resource" "local_download_talos_image" {
|
||||
provisioner "local-exec" {
|
||||
command = <<EOT
|
||||
curl -L ${local.iso_url} -o ${path.module}/${local.iso_file}.xz
|
||||
xz -d ${path.module}/${local.iso_file}.xz
|
||||
EOT
|
||||
}
|
||||
}
|
||||
|
||||
resource "proxmox_virtual_environment_file" "talos-image" {
|
||||
depends_on = [null_resource.local_download_talos_image]
|
||||
|
||||
node_name = "pve01"
|
||||
content_type = "import"
|
||||
datastore_id = "local"
|
||||
overwrite = true
|
||||
|
||||
source_file {
|
||||
path = "${path.module}/${local.iso_file}"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
output "talos_image_id" {
|
||||
description = "The ID of the Talos image"
|
||||
value = proxmox_virtual_environment_file.talos-image.id
|
||||
}
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
customization:
|
||||
systemExtensions:
|
||||
officialExtensions:
|
||||
- siderolabs/qemu-guest-agent
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
variable "talos_version" {
|
||||
description = "Talos version to download"
|
||||
type = string
|
||||
}
|
||||
|
|
@ -12,16 +12,9 @@ resource "proxmox_virtual_environment_vm" "talos-node" {
|
|||
name = var.node.name
|
||||
node_name = var.node.proxmox_node
|
||||
tags = ["tofu"]
|
||||
bios = "ovmf"
|
||||
on_boot = true
|
||||
machine = "q35"
|
||||
stop_on_destroy = true
|
||||
|
||||
operating_system {
|
||||
type = "l26"
|
||||
}
|
||||
agent {
|
||||
enabled = true
|
||||
clone {
|
||||
vm_id = 10000 + tonumber(replace(var.node.talos_version, ".", ""))
|
||||
}
|
||||
|
||||
cpu {
|
||||
|
|
@ -37,7 +30,6 @@ resource "proxmox_virtual_environment_vm" "talos-node" {
|
|||
disk {
|
||||
datastore_id = var.node.storagepool
|
||||
interface = "virtio0"
|
||||
import_from = var.talos_image_id
|
||||
size = var.node.disk
|
||||
file_format = "raw"
|
||||
}
|
||||
|
|
@ -52,17 +44,6 @@ resource "proxmox_virtual_environment_vm" "talos-node" {
|
|||
}
|
||||
}
|
||||
|
||||
efi_disk {
|
||||
datastore_id = var.node.storagepool
|
||||
file_format = "raw"
|
||||
type = "4m"
|
||||
}
|
||||
|
||||
tpm_state {
|
||||
datastore_id = var.node.storagepool
|
||||
version = "v2.0"
|
||||
}
|
||||
|
||||
initialization {
|
||||
datastore_id = var.node.storagepool
|
||||
ip_config {
|
||||
|
|
@ -72,11 +53,7 @@ resource "proxmox_virtual_environment_vm" "talos-node" {
|
|||
}
|
||||
}
|
||||
dns {
|
||||
servers = ["10.13.37.2"]
|
||||
servers = ["192.168.1.2"]
|
||||
}
|
||||
}
|
||||
|
||||
network_device {
|
||||
bridge = "vmbr1"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,20 +1,23 @@
|
|||
variable "node" {
|
||||
description = "Virtual node configuration"
|
||||
description = "Basic configuration for the Talos node"
|
||||
type = object({
|
||||
id = number
|
||||
name = string
|
||||
ipv4_address = string
|
||||
ipv4_gateway = string
|
||||
cpu = number
|
||||
memory = number
|
||||
disk = string
|
||||
storagepool = string
|
||||
talos_version = string
|
||||
cluster_name = string
|
||||
kubernetes_version = string
|
||||
cluster_endpoint = string
|
||||
proxmox_node = string
|
||||
controlplane_addresses = list(string)
|
||||
worker_addresses = list(string)
|
||||
id = number
|
||||
name = string
|
||||
ipv4_address = string
|
||||
ipv4_gateway = string
|
||||
cpu = number
|
||||
memory = number
|
||||
disk = string
|
||||
storagepool = string
|
||||
talos_version = string
|
||||
cluster_name = string
|
||||
kubernetes_version = string
|
||||
cluster_endpoint = string
|
||||
proxmox_node = string
|
||||
})
|
||||
}
|
||||
variable "pvc_disks" {
|
||||
description = "List of extra disks to attach to the node"
|
||||
type = list(number)
|
||||
default = []
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue